nnivxix / ytta

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.


Languages

Language:PHP 60.1%Language:Blade 39.3%Language:JavaScript 0.6%Language:CSS 0.0%