Is it possible to create a custom query builder inside a model and return the query? Not a stressing issue but would be helpful.
/* Controller */
public function getOrders()
{
$orders = \App\Order::where('is_new', 1)->getFromUserStore();
}
/* Order Model */
public function getFromUserStore()
{
if(\Auth::user()->store->id == 1)
{
return $this->get();
}
else
{
return $this->where('status_id', 1)->get();
}
}
Thanks
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ZdWH4Q
via IFTTT
Aucun commentaire:
Enregistrer un commentaire