1. Go to this page and download the library: Download oobook/manage-eloquent 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/ */
oobook / manage-eloquent example snippets
namespace App\Models;
use Oobook\Database\Eloquent\Concerns\ManageEloquent;
class Product extends Model
{
use ManageEloquent;
protected $fillable = [
'name'
];
public function tags(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{
return $this->morphToMany(
Tag::class,
'taggable'
);
}
public function category(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Category::class);
}
}
$product = new Product();
// RELATIONSHIPS
// get all defined Relationships
$product->definedRelationships(); // ['tags', 'category']
// get relationships by relationship type
$product->definedRelations('BelongsTo'), // ['category'];
$product->definedRelations(['BelongsTo', 'MorphToMany']), // ['tags', 'category'];
// get relation types
$product->definedRelationsTypes(),
// [
// "category" => "BelongsTo"
// "tags" => "MorphToMany"
// ]
$product->hasRelation('tags') // true;
$product->getRelationType('tags') // \Illuminate\Database\Eloquent\Relations\MorphToMany;
// COLUMNS
$product->hasColumn('name') // true if exists on db table;
$product->getColumns() // get the list of columns of the table;
// get the list of timestamp columns of the table;
$product->getTimestampColumns()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.