/images/avatar.png

Laravel Login With Username Instead of Email

1. Install Laravel There’s a lot of way to install Laravel. In this time, I am going to use composer that is a dependency manager for PHP. 1 composer create-project laravel/laravel login-project 2. Install breeze that is a starter kit for authentication. breeze is a starter kit for authentication in Laravel 1 2 3 cd login-project composer require laravel/breeze --dev npm install && npm run dev 3. Migrate You should migrate database for using Laravel

Laravel Layouts

Laravel Blade Layouts Laravel uses Blade Templates extends @extends('file') is loading file.blade.php file. section/show, section/endsection, yield, parent Base File 1 2 3 4 5 @section('section-name1') <p>This is test section.</p> @show @yield('section-name2', 'Default Value') Extend File 1 2 3 4 5 6 7 8 9 10 11 12 13 @extends('base') @section('section-name1') @parent <!-- Load Parent Section Content --> <p>This is replace section-name1</p> @parent <!-- Load Parent Section Content --> @endsection @section('section-name2', 'This is section 2 value') stack, push/endpush, prepend/endprepend Base File

Laravel Often Used Artisan Commands

Create Controller 1 2 3 4 5 # Create Controller php artisan make:controller Auth/LoginController # Created a File vi app/Http/Controllers/Auth/LoginController.php Create Model with Create Table Migration 1 2 3 4 5 6 # Create Model with Migration File by Model php artisan make:model Board -m # Created Files vi app/Models/Board.php vi database/migrations/YYYY_MM_DD_000000_create_boards_table.php Create Modify Table Migration 1 2 3 4 5 # Create Migration File for Modify [users] table php artisan make:migration add_username_to_users --table users # Created a File vi database/migrations/YYYY_MM_DD_000000_add_username_to_users.

Laravel Dump and Die

Laravel Dump and Die The dd keyword is to show object’s detail in Laravel. 1 2 3 4 5 6 7 8 9 10 namespace App\Http\Contollers\Auth; use App\Http\Controllers\Controller; use Illuminate\Http\Request; class LoginController extends Controller { public function store(Request $request) { dd($request); } }

PHP trait in Class

PHP trait in Class The trait keyword is for merging classes. 1 2 3 4 5 6 7 8 9 10 11 12 trait ExampleTrait { public function Foo() { echo 'FOO'; } } class ExampleClass { use ExampleTrait; } $classInstance = new ExampleClass(); $classInstance->Foo();

Laravel Directory Structure

Note This document is for Laravel 8.x version and comes from official site Laravel . app The app directory contains the core code of your application. app/Broadcasting The Boardcasting directory contains all of the broadcast channel classes for your application. These classes are generated using the make:channel command. This directory does not exist by default, but will be created for you when you create your first channel. app/Console The Console directory contains all of the custom Artisan commands for your application.