Changeset 0a1fb54 for app/Http


Ignore:
Timestamp:
11/23/21 22:01:52 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
master
Children:
dbc5976
Parents:
4d73966
Message:

bug fixes

Location:
app/Http
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Auth/CreatePasswordController.php

    r4d73966 r0a1fb54  
    3636        $user->save();
    3737
    38         return redirect()->route("auth.loginShow");
     38        return redirect()->route("auth.showLogin");
    3939    }
    4040}
  • app/Http/Controllers/Auth/VerifyLoginController.php

    r4d73966 r0a1fb54  
    66use App\Http\Controllers\Controller;
    77use App\Models\User;
     8use App\Notifications\VerifyUser;
    89use Illuminate\Http\Request;
    910use App\Services\Hashid;
     11use Illuminate\Support\Carbon;
    1012
    1113class VerifyLoginController extends Controller
  • app/Http/Controllers/Dashboard/DepartmentsController.php

    r4d73966 r0a1fb54  
    2727    }
    2828
    29     public function create()
    30     {
    31         return view("dashboard.departments.create");
    32     }
    33 
    3429    public function store(NewDepartmentRequest $request)
    3530    {
     
    4843        $department->user_id = auth()->id();
    4944
    50         $users = User::all();
    51 
    5245        $department->save();
    5346
     
    5548
    5649        return redirect()->route("dashboard.departments.index");
    57     }
    58 
    59     public function editShow($id)
    60     {
    61         return view("dashboard.departments.edit")->with([
    62             "department" => Department::findOrFail($id)
    63         ]);
    6450    }
    6551
     
    7965            $location = 'Departments' . DIRECTORY_SEPARATOR . $request->code;
    8066
    81             if(!Storage::disk('local')->has($location) && Folder::where('department_id', $department->id)->pluck('no_of_files')->first() > 0){
     67            if(!Storage::disk('local')->has($location) ){
    8268                Storage::disk('local')->move($oldLocation, $location);
    8369                $department->location = $location;
     
    8874                    $folder->arch_id = $department->code . '/' . $currArchId;
    8975                    $folder->save();
     76
    9077                foreach($folder->files as $file) {
     78                    //dd($file);
    9179                    $file->location = $location . DIRECTORY_SEPARATOR . $folder->name . DIRECTORY_SEPARATOR . $file->name;
    9280                    $file->save();
  • app/Http/Controllers/Dashboard/FilesController.php

    r4d73966 r0a1fb54  
    5757
    5858                if(File::where(['folder_id' => $folder->id, 'name' => $fileName])->count() > 0) {
     59
    5960                    Alert::flash("The uploaded file already exists", "error");
    60 
    6161                    return redirect()->back();
    6262                }
  • app/Http/Controllers/Dashboard/FoldersController.php

    r4d73966 r0a1fb54  
    3636
    3737            if ($request->query('sort') == 'newest') {
    38                 $folders = $foldersInDeptSort->orderBy('created_at', 'desc')->paginate(12);
     38                $folders = $foldersInDeptSort->orderBy('created_at', 'desc')->paginate(9);
    3939            }
    4040            else if ($request->query('sort') == 'name') {
    41                 $folders = $foldersInDeptSort->orderBy('name', 'asc')->paginate(12);
     41                $folders = $foldersInDeptSort->orderBy('name', 'asc')->paginate(9);
    4242            }
    4343            else if ($request->query('sort') == 'no_of_files') {
    44                 $folders = $foldersInDeptSort->orderBy('no_of_files', 'desc')->paginate(12);
     44                $folders = $foldersInDeptSort->orderBy('no_of_files', 'desc')->paginate(9);
    4545            }
    4646            else if($request->query('sort') == 'count'){
    4747                $total = $foldersInDeptSort->folder->files->count();
    48                 $folders = $foldersInDeptSort->orderBy($total, 'asc')->paginate(12);
     48                $folders = $foldersInDeptSort->orderBy($total, 'asc')->paginate(9);
    4949            }
    5050            else {
    51                 $folders = Folder::where('department_id', $request->query('id'))->paginate(12);
     51                $folders = Folder::where('department_id', $request->query('id'))->paginate(9);
    5252            }
    5353        } else {
    5454            if ($request->query('sort') == 'newest') {
    55                 $folders = Folder::orderBy('created_at', 'desc')->paginate(12);
     55                $folders = Folder::orderBy('created_at', 'desc')->paginate(9);
    5656            }
    5757            else if ($request->query('sort') == 'name') {
    58                 $folders = Folder::orderBy('name', 'asc')->paginate(12);
     58                $folders = Folder::orderBy('name', 'asc')->paginate(9);
    5959            }
    6060            else if ($request->query('sort') == 'no_of_files') {
    61                 $folders = Folder::orderBy('no_of_files', 'desc')->paginate(12);
     61                $folders = Folder::orderBy('no_of_files', 'desc')->paginate(9);
    6262            }
    6363            else if ($request->query('sort') == 'recent') {
    64                 $folders = Folder::orderBy('created_at', 'desc')->paginate(12);
     64                $folders = Folder::orderBy('created_at', 'desc')->paginate(9);
    6565            } else if ($request->query('search')) {
    6666
     
    7373                $folders = $result;
    7474            } else {
    75                 $folders = Folder::paginate(12);
     75                $folders = Folder::paginate(9);
    7676            }
    7777        }
  • app/Http/Controllers/Dashboard/IndexController.php

    r4d73966 r0a1fb54  
    3232        return view("dashboard.index")->with([
    3333            "counters" => $counters,
    34             "largestDepartments" => Department::orderBy('no_of_folders', 'desc')->limit(10)->get(),
     34            "largestDepartments" => Department::orderBy('no_of_folders', 'desc')->limit(5)->get(),
    3535            "folders" => Folder::all(),
    3636            "files" => File::all(),
  • app/Http/Controllers/Dashboard/SettingsController.php

    r4d73966 r0a1fb54  
    2121    public function settings()
    2222    {
    23         $fileType = FileType::find("1");
    24 
    2523        return view("dashboard.settings.index")->with([
    2624            "user" => auth()->user(),
    27             "adminAndReferents" => User::where("role_id", 1)->orWhere("role_id", 2)->get(),
    2825            "active_tab" => "account",
    29             "fileType" => $fileType
     26            "fileType" => FileType::find("1")
    3027        ]);
    3128    }
     
    3835            $user->save();
    3936
     37            Alert::flash("Username updated successfully");
     38
    4039            auth()->logout();
    4140            session()->flush();
    4241
    43             return redirect()->route("auth.loginShow");
     42            return redirect()->route("auth.showLogin");
    4443    }
    4544
     
    5150            $user->save();
    5251
     52            Alert::flash("Password updated successfully");
     53
    5354            auth()->logout();
    5455            session()->flush();
    5556
    56             return redirect()->route("auth.loginShow");
     57            return redirect()->route("auth.showLogin");
    5758    }
    5859
     
    7172        $user->notify(new VerifyNewEmail($user));
    7273
     74        Alert::flash("Email updated successfully");
     75
    7376        auth()->logout();
    7477        session()->flush();
    7578
    76         return redirect()->route("auth.loginShow");
     79        return redirect()->route("auth.showLogin");
    7780    }
    7881
  • app/Http/Controllers/Dashboard/UsersController.php

    r4d73966 r0a1fb54  
    2727        return view("dashboard.users.index")->with([
    2828            "users" => User::all(),
    29             "roles" => Role::all(),
    30             "adminAndReferents" => User::where("role_id", 1)->orWhere("role_id", 2)->get()
    31         ]);
    32     }
    33 
    34     public function create()
    35     {
    36         return view("dashboard.users.create")->with([
    37             "roles" => Role::all(),
     29            "roles" => Role::all()
    3830        ]);
    3931    }
     
    7769    }
    7870
    79     public function editShow($id)
    80     {
    81         return view("dashboard.users.edit")->with([
    82             "user" => User::findOrFail($id),
    83             "roles" => Role::all(),
    84         ]);
    85     }
    86 
    8771    public function edit(UpdateUserRequest $request, $id)
    8872    {
     
    11094
    11195        if($user->isDirty('email')) {
     96            $user->is_active = false;
     97            $user->security_code = $user->generateSecurityCode();
     98            $user->verify_token = $user->generateVerifyToken();
    11299            $user->notify(new VerifyNewEmail($user));
    113100        }
     101
    114102        $user->save();
    115103
  • app/Http/Middleware/Authenticate.php

    r4d73966 r0a1fb54  
    1616    {
    1717        if (! $request->expectsJson()) {
    18             return route('auth.loginShow');
     18            return route('auth.showLogin');
    1919        }
    2020    }
  • app/Http/Middleware/CheckCreatePassword.php

    r4d73966 r0a1fb54  
    2424
    2525        if($user->is_active) {
    26             return redirect()->route("auth.loginShow");
     26            return redirect()->route("auth.showLogin");
    2727        }
    2828
    2929        if(!$user->is_forgot_password) {
    30             if(Carbon::now()->greaterThan($user->created_at->addMinutes(10))) {
    31                 return redirect()->route("auth.loginShow");
     30            if(Carbon::now()->greaterThan($user->created_at->addMinutes(180))) {
     31                return redirect()->route("auth.showLogin");
    3232            }
    3333        }
  • app/Http/Middleware/CheckIsActive.php

    r4d73966 r0a1fb54  
    2424            auth()->logout();
    2525
    26             return redirect()->route("auth.loginShow");
     26            return redirect()->route("auth.showLogin");
    2727        }
    2828
  • app/Http/Middleware/CheckVerifyNewEmail.php

    r4d73966 r0a1fb54  
    2323
    2424        if($user->is_active) {
    25             return redirect()->route("auth.loginShow");
     25            return redirect()->route("auth.showLogin");
    2626        }
    2727
  • app/Http/Middleware/CheckVerifyToken.php

    r4d73966 r0a1fb54  
    66use App\Services\Hashid;
    77use Closure;
     8use Illuminate\Support\Carbon;
    89
    910class CheckVerifyToken
     
    2324        $user = User::findOrFail($hashId->decode($id));
    2425
    25         if ($user->verify_token !== $token || now()->greaterThan($user->updated_at->addMinutes(1))) {
     26        if ($user->verify_token !== $token || Carbon::now()->greaterThan($user->updated_at->addMinutes(1))) {
    2627            return redirect()->route("auth.login");
    2728        }
Note: See TracChangeset for help on using the changeset viewer.