Validator Laravel
Where can I put my validator to avoid typing it twice for storing and updating a table?
Where is the right place to put it? and make it reusable
@Sinnbeck how should I name a form request for example if I want to validate an 'Employee'?
@Kris01 StoreEmployeeRequest for instance
@Sinnbeck why is this happening ?
error
Target class [App\Http\Controllers\StoreEmployeeRequest] does not exist.
code
/**
* @param App\Http\Requests\StoreEmployeeRequest $request
* @return Illuminate\Http\Response
*/
public function store(StoreEmployeeRequest $request){
$employee = new Employee();
$statuses = $employee->getStatuses();
$shiftTypes = $employee->getShiftTypes();
$validated = $request->validated();
......
}
It's giving a wrong path
@Kris01 you need to import it
use App\Http\Requests\StoreEmployeeRequest
@Sinnbeck ok works, how do I access the old input now?
@Kris01 it works exactly the same as if I were to add validation in the controller method directly
Please or to participate in this conversation.