Skip to content

Instantly share code, notes, and snippets.

@instplanet
Created March 8, 2019 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save instplanet/950afd3ef766402a49c00390deef6573 to your computer and use it in GitHub Desktop.
Save instplanet/950afd3ef766402a49c00390deef6573 to your computer and use it in GitHub Desktop.
public function index() {
$this->validate($request, [
"equipmentType" => 'bail|required|in:pac,cto,roteamento,ponto|string',
"equipmentId" => [
"required",
Rule::exists($request->get('equipmentType')->where(function ($query) use ($request) {
$equipmentType = $request->get('equipmentType');
if($equipmentType === 'pac') {
$column = 'cdpac'
} else if ($equipmentType === 'cto') {
$column = 'cdcto'
}
$query->where($column, $request->get('equipmentId'));
}),
]
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment