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

Location:
app/Http/Controllers/Dashboard
Files:
1 deleted
4 edited

Legend:

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

    r120759b rd795fa6  
    77use App\Http\Requests\Dashboard\UpdateDepartmentRequest;
    88use App\Models\Department;
     9use App\Models\Document;
    910use App\Models\User;
     11use Carbon\Carbon;
    1012use Illuminate\Http\Request;
    1113use App\Http\Controllers\Controller;
     
    2527    {
    2628        return view("dashboard.departments.create");
    27     }
    28 
    29     public function editShow($id)
    30     {
    31         return view("dashboard.departments.edit")->with([
    32             "department" => Department::findOrFail($id)
    33         ]);
    3429    }
    3530
     
    5550    }
    5651
     52    public function editShow($id)
     53    {
     54        return view("dashboard.departments.edit")->with([
     55            "department" => Department::findOrFail($id)
     56        ]);
     57    }
     58
    5759    public function edit(UpdateDepartmentRequest $request, $id)
    5860    {
     
    6365        $department->name = $request->name;
    6466        $department->code = $request->code;
     67        $department->updated_at = Carbon::now();;
    6568
    6669        $path = '/Departments/' . $request->code;
     
    8386    }
    8487
    85     public function destroy(Request $request, $id)
     88    public function destroy($id)
    8689    {
    8790        $department = Department::find($id);
     91        //$department->delete();
     92        $documents = $department->document()->count();
    8893
    89         $department->delete();
     94        if($documents > 0){
     95            Alert::flash($department->name . " has " . $documents . " document/s associated", "error");
     96        }
     97        else {
     98            $department->delete();
    9099
    91         Alert::flash($department->name . " deleted successfully");
     100            Alert::flash($department->name . " deleted successfully");
     101        }
    92102
    93103        return redirect()->route("dashboard.departments.index");
  • 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}
  • app/Http/Controllers/Dashboard/SettingsController.php

    r120759b rd795fa6  
    33namespace App\Http\Controllers\Dashboard;
    44
    5 use App\Helpers\Alert;
    65use App\Http\Requests\Dashboard\EmailSettingsRequest;
    7 use App\Http\Requests\Dashboard\NewUserRequest;
    86use App\Http\Requests\Dashboard\PasswordSettingsRequest;
    9 use App\Http\Requests\Dashboard\PhotosSettingsRequest;
    10 use App\Http\Requests\Dashboard\SocialLinksSettingsRequest;
    11 use App\Http\Requests\Dashboard\UpdateUserData;
    12 use App\Http\Requests\Dashboard\UpdateUserRequest;
    137use App\Http\Requests\Dashboard\UsernameSettingsRequest;
    14 use App\Http\Requests\Dashboard\UserProfileSettingsRequest;
    15 use App\Models\Post;
    16 use App\Models\Role;
    178use App\Models\User;
    18 use App\Models\UserProfile;
    19 use Illuminate\Support\Str;
    20 use Illuminate\Http\Request;
    219use App\Http\Controllers\Controller;
    22 use Illuminate\Support\Facades\File;
    23 use Illuminate\Support\Facades\Hash;
    2410use App\Notifications\VerifyNewEmail;
    25 use Illuminate\Support\Facades\Storage;
    26 use Propaganistas\LaravelPhone\PhoneNumber;
    27 use Propaganistas\LaravelIntl\Facades\Country;
     11use Carbon\Carbon;
    2812
    2913class SettingsController extends Controller
     
    3317        return view("dashboard.settings.index")->with([
    3418            "user" => auth()->user(),
    35             "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get()
     19            "adminAndEditors" => User::where("role_id", 1)->orWhere("role_id", 2)->get(),
    3620        ]);
    3721    }
     
    3923    public function updateUsername(UsernameSettingsRequest $request)
    4024    {
    41         $user = auth()->user();
    42         $user->username = $request->username;
    43         $user->save();
    44 
    45         auth()->logout();
    46         session()->flush();
    47 
    48         return redirect()->route("auth.loginShow");
     25//        if($request->validated()){
     26//        $user = auth()->user();
     27//        $user->username = $request->username;
     28//        $user->save();
     29//
     30//        auth()->logout();
     31//        session()->flush();
     32//
     33//        return redirect()->route("auth.loginShow");
     34//        }
     35//        else {
     36            return back()->withInput(['tab'=>'security']);
     37       // }
    4938    }
    5039
  • app/Http/Controllers/Dashboard/UsersController.php

    r120759b rd795fa6  
    88use App\Http\Requests\Dashboard\UpdateUserRequest;
    99use App\Models\Avatar;
     10use Carbon\Carbon;
    1011use Illuminate\Support\Facades\File;
    1112use App\Models\Role;
     
    4142        $user->surname = $request->surname;
    4243        $user->email = $request->email;
    43         $user->mobile_number = $request->mobile_number;
     44        $user->phone_number = $request->phone_number;
    4445        $user->username = $request->username;
    4546        $user->password = $user->generateTemporaryPassword();
     
    8586        $user->username = $request->username;
    8687        $user->email = $request->email;
    87         $user->mobile_number = $request->mobile_number;
     88        $user->phone_number = $request->phone_number;
    8889        $user->role_id = $request->userRole;
     90        $user->updated_at = $request->Carbon::now();;
    8991
    9092        if ($request->hasFile("avatar")) {
     
    152154        $user->name = $request->name;
    153155        $user->surname = $request->surname;
    154         $user->mobile_number = $request->mobile_number;
     156        $user->phone_number = $request->phone_number;
    155157
    156158        if ($request->hasFile("avatar")) {
Note: See TracChangeset for help on using the changeset viewer.