develop
Last change
on this file since 24a616f was 24a616f, checked in by Berat Kjufliju <kufliju@…>, 3 years ago |
added documents crud, added last_seen_to_user, edited views
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Requests\Dashboard;
|
---|
4 |
|
---|
5 | use App\Models\Document;
|
---|
6 | use Illuminate\Foundation\Http\FormRequest;
|
---|
7 |
|
---|
8 | class DocumentRequest extends FormRequest
|
---|
9 | {
|
---|
10 | /**
|
---|
11 | * Determine if the user is authorized to make this request.
|
---|
12 | *
|
---|
13 | * @return bool
|
---|
14 | */
|
---|
15 | public function authorize()
|
---|
16 | {
|
---|
17 | if($this->isMethod("patch")) {
|
---|
18 | $document = Document::find($this->route("id"));
|
---|
19 | return auth()->user()->hasPermission("edit_all_documents") || ($document->user->id == auth()->user()->id);
|
---|
20 | }
|
---|
21 |
|
---|
22 | return true;
|
---|
23 | }
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Get the validation rules that apply to the request.
|
---|
27 | *
|
---|
28 | * @return array
|
---|
29 | */
|
---|
30 | public function rules()
|
---|
31 | {
|
---|
32 | $rules = [
|
---|
33 | "arch_id" => "required|min:10|max:255",
|
---|
34 | "name" => "required|min:10|max:255",
|
---|
35 | "department" => "required|integer|exists:departments,id",
|
---|
36 | "description" => "required|min:30",
|
---|
37 | ];
|
---|
38 |
|
---|
39 | if($this->isMethod("patch")) {
|
---|
40 | $fileRules = [
|
---|
41 | "file_item.*" => "mimes:jpg,jpeg,png|max:4096"
|
---|
42 | ];
|
---|
43 | } else {
|
---|
44 | $fileRules = [
|
---|
45 | "file_item.*" => "mimes:jpg,jpeg,png|max:4096"
|
---|
46 | ];
|
---|
47 | }
|
---|
48 |
|
---|
49 | $rules = array_merge(
|
---|
50 | $rules,
|
---|
51 | $fileRules,
|
---|
52 | );
|
---|
53 |
|
---|
54 | return $rules;
|
---|
55 | }
|
---|
56 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.