Code Explainers

Code explainers tagged #relationships

php
class Cart extends Model
{
    protected $fillable = ['user_id'];
 

Modeling a shopping cart in Laravel

eloquent relationships domain-model
Intermediate 7 steps
php
<?php
 
namespace Database\Seeders;
 

Building blog test data with Laravel factories

seeding factories relationships
Intermediate 9 steps
php
<?php
 
namespace App\Models;
 

Polymorphic comments in Laravel with morphTo

polymorphism eloquent relationships
Intermediate 5 steps