- laravel new laravelprojectname
- composer require laravel/breeze
- php artisan breeze:install
- npm instatall
- npm run dev
- php artisan migrate
add this file in view→layout→app.php in header
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<script src="{{ asset('js/app.js') }}" defer></script>
admin auth
php artisan make:model Admin -m
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
paste this in admin table
- copy user model file in admin model table and change class name
put this in web.php
//admin
Route::namespace('Admin')->prefix('Admin')->name('admin')->group(function(){
Route::namespace('auth')->group(function(){
});
});
crate a folder in admin folder name Admin and then
create a folder inside Admi folder name is Auth
<?php
namespace App\Http\Controllers\Admin\Auth; // chnage this line
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
public function create()
{
return view('admin.auth.login'); change this line
public function store(LoginRequest $request)
{
$request->authenticate();
$request->session()->regenerate();
return redirect()->intended(RouteServiceProvider::ADMIN_HOME); //change this line
}
Provider->routeservide provider .php
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/dashboard';
public const ADMIN_HOME = '/admin/dashboard';////// add this line
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
crate a folder inside view
-admin forlder create and inside admin create a forlder auth name
paste login.blade.php in inside admin auth folder
//admin
Route::namespace('Admin')->prefix('Admin')->name('admin')->group(function(){
Route::namespace('auth')->group(function(){
Route::get('login','AuthenticatedSessionController@index')->nanme('login')
//add this line });
});
0 Comments