Is it possible to pass a variable from Eloquent to Controller? I have here my code for Eloquent where i get the result of my filtered query and i wanna use that same variable to my Controller so that i can use it for my Exporting to excel. Here's my code for my eloquent model:
$result = $query
->orderBy('id', 'desc')
->paginate($perPage);
if ($search) {
$result->appends(['search' => $search]);
}
if ($emp_status) {
$result->appends(['emp_status' => $emp_status]);
}
if ($company) {
$result->appends(['company' => $company]);
}
if ($age) {
$result->appends(['age' => $age]);
}
if ($tenure) {
$result->appends(['tenure' => $tenure]);
}
if ($benefit) {
$result->appends(['benefit' => $benefit]);
}
if ($level) {
$result->appends(['level' => $level]);
}
if ($gender) {
$result->appends(['gender' => $gender]);
}
if ($civil_status) {
$result->appends(['civil_status' => $civil_status]);
}
if ($birthmonth) {
$result->appends(['birthmonth' => $birthmonth]);
}
return $result;
How can I get "$result" and use it in UsersController?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire