vendredi 31 mars 2017

Laravel searching on hasone relationship

I want to be able to perform search on values in hasOne relationship.

I have deliverables and deliverable_versions table with hasMany relationship. So a deliverable can have many deliverable_versions.

I also have deliverable hasOne deliverable_version to get the latest version.

I want to be able to list the deliverables, but after performing a search on the latest version.

The problem is, in my current database, the versions have all the information needed in search.

So for example, I want to search on the values on "recent version" like this.

$deliverables = $account->deliverables()->with('recentVersion');
$deliverables = $deliverables->search($search); //<--Search on recent version
$deliverables = $deliverables->paginate(4);

How can I achieve something like this in Laravel Eloquent?

Any help is appreciated.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2nCL38s
via IFTTT

Aucun commentaire:

Enregistrer un commentaire