Ignore:
Timestamp:
10/17/21 20:28:35 (3 years ago)
Author:
Berat Kjufliju <kufliju@…>
Branches:
develop, master
Children:
e6c1f87
Parents:
d795fa6
Message:

added arch_id validation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Requests/Dashboard/DocumentRequest.php

    rd795fa6 rbd9e8e3  
    1616    public function authorize()
    1717    {
    18         if($this->isMethod("patch")) {
     18        if ($this->isMethod("patch")) {
    1919            $document = Document::find($this->route("id"));
    2020            return auth()->user()->hasPermission("edit_all_documents") || ($document->user->id == auth()->user()->id);
     
    3333
    3434        $rules = [
    35             "arch_id" => "required|min:10|max:255",
     35            "arch_id" => [
     36                "required",
     37                function($attribute, $value, $fail) {
     38                    $arch_id = $this->request->get('arch_id');
     39                    $deptId = explode('/', $arch_id)[0];
     40                    if ($deptId !== $this->request->get('department')) {
     41                        $fail("Dept id error");
     42                    }
     43                }
     44            ],
    3645            "name" => "required|min:10|max:255",
    3746            "department" => "required|integer|exists:departments,id",
     
    3948        ];
    4049
    41         if($this->isMethod("patch")) {
     50        if ($this->isMethod("patch")) {
    4251            $fileRules = [
    4352                "file_item.*" => "mimes:jpg,jpeg,png|max:4096"
    44                 ];
     53            ];
    4554        } else {
    4655            $fileRules = [
Note: See TracChangeset for help on using the changeset viewer.