Skip to content
/ ytta Public

This repository aims to learn Polymorphic relationships in Laravel. In this repository there are Video, Post, Comment (Polymorphic) models.

Notifications You must be signed in to change notification settings

nnivxix/ytta

Repository files navigation

YTTA (Youtube Tes Asal 😋)

This repository aims to learn Polymorphic relationships in Laravel. In this repository there are Video, Post, Comment (Polymorphic) models.

Usage using tinker

Open tinker

php artisan tinker

Find $user

$user = \App\Models\User::find(1);

Create post and find post

$user->posts()->create([
    'title'   => 'test title',
    'content' => 'test content'
]);
$post = $user->posts()->find('uuid');

Create comment

$post->comments()->create([
    'user_id' => 1,
    'content' => 'comment post 1'
]);

Show Comments

$post->comments;

Usage using tinkerun

  1. open file ./.tinkerun/post.php.
  2. uncomments all codes,
  3. click run (click on top right corner) or ctrl + r (if you have configured the keybinding).

References

About

This repository aims to learn Polymorphic relationships in Laravel. In this repository there are Video, Post, Comment (Polymorphic) models.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages