mercredi 30 mai 2018

Query inside a scope function in Laravel

Is it possible to do a query inside a scope function in Laravel, What am trying to do is get the total sum of available products in a model and compare it with the defined restocking level in another model.

This is what I have so far and its not working

public function scopeDuereorders($query)
{
    return $query->with(["centerdesc"])->where('reorderLevel',"<",Stockdetails::where('partNumb', $this->partcode)->sum('quantity'))->orderBy("partDesc", "ASC")->get();
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire