I have 2 model created like below:
Employee.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Employee extends Model
{
public function grades(){
return $this->belongsTo(Grade::class);
}
}
and also
Grade.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Grade extends Model
{
public function employee(){
return $this->hasMany(Employee::class);
}
}
when I try to show code ane name of Grade in tinker like below
$a=App\Employee::find(15);<br>
$a->grades->code
it gives me error :
PHP Notice: Trying to get property 'code' of non-object in Psy Shell code on line 1*
table employees:
table grades:

