| Install | |
|---|---|
composer require adideas/laravel-get-relationship-eloquent-model |
--
View (get) all links (links) of any eloquent Laravel models
Require this package with composer using the following command:
composer require adideas/laravel-get-relationship-eloquent-model
Put star :) please
use App\Http\Controllers\Controller;
use Adideas\RelationFinder\Relations;
class MyController extends Controller
{
public function show(MyModel $myModel, Relations $relations)
{
$relations->where('name', 'myRelationFunction'); // return collect
dd($relations); // return collect
Relations::relations($myModel)->where('name', 'myRelationFunction'); // return collect
}
}
OR
use Adideas\RelationFinder\RelationsFinder;
class MyModel extends Model
{
use RelationsFinder;
}
use App\Http\Controllers\Controller;
class MyController extends Controller
{
public function show(MyModel $myModel)
{
MyModel::relations()->where('name', 'myRelationFunction'); // return collect
// or
$myModel->relations()->where('name', 'myRelationFunction'); // return collect
}
}
If you want to see all models! Install the key.
class MyModel extends Model
{
const WITH_VENDOR_RELATION = true;
// or
public $withVendorRelation = true;
}