I've a PermissionController
with a permission()
function like below, and i want to call the permission()
function in another controller. How can i call my permission()
function to another controller ?
here my PermissionController
class PermissionController extends Controller
{
public function permission(){
$checkPermission = User::leftJoin('employees', 'employees.user_id', '=', 'users.id')
->leftJoin('positions', 'employees.position_id', '=', 'positions.id')
->leftJoin('divisions', 'employees.division_id', '=', 'divisions.id')
->where(function($query){
$query->where('division_name', 'Sales')
->orWhere('division_name', '=', 'Project Management')
->orWhere('position_name', '=', 'Dept Head');
})
->get();
}
}
I think your function should be in one of your model since you're only getting value.
This will me more relevant according to MVC.
Having it in your User
model will let you use it on every instance of your application with a single call.