Hi!
How use relationships in admin panel?
For example: if I use model Projects and use Project_cats, How add project_cat in my project in field select?
in Project_cats model:
public function project()
{
return $this->hasMany('App\Projects');
}
in Projects model:
public function categories()
{
return $this->belongsToMany('App\Project_cats');
}
@IvanBohonosiuk there is no way for now to use relationship unless you override the projects route and use your own controller:
_on routes/web.php_ add this:
Route::resource('admin/projects', 'ProjectController');
Then create a new ProjectController.php to your app/Http/Controllers. You can copy VoyagerBreadController.php to your controller and edit it.
Don't forget to define VoyagerServiceProvider above AppServiceProvider so it will use web.php instead of voyager routes.php
_on config/app.php_:
/*
* Package Service Providers...
*/
// Voyager Service Providers
TCG\Voyager\VoyagerServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Most helpful comment