PHP code example of ooxif / laravel-query-param

1. Go to this page and download the library: Download ooxif/laravel-query-param 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/ */

    

ooxif / laravel-query-param example snippets


// table contains a binary column
Schema::create('images', function ($table) {
    $table->increments();
    $table->timestamps();
    $table->binary('data');
});


// use ModelTrait, add '(column name)' => 'binary' to $casts
class Image extends Eloquent
{
    use Ooxif\LaravelQueryParam\ModelTrait;

    protected $table = 'images';
    
    protected $casts = [
        'data' => 'binary',
    ];
}


$lob = 'some binary data'; 
$image = new Image();

// setting/getting 
$image->data = $lob;
$image->data; // object(Ooxif\LaravelQueryParam\Param\ParamLob)
$image->data->value() === $lob; // true

// saving
$image->save();

// querying (model) - use param_lob()
$image = Image::where('data', param_lob($lob))->first();

// querying (db) - use param_lob()
$result = DB::table('images')->where('data', param_lob($lob))->first();
$result->data === $lob; // true