Created
March 8, 2019 15:24
-
-
Save instplanet/950afd3ef766402a49c00390deef6573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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