mercredi 18 mai 2022

Laravel hasOne can't only one attribute from the relation model

I have a Model called User That has one to many relation with orders I'm trying to get using an eloquent relation the first order date he did

I tried adding in the User Model

public function firstOrderDate(){
return $this->hasOne(Order::class)->oldest();
}

My Query

User::whereHas('firstOrderDate')->with('firstOrderDate')->get()

it's returning the Whole Order model I even tried to add select('date') it's returning null now



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/yjeIN0f
via IFTTT

Aucun commentaire:

Enregistrer un commentaire