This repository aims to learn Polymorphic relationships in Laravel. In this repository there are Video, Post, Comment
(Polymorphic) models.
php artisan tinker
$user = \App\Models\User::find(1);
$user->posts()->create([
'title' => 'test title',
'content' => 'test content'
]);
$post = $user->posts()->find('uuid');
$post->comments()->create([
'user_id' => 1,
'content' => 'comment post 1'
]);
$post->comments;
- open file
./.tinkerun/post.php
. - uncomments all codes,
- click run (click on top right corner) or
ctrl + r
(if you have configured the keybinding).