Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
 
PREVIOUS NEXT
Tagged: #laravel #add #model #polymorphic #relationships
ADD COMMENT
Topic
Name
2+1 =