PHP code example of sfneal / models

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

    

sfneal / models example snippets

 php
// Create a new Model record
$model = YourModel::query()->create($data);

// returns true
$model->wasCreated();

// Update the Model
$model->update([
	'some_attribute' => 'blue'
]);	

// returns false
$model->wasCreated();

// returns true
$model->wasUpdated();
 php
use Illuminate\Database\Eloquent\Builder;
use Sfneal\Builders\QueryBuilder;

class ExampleModel extends Model
{
    /**
     * Query Builder.
     *
     * @param $query
     * @return QueryBuilder
     */
    public function newEloquentBuilder($query)
    {
        return new QueryBuilder($query);
    }
    
    /**
     * Query Builder method for improved type hinting.
     *
     * @return QueryBuilder|Builder
     */
    public static function query()
    {
        return parent::query();
    }
}