Route::bind("company_code", function ($value) {
$comp = CompanyEloquent::where("code",$value)->first();
return $comp;
});
Route::bind("staff_code", function ($value) {
$comp = StaffEloquent::where([
"company_id" => ????,
"staff_code" => $value // 複合ユニークのため
])->first();
return $comp;
});
こんな感じのアレが、
use \Illuminate\Routing\Route;
Route::bind("company_code", function ($value) {
$comp = CompanyEloquent::where("code",$value)->first();
return $comp;
});
Route::bind("staff_code", function ($value,Route $route) {
$comp = StaffEloquent::where([
"company_id" => $route->parameter("company_code")->id,
"staff_code" => $value // 複合ユニークのため
])->first();
return $comp;
});
みたいに書けたりする。
便利。