Answers for "polymorphic relationship laravel example"

PHP
0

morph relation laravel

You may register the morphMap in the boot function of your 
AppProvidersAppServiceProvider class or create a separate service provider 
if you wish.

use IlluminateDatabaseEloquentRelationsRelation;

Relation::morphMap([
    'post' => 'AppModelsPost',
    'video' => 'AppModelsVideo',
]);
Posted by: Guest on January-06-2021
0

laravel add model to polymorphic relationships

//Create a new Tag instance (fill the array with your own database fields)
$tag = new Tag(['name' => 'Foo bar.']);

//Find the video to insert into a tag
$video = Video::find(1);

//In the tag relationship, save a new video
$tag->videos()->save($video);
Posted by: Guest on December-03-2021
0

laravel polymorphic relationship why we need this relation orm,

$user->roles()->toggle([1, 2, 3]);
Posted by: Guest on March-13-2021

Code answers related to "polymorphic relationship laravel example"

Browse Popular Code Answers by Language