Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel 6 use username instead of id

// using User->username instead of id on url:
public function show($user)
    {
  		// where<YourAtributeName>($param)->firstOrFail()
        $user = User::whereUsername($user)->firstOrFail();
        return view('users.show', ['user'=>$user]);
    }
Comment

PREVIOUS NEXT
Code Example
Php :: get ids from object 
Php :: laravel check if query builder is empty 
Php :: enable socket in php 
Php :: PHP OOP - Inheritance 
Php :: Logging a Massage php 
Php :: autoloading classes 
Php :: symfony twig variable 
Php :: avatar generator laravel 
Php :: Creating dynamic subdomain in php 
Php :: Publish Spatie Laravel Permission 
Php :: php/Laravel check if date is passed 
Php :: php 8 Match Expression / Switch Case 
Php :: php distinct 
Php :: laravel eloquent difference create and insert 
Php :: sweet alert confirm box laravel 
Php :: mail laravel 
Php :: require password confirm laravel 
Php :: what is route namespace in laravel 
Php :: wordpress basic auth 
Php :: laravel 419 error 
Php :: download html table to excel 
Php :: laravel available router methods 
Php :: how pass optional route parameter in laravel 
Php :: how to fetch data from database in php 
Php :: Bd phone number validation in laravel 
Php :: how many products can a laravel ecommerce handle 
Php :: Laravel Http client throw exception if request is not successful 
Php :: remove dashboard mya ccount 
Php :: cpt change link 
Php :: custom morph relation laravel 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =