mercredi 23 janvier 2019

How to set custom attribute using eloquent using related model

Hi i have a elloquent query like this

$partners = DeliveryPartner::where('active', 1)
    ->where('blocked', 0)
    ->whereHas('deliveryPartnerZipcodes', function ($query) use ($zip4pp) {
        $query->where('zipcode', $zip4pp);
    })
    ->with('deliveryPartnerImage')
    ->with(['deliveryPartnerTimes' => function($query) {
        //HERE I WANT TO SET A PROPERTY ON THE BASE COLLECTION USING INFO FROM THIS MODEL
    }])
    ->get();

In delivery times there are opening and closing times. Using these times i want to set a propery called "status" on the parent like $partent->status = somevalue based on de data from deliverypartner times

how can i do this ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire