9 months ago

Fetching Full Name From Model

Posted 9 months ago by kshitizmittal

I want to fetch full name from Employeedetail model.

Model Code :-

public function getFullNameAttribute() {
            return $this->first_name.' '.$this->middle_name.' '.$this->last_name;
            return $this->first_name.' '.$this->last_name;     

Controller Code :-

$supervisors = Employeedetail::where(['status'=>'Active'])->pluck('full_name','emp_id')->all();

Error Message :-

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'full_name' in 'field list' (SQL: select `full_name`, `emp_id` from `employeedetails` where (`status` = Active)) ◀"

Ultimate Goal is to pluck full name.

Please sign in or create an account to participate in this conversation.