PHP code example of datalogix / laravel-builder-macros
1. Go to this page and download the library: Download datalogix/laravel-builder-macros library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
datalogix / laravel-builder-macros example snippets
// Params: $column, $query
$query->addSubSelect('primary_address_id',
Address::select('id')
->where('user_id', $user->id)
->primary()
);
// It adds primary_address_id to the result set
$query->defaultSelectAll()
->join('contacts', 'users.id', '=', 'contacts.user_id')
->addSelect('contacts.name as contact_name');
$query->filter(['name' => 'john'])->get();
// Returns all results where name
$query->filter(['name' => 'john', 'contact.email' => '@'])->get();
// Returns all results where name