Laravel Installation and Authentication

Environment setup for Laravel Installation

Install this software – links also given

  1. Xampp –
  2. Composer –
  3. NPM –
  4. VS Code –

Check that Xampp is Installed and Working

Check Composer Intalled and Working

composer -v

Check NPM Intalled and Working

npm -v

Clear command on the CMD/POWERSHELL


VS Code Extension
Laravel Goto

Laravel Installation

composer create-project laravel/laravel your-project-name

Tutorial – Laravel Instatallation

Make Authentication (LOGIN/SIGNUP System)

> Database Connection

> composer require laravel/ui

> php artisan ui bootstrap ––auth (Write this, no copy)

> npm install

> npm run build

> npm run dev

> php artisan migrate

Make Authentication (LOGIN/SIGNUP System) (New)

> Database Connection

> composer require laravel/breeze –dev

> php artisan breeze:install blade

> php artisan migrate

Setup Admin Panel with Laravel

  1. Need an admin panel.
  2. Analysis it.
  3. Setup with Laravel view+layout.
  4. Controller setup
  5. Route setup

Role Management in Authentication

Necessary Command

php artisan make:migration add_role_in_users_table --table=users
php artisan make:middleware AdminMiddleware

Add this in migration, that created in last.

//column created

//column drop

Role logic

            if(Auth::user()->role == '1'){
                return $next($request);
                return redirect('/');
            return redirect('');

Make route


Some command

php artisan make:controller ControllerName

php artisan make:controller Folder/ControllerName

php artisan make:controller ControllerName -r

php artisan make:controller Folder/ControllerName -r

php artisan optimize
php artisan make:migration create_table_name
php artisan make: model model_name

php artisan make:migration add_new_fields_user_table –table=users

<h3>No Product Available Currently</h3>
<h3>Please visit after sometimes</h3>

Image Intervention Package Install

composer require intervention/image

file = $request['photo'];
$image_name = uniqid('user_').'_'.rand().'.'.$request['photo']->getClientOriginalExtension();
Image::make($request['photo'])->save(public_path('uploads/student/'.$image_name)); //raw

Some quick command

//For rollback one step
php artisan migrate:rollback --step=1

//Rollback specific migration
php artisan migrate:rollback --path=/database/migrations/migration_file_name.php

php artisan migrate:rollback --path=/database/migrations/2022_12_26_144352_create_agri_infos_table.php

//active class add
{{ request()->is('/') ? 'active' : ''}}

// ternary operator
{{ $single_order->order_status == 0 ? 'Pending' : 'Completed' }}

//Confirm with Jquery
<a onclick="return window.confirm('Are you sure?');" href="{{url('vet/me/farmerissue/solve/'.$data->id)}}">Solve</a>

Laravel Resource Controller, Model, Migration create

php artisan make:model Model_Name -mcr

Resource route:
Route::resource('/student', StudentController::class);

Laravel Create

In store method 

also return view possible

Laravel Read

$data = Model::all();
then compact in view

$data = Model::paginate(1);

Laravel Route Check

php artisan route:list

Laravel Version Check Command

php artisan --version

{{ phpversion() }}  //blade view php version
{{ app()->version() }} //blade view laravel version

php artisan about //all info view

check composer.json
check directory

Soft Delete in Laravel

Add a column deleted_at
php artisan make:migration add_delete_column_student_table --table=students

Migration file up:

Migration file down:

Migrate it. 
On model

use Illuminate\Database\Eloquent\SoftDeletes;
use SoftDeletes;

use HasFactory,SoftDeletes;

$data = Model::onlyTrashed()->get();

    public function hard_delete($id)
       $forceDelete = Student::where('id',$id)->forceDelete();

        return $forceDelete;


Encrypt Password Tool For Laravel


use Hash;
use Carbon\Carbon;

Leave a Comment