Car.php
class Car extends Model {
protected $table = 'master_cars';
}
Person.php
class Person extends Model {
protected $table = 'master_persons';
public function car() {
return $this->belongsTo('App\Models\Car', 'car_id', 'id');
}
}
Controller.php
$cars = Car::orderBy('id', 'desc')->where('name', '=', $request->name);
if (!empty($request->person)) {
$cars->join('master_persons', 'master_persons.car_id', '=', 'master_cars.id')
->where('master_persons.name', '=', $request->person);
}
$cars->paginate(10);
return view('main.index')
->with('cars', $cars);
index.blade.php
@foreach ($cars as $car)
{!! car->name !!}
@endforeach
{!! $cars->render() !!}
In this way, when you use the Eloquent, the following error occurs.
"Call to undefined method Illuminate\Database\Query\Builder::render() "
Resolution is or not people can be seen?