lundi 5 juin 2017

how to use traits in laravel models

Hello i'm laravel beginner

I want to make trait and use it in my model but at run time i got error that the trait is not found

my trait :

namespace App;

use Illuminate\Support\Facades\Schema;

trait GeneralModel { public static function testStaticFunction() { dd('test'); } }

my model :

namespace App;
use Illuminate\Database\Eloquent\Model;

class Comment extends Model { use GeneralModel;

}

my controller

namespace App\Http\Controllers;

use App\Comment;

class SearchController extends Controller { public function find(){ Comment::testStaticFunction(); }

}

error received

Trait 'App\GeneralModel' not found



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire