nicolaslopezj / searchable

A php trait to search laravel models
MIT License
2.01k stars 291 forks source link

Search not giving result #117

Open binita-engg89 opened 8 years ago

binita-engg89 commented 8 years ago

Value of Gr_no : gr22rmNO In database

In Model

protected $searchable = [ 'columns' => [ 'purchase.sr_no' => 10, 'purchase.gr_no' => 10],

];

or this way

protected $searchable = [ 'columns' => [ 'purchase.sr_no', 'purchase.gr_no'],

];

In Controller $purchase = Purchase::search('g', null, true)->get();

Result returns blank array

Collection {#895

items: []

}

am i doing any wrong???

Thanks

scripta55 commented 8 years ago

hi @binita-engg89 does your model return data on its own? if you call purchase::all();

binita-engg89 commented 8 years ago

@scripta55 yes

chAhmedRaza commented 7 years ago

Same is happening with me. Any solution yet?

jozeflambrecht commented 6 years ago

workaround would be:

Order::withoutGlobalScopes()->search($query)->where('team_id', Auth::user()->team_id)->get();

So re-adding your constraint after removing the global scope...