laravel8

Synopsis

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things. Laravel is accessible, yet powerful, providing tools needed for large, robust applications.

CLI Commands

Project Commands

SyntaxDescription
$ laravel new projectNameNew Project
$ php artisan serveLaunch server
$ php artisan listCommands list
$ php artisan tinkerLaravel Console
$ php artisan route:listRoute List

Common Commands

SyntaxDescription
$ php artisan migrateDatabase migration
$ php artisan db:seedData seed
$ php artisan make:migration create_products_tableCreate table migration
$ php artisan make:model Product -mcfCreate from model with options: -m (migration), -c (controller), -r (resource controllers), -f (factory), -s (seed)
$ php artisan make:controller ProductsControllerCreate a controller
$ php artisan make:migration add_date_to_blogposts_tableUpdate table migration
$php artisan migrate:rollbackRollback latest migration
$ php artisan migrate:resetRollback all migrations
$ php artisan migrate:refreshRollback all and re-migrate
$php artisan migrate:refresh --seedRollback all, re-migrate and seed

Authentication

SyntaxDescription
Auth::check();Determine if the current user is authenticated
Auth::user();Get the currently authenticated user
Auth::id();Get the ID of the currently authenticated user
Auth::attempt(array('email' => $email, 'password' => $password));Attempt to authenticate a user using the given credentials
Auth::attempt($credentials, true);‘Remember me’ by passing true to Auth::attempt()
Auth::once($credentials);Log in for a single request
Auth::login(User::find(1));Log a user into the application
Auth::loginUsingId(1);Log the given user ID into the application
Auth::logout();Log the user out of the application
Auth::validate($credentials);Validate a user’s credentials
Auth::basic('username');Attempt to authenticate using HTTP Basic Auth
Auth::onceBasic();Perform a stateless HTTP Basic login attempt
Password::remind($credentials, function($message, $user){});Send a password reminder to a user