PHP code example of bjnstnkvc / builder-make-command

1. Go to this page and download the library: Download bjnstnkvc/builder-make-command 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/ */

    

bjnstnkvc / builder-make-command example snippets


use App\Models\Builders\UserBuilder;

/**
 * Create a new Eloquent query builder for the model
 *
 * @param $query
 *
 * @return UserBuilder
 */
public function newEloquentBuilder($query): UserBuilder
{
    return new UserBuilder($query);
}

User::whereId(?string $operator = null, ?string $value = null);
User::whereIdNot(?string $operator = null, ?string $value = null);
User::whereIdIn(array $values);
User::whereIdNotIn(array $values);
User::orWhereId(?string $operator = null, ?string $value = null);
User::orWhereIdNot(?string $operator = null, ?string $value = null);
User::orWhereIdIn(array $values);
User::orWhereIdNotIn(array $values);

// Methods for other database columns.

User::whereId(1)
    ->orWhereNameNot('John')
    ->first();

User::whereId('>', 1)
    ->orWhereEmail('[email protected]')
    ->first();

User::whereName('John')
    ->where(function (UserBuilder $query) {
        $query->whereEmail('[email protected]')
              ->orWhereTitle('Admin');
    })
    ->first();

use App\Models\Builders\UserBuilder;

/**
 * @method static UserBuilder query() Begin querying the model.
 *
 * @mixin UserBuilder
 */
class User extends Authenticatable
{
    //
}
bash
php artisan vendor:publish --provider="Bjnstnkvc\BuilderMakeCommand\BuilderMakeCommandServiceProvider" --tag=make-builder-config
bash
php artisan vendor:publish --provider="Bjnstnkvc\BuilderMakeCommand\BuilderMakeCommandServiceProvider" --tag=make-builder-stubs
bash
php artisan make:builder UserBuilder
bash
php artisan make:builder UserBuilder User
bash
php artisan make:builder UserBuilder User --force
bash
php artisan make:builder