Ignore:
Timestamp:
10/17/21 18:39:50 (3 years ago)
Author:
Berat Kjufliju <kufliju@…>
Branches:
develop, master
Children:
bd9e8e3
Parents:
120759b
Message:

added validation to blades

File:
1 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Dashboard/DocumentsController.php

    r120759b rd795fa6  
    88use App\Models\Document;
    99use App\Models\File;
    10 use App\Models\Files;
    11 use App\Models\User;
    12 use App\Notifications\NewDocumentCreated;
    1310use App\Services\UploadService;
    1411use Illuminate\Http\Request;
    1512use Illuminate\Support\Facades\Storage;
    16 use Mews\Purifier\Facades\Purifier;
    1713use App\Http\Controllers\Controller;
    18 use Illuminate\Support\Facades\Notification;
    1914
    2015class DocumentsController extends Controller
    2116{
    22     public function index()
     17    public function index(Request $request)
    2318    {
    24         if (auth()->user()->hasPermission("manage_all_documents"))
     19        if($request->department) {
     20            $documents = Document::with('department')->where('department', function ($query) {
     21                $query->where('id', $request->department)->get();
     22            });
     23        }
     24        else{
    2525            $documents = Document::all();
    26         else
    27             $documents = Document::where("user_id", auth()->user()->id)->get();
     26        }
     27
     28        $departments = Department::all();
    2829
    2930        return view("dashboard.documents.index")->with([
    3031            "documents" => $documents,
    3132            "currentUser" => auth()->user(),
    32             "departments" => Department::all(),
     33            "departments" => $departments,
    3334            "docsCount" => Department::withCount('document')->get(),
    3435            'totalDocs' => Document::all()->count()
    3536        ]);
     37
    3638    }
    3739
     
    6668        $document->arch_id = $request->arch_id;
    6769        $document->description = $request->description;
     70        $document->updated_at = $request->Carbon::now();;
    6871
    6972        $document->save();
     
    108111    }
    109112
    110     public function getDocumentsInDepartment($id)
    111     {
    112         $documents = Department::findOrFail($id)->document()->get();
    113         $department = Department::findOrFail($id);
    114 
    115         return view('dashboard.documents.department')
    116             ->with([
    117                 'documents' => $documents,
    118                 'departments' => Department::all(),
    119                 'totalDocs' => Document::all()->count(),
    120                 'department' => $department
    121 
    122         ]);
    123     }
    124 
    125113}
Note: See TracChangeset for help on using the changeset viewer.