PHP code example of churakovmike / laravel-extended-builder

1. Go to this page and download the library: Download churakovmike/laravel-extended-builder 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/ */

    

churakovmike / laravel-extended-builder example snippets


composer 



namespace App;

use ChurakovMike\ExtendedBuilder\ExtendedQuery;

/**
 * Class UserQuery
 * @package App
 *
 * @property string $modelClass
 */
class UserQuery extends ExtendedQuery
{
    public function isActive()
    {
        return $this->where('status', true);
    }
    
    public function hasName($name)
    {
        return $this->where('name', $name);
    }
}




namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;

/**
 * Class User
 * @package App
 */
class User extends Authenticatable
{
    public static function where()
    {
        return new \App\UserQuery(get_called_class());
    }
}

$user = User::where()
        ->isActive()
        ->first();

$user = User::where()
        ->isActive()
        ->hasName('Mike')
        ->first();