i have this query
$classroom = Classroom::with('students:id,name')->find($classroom);
its give-me the result
Array
(
[0] => Array
(
[id] => 1
[name] => Adriel dos Santos Azevedo
[pivot] => Array
(
[classroom_id] => 1
[student_id] => 1
)
)
but i need of this resut without the Pivot
[pivot] => Array
(
[classroom_id] => 1
[student_id] => 1
)
For this i make in model Student
protected $hidden = ['pivot'];
But i should like solved it at query and no in Model.
Anythink like
$classroom = Classroom::with('students:id,name')->without('students.Pivot')->find($classroom);
How to do it?
I so get it doing
$classroom = Classroom::with('students:id,name'))->find($classroom);
$students = [];
foreach($classroom->students->makeHidden("pivot") as $student) {
$students[] = $student->toArray();
};
echo '<pre>';
print_r($students);
But note that is the PHP tthat be working,not the Eloquent Query