-2
I have a Model called Record, This Model has a method like HasOne
who is called Item, I’m implementing a search, but here’s the problem.
All the methods work normally, the problem is the following, when I do the search the results are returned in the two queries, see how they are:
<?php
$record->where( 'title', 'LIKE', "%{$request->ask}%" );
// essa tabela retorna como foi pedido, um modelo Record com o title e outros campos.
$record->item()->where( 'name', 'LIKE', "%{$request->ask}%" );
// Essa também retorna o que foi pedido um modelo Item com o name e outros campos
What I want is to make the second query return, not only the items table, but also return the parent model with all the methods that exist in the model, so I can use it as the original.
The father is the
item()
?– CypherPotato
The Record is the father.
– Baile do Gauchinho
you want to run the filter on the two?
– novic
I want to search the Record if the terms exist it returns the Record model, if it exists in the Item model Returns the Record relative to it.
– Baile do Gauchinho
This answers your question? How to use hasmany relationship in Laravel 5.2?
– novic
I have not already reviewed the ORM no more is there the answer, I think I will have to change my database logic so, more vlw for trying to help me, I think in my heart my logic is that is wrong.
– Baile do Gauchinho