I am trying to show one single record based on id. And I am getting this error:
Trying to get property of non-object
Show function from ClientsController:
public function show( Clients $clients)
{
$clients = Clients::find($clients->id);
return view('clients.show', ['clients' => $clients]);
}
single show.blade view file
@extends('layouts.app')
@section('content')
<h1>{{ $clients->name }}</h1>
@endsection
Clients model:
class Clients extends Model
{
//
protected $fillable = [
'name', 'type', 'user_id', 'sales_id', 'regions_id'
];
public function user(){
return $this->belongsTo('App\User');
}
public function region(){
return $this->belongsTo('App\Regions');
}
public function sales(){
return $this->belongsTo('App\Sales');
}
}
Database: https://take.ms/7kuo4