PHP code example of alvarofpp / expand-database

1. Go to this page and download the library: Download alvarofpp/expand-database 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/ */

    

alvarofpp / expand-database example snippets


'providers' => [
    // ...

    Alvarofpp\ExpandDatabase\ExpandDatabaseServiceProvider::class,

    // ...
],


Schema::create('users', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->string('email')->unique();
    $table->timestamp('email_verified_at')->nullable();
    $table->string('password');
    $table->rememberToken();
    $table->timestamps();

    $table->comment('Stores users');
});


Schema::table('users', function (Blueprint $table) {
    $table->removeComment();
});


$query = Course::where('price', '>', $request->price)
    ->where('rating', '>=', $request->min_rating)
    ->where('rating', '<=', $request->max_rating);

dd($query->toSql(), $query->toSqlWithBindings());

// toSql(): "select * from "courses" where "price" > ? and "rating" >= ? and "rating" <= ?"
// toSqlWithBindings(): "select * from "courses" where "price" > 100.0 and "rating" >= 4.3 and "rating" <= 5.0"