source: app/Http/Requests/Dashboard/FileRequest.php@ c6b84df

develop
Last change on this file since c6b84df 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
Line 
1<?php
2
3namespace App\Http\Requests\Dashboard;
4
5use App\Helpers\Alert;
6use App\Models\FileType;
7use App\Rules\UploadCount;
8use Illuminate\Foundation\Http\FormRequest;
9
10class 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 {
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;
54 }
55}
Note: See TracBrowser for help on using the repository browser.