Helper function – array_add() (laravel 5.2): link
The method appends the key/value pair to the existing array. This can be useful when adding additional fields when creating new record with request all() method. If the form and database field names are same than just pass the request->all() method. If you still see that the input is not creating new record than you must define all your fillable fields under the model.
For example:
$new_department = Department::create(array_add($request->all(),'company_id',Auth::user()->company->first()->id));
or
$data = $request->all();
$data['company_id'] = Auth::user()->company->first()->id;
Department::create($data);
Use pluck vs list (laravel 5.2) : link
The pluck method returns an array. Both method to do the same thing.
For example:
$this->departments->whereCompanyId(Auth::user()->company->first()->id)->pluck('name', 'id')