I need to alias when I do a Laravel eager loading:
$employee = Employee::with(['profilepic', 'emp_company'])->find($user->employee_id);
In my model I have profilepic function and emp_company function. I need to pass a company object without renaming the emp_company funtion to company.
I need to to this because I want the JSON response as profilepic and company. for the frontend I need emp_company object as company. It is possible to alias.
from Newest questions tagged laravel-5 – Stack Overflow https://ift.tt/3kVHYjm