vendredi 20 juillet 2018

Laravel - Return Collection Where Attribute of Model Records is Empty

I have the following section of one of my functions:

$shipmentsNotSent = DB::table('shipments')
        ->whereNull(['billedAt','agentBilling'])
        ->whereBetween('date', [$startDateNS, $nowNS])
        ->get();

This works well but I am currently in the process of streamlining the models/controllers and a variety of other files, and I need it also to return only records that return nothing in the custom attribute (see below) I set up for the Shipment model.

public function getbillingUploadStatusAttribute(){
    $billingUploadStatus = $this->billingUpdates()->where([
        ['actionCategoryID', 1],
        ['actionID', 2]
    ])->orderBy('created_at','desc')->first();
    return $billingUploadStatus;
}

So how would I go about filtering those records already filtered in the above controller function also return nothing in the attribute return?

Matt



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire