Laravel cheatsheet (MAIN)
Commons commands
// Database migration
$ php artisan migrate
// Data seed
$ php artisan db:seed
// Create table migration
$ php artisan make:migration create_products_table
// Create from model with options:
// -m (migration), -c (controller), -r (resource controllers), -f (factory), -s (seed)
$ php artisan make:model Product -mcf
// Create a controller
$ php artisan make:controller ProductsController
// Update table migration
$ php artisan make:migration add_date_to_blogposts_table
// Rollback latest migration
php artisan migrate:rollback
// Rollback all migrations
php artisan migrate:reset
// Rollback all and re-migrate
php artisan migrate:refresh
// Rollback all, re-migrate and seed
php artisan migrate:refresh --seedCreate and update data tables (with migrations)
Models
Factory
Seed
Running Seeder
Eloquent ORM
Routes
Cache
Controllers
Template
Database direct access no model
Helpers
Flash & Session
HTTP Client
Storage
(helper class to store files locally or in the cloud)
Install a project from github
Heroku deployment
Rest API
(create a Rest API endpoint)
API Resource
(Layer that sits between your models and the JSON responses)
API Resource definition file
API Controller
(Best practice is to place your API controllers inside app/Http/Controllers/Api/v1/)
API Token authentication
First you need to create a Token for a specific user.
You can then use this token is a request
Authorization rules You can create a token with pre-define auth rules
Last updated