Created
April 14, 2020 18:09
-
-
Save vijayrami/4e9c6dd2bb2e04a28cf229135f2e1f84 to your computer and use it in GitHub Desktop.
Create Custom request to apply validation
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
create file in App/Http/Requests/CsvImportRequest.php | |
<?php | |
namespace App\Http\Requests; | |
use Illuminate\Foundation\Http\FormRequest; | |
class CsvImportRequest extends FormRequest | |
{ | |
/** | |
* Determine if the user is authorized to make this request. | |
* | |
* @return bool | |
*/ | |
public function authorize() | |
{ | |
return true; | |
} | |
/** | |
* Get the validation rules that apply to the request. | |
* | |
* @return array | |
*/ | |
public function rules() | |
{ | |
return [ | |
'csv_file' => 'required|mimes:xlsx,xls,csv' | |
]; | |
} | |
} | |
in controller: | |
use App\Http\Requests\CsvImportRequest; | |
public function parseImport(CsvImportRequest $request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment