develop
Last change
on this file since 112ba6d was c6b84df, checked in by beratkjufliju <kufliju@…>, 3 years ago |
added fileTypes controller, notifications, excel export, edited views
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[ea7b12a] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Http\Requests\Dashboard;
|
---|
| 4 |
|
---|
[c6b84df] | 5 | use App\Helpers\Alert;
|
---|
| 6 | use App\Models\FileType;
|
---|
| 7 | use App\Rules\UploadCount;
|
---|
[ea7b12a] | 8 | use Illuminate\Foundation\Http\FormRequest;
|
---|
| 9 |
|
---|
| 10 | class FileRequest extends FormRequest
|
---|
| 11 | {
|
---|
| 12 | /**
|
---|
| 13 | * Determine if the user is authorized to make this request.
|
---|
| 14 | *
|
---|
| 15 | * @return bool
|
---|
| 16 | */
|
---|
| 17 | public function authorize()
|
---|
| 18 | {
|
---|
| 19 | return true;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * Get the validation rules that apply to the request.
|
---|
| 24 | *
|
---|
| 25 | * @return array
|
---|
| 26 | */
|
---|
| 27 | public function rules()
|
---|
| 28 | {
|
---|
[c6b84df] | 29 | $rules = [
|
---|
| 30 | "folder" => "required|integer|exists:folders,id",
|
---|
| 31 | ];
|
---|
| 32 |
|
---|
| 33 | $mimes = FileType::find("1")->mimes;
|
---|
| 34 | $maxSize = FileType::find("1")->max_size;
|
---|
| 35 |
|
---|
| 36 | if ($this->isMethod("patch")) {
|
---|
| 37 | $fileRules = [
|
---|
| 38 | "file_item.*" => "mimes:{$mimes}|max:{$maxSize}"
|
---|
| 39 | ];
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | else {
|
---|
| 43 | $fileRules = [
|
---|
| 44 | "file_item.*" => "mimes:{$mimes}|max:{$maxSize}"
|
---|
| 45 | ];
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | $rules = array_merge(
|
---|
| 49 | $rules,
|
---|
| 50 | $fileRules,
|
---|
| 51 | );
|
---|
| 52 |
|
---|
| 53 | return $rules;
|
---|
[ea7b12a] | 54 | }
|
---|
| 55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.