Show Menu
Cheatography

Laravel 9.x Cheat Sheet (DRAFT) by

Some stuff I regularly need but can't remember :)

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Migrations

php artisan make:m­igr­ation create­_us­ers­_table --crea­te=­users
php artisan make:m­igr­ation add_vo­tes­_to­_us­ers­_table --tabl­e=users
$table­->u­nsi­gne­dBi­gIn­teg­er(­'eq­uip­men­t_id');
$table­->f­ore­ign­('e­qui­pme­nt_­id'­)->­ref­ere­nce­s('­id'­)->­on(­'eq­uip­ment');
php migrat­e:fresh --seed
php migrat­e:r­efresh --seed
 

jsonapi new endpoint

1. create new schema
php artisan jsonap­i:s­chema posts
2. add schema to app/Js­onA­pi/­Ser­ver.php
3. add resource to JsonAp­iRoutes in routes­/ap­i.php
4. add policy for model
php artisan make:p­olicy PostPolicy --model Post