1. Go to this page and download the library: Download laravel-ready/model-support 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/ */
laravel-ready / model-support example snippets
use LaravelReady\ModelSupport\Traits\Sluggable;
use LaravelReady\ModelSupport\Traits\HasActive;
...
class Post extends Model
{
use Sluggable, HasActive;
protected $fillable = [
'title',
'slug',
'content',
'is_active'
];
...
}
use LaravelReady\ModelSupport\Traits\HasLanguage;
...
$model->lang('en'); // will return $query->where('lang', $lang);
$model->langNot('en'); // will return $query->where('lang', '!=', $lang);
$model->langIn(['en', 'tr']); // will return $query->whereIn('lang', $langs);
$model->langNotIn(['en', 'tr']); // will return $query->whereNotIn('lang', $langs);
use LaravelReady\ModelSupport\Traits\Sluggable;
...
$model->slug('any-string'); // will return $query->where('slug', $slug);
$model->slugLike('any-string'); // will return $query->where('slug', 'like', $slug);
$model->slugNot('any-string'); // will return $query->where('slug', '!=', $slug);
$model->slugNotLike('any-string'); // will return $query->where('slug', 'not like', $slug);
$model->slugIn(['any-string', 'any-string']); // will return $query->whereIn('slug', $slug);
$model->slugNotIn(['any-string', 'any-string']); // will return $query->whereNotIn('slug', $slug);
use LaravelReady\ModelSupport\Traits\SluggableTitle;
...
use LaravelReady\ModelSupport\Traits\SluggableName;
...
use LaravelReady\ModelSupport\Traits\ParentChild;
...
$model->parent(); // will return parent model
$model->children(); // will return children models
$model->allChildren(); // will return all children models
$model->allChildrenIds(); // will return all children ids
$model->recursiveParentAndChildren(); // will return all parent and children models
use LaravelReady\ModelSupport\Traits\HasActive;
...
$model->status(true|false); // will return $query->where('is_active', $status);
$model->active(); // will return $query->where('is_active', true);
$model->inactive(); // will return $query->where('is_active', false);