Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to make trait in laravel

/*
|==============================================================
| How to create traits in laravel --
|==============================================================
| 1) There is no specific command for traits in Laravel 8.
| 2) Create Traits folder in app folder of laravel and add file 
|	 UserTrait.php in that trait folder.
|
*/

<?php
namespace AppTraits;
 
trait UserTrait {

    public function method1() 
    {
 		// write code here
    }
  
   	public function method2() 
    {
 		// write code here
    }
 
}
 
PREVIOUS NEXT
Tagged: #trait #laravel
ADD COMMENT
Topic
Name
5+3 =