Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel blade auth check

@guest
    // Show content if  unauthenticated
@endguest

@auth
    // The data only available for auth user
@endauth
Comment

laravel blade auth user

{{ auth()->user()->email }}
Comment

auth laravel 9

// With Boothstrap
composer require laravel/ui --dev
php artisan ui bootstrap --auth
npm install
npm run build
npm run dev
Comment

laravel auth

composer require laravel/ui

php artisan ui vue --auth

npm install && npm run dev
Comment

custom laravel auth

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use Hash;
use Session;
use AppModelsUser;
use IlluminateSupportFacadesAuth;
class CustomAuthController extends Controller
{
    public function index()
    {
        return view('auth.login');
    }  
      
    public function customLogin(Request $request)
    {
        $request->validate([
            'email' => 'required',
            'password' => 'required',
        ]);
   
        $credentials = $request->only('email', 'password');
        if (Auth::attempt($credentials)) {
            return redirect()->intended('dashboard')
                        ->withSuccess('Signed in');
        }
  
        return redirect("login")->withSuccess('Login details are not valid');
    }

    public function registration()
    {
        return view('auth.registration');
    }
      
    public function customRegistration(Request $request)
    {  
        $request->validate([
            'name' => 'required',
            'email' => 'required|email|unique:users',
            'password' => 'required|min:6',
        ]);
           
        $data = $request->all();
        $check = $this->create($data);
         
        return redirect("dashboard")->withSuccess('You have signed-in');
    }

    public function create(array $data)
    {
      return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => Hash::make($data['password'])
      ]);
    }    
    
    public function dashboard()
    {
        if(Auth::check()){
            return view('dashboard');
        }
  
        return redirect("login")->withSuccess('You are not allowed to access');
    }
    
    public function signOut() {
        Session::flush();
        Auth::logout();
  
        return Redirect('login');
    }
}
Comment

laravel Blade @auth

//Typical way:
@if(auth()->user())
 // The user is authenticated.
 @endif

//Shorter:

 @auth
 // The user is authenticated.
 @endauth
Comment

laravel auth

//namespace
use IlluminateSupportFacadesAuth;
Comment

PREVIOUS NEXT
Code Example
Php :: laravel search multiple (related) tables 
Php :: php all date arguments 
Php :: softDelete laravel8 
Php :: get query string in symfony twig 
Php :: laravel get view variables 
Php :: how to redirect to another page in php after submit 
Php :: php file upload 
Php :: get request header codeingiter3 
Php :: php upload multiple files 
Php :: rest api response 404 wordpress 
Php :: get_adjacent_post wordpress 
Php :: symfony rabbitMQ 
Php :: codeigniter 4 delete redirect with data 
Php :: get date to current week last or first day dates 
Php :: laravel localization 
Php :: php prepared statement upload file 
Php :: isset laravel 
Php :: how to set up alert messages in laravel 8 
Php :: laravel exclude field 
Php :: get php ini config from terminal 
Php :: wordpress add button to admin bar 
Php :: two condition in one laravel query 
Php :: jquery is less than or equal to 
Php :: Download any version of xampp 
Php :: how to save and get checkbox value in database php 
Php :: foreach smarty 
Php :: laravel uuid not showing in query 
Php :: transforming string to integer in php 
Php :: php array push 
Php :: laravel composer create project 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =