Booting trait on eloquent model

Posted 2 years ago by Geoffrey06

Hi !

I have a probleme , when i'm trying to use a trait on specific model .

I have a model :

namespace App;

use Illuminate\Database\Eloquent\Model;


class TagCategorie extends Model
{
    use SearcheableCategorie;

    public function scopeCategorie($query ){
        $query = $query->search();
        return $query->get();
    }
}

And i have a trait

namespace App;


trait SearcheableCategorie
{

    protected $cat;
    protected $model;


    public function search()
    {
        $query = $query->where('CAT_therm', '=' , '1');
    }

   
}

But it return an : BadMethodCallException in Builder.php line 2372: Call to undefined method Illuminate\Database\Query\Builder::search()

Please sign in or create an account to participate in this conversation.