Laravel 5 Model Accessor Displayed as Undefined Variable -
i have following laravel model class , have accessor location name follows (not sure if correct syntax)
class job extends model { public function location() { return $this->belongsto('app\location'); } public function getlocationnameattribute() { return $this->location('name'); } }
in form have following:
{!! form::text('location_name', $locationname !!}
but error undefined variable: locationname when try view page.
the location table has 2 columns(id, name) , want name of location associated job. how do this. in job table store location_id. can follows isset($job->location_id) ? $job->location->name : ''
i'm trying understand how can achieve same using accessor. can 1 shed light please.
Comments
Post a Comment