Changeset 0a1fb54 for app


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
Files:
2 added
18 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        }
  • app/Models/Department.php

    r4d73966 r0a1fb54  
    99class Department extends Model
    1010{
    11     use Notifiable;
    1211    use HasFactory;
    1312
     
    2019    ];
    2120
    22     public function getCreatedByName()
    23     {
    24         return User::where('id', $this->user_id)->pluck('username')->first();
    25     }
    26 
    2721    public function folder(){
    2822        return $this->hasMany(Folder::class);
    2923    }
    3024
    31 //    public function getDeptId(){
    32 //        return Department::where('id', $this->id)->get();
    33 //    }
     25    public function user(){
     26        return $this->belongsTo(User::class);
     27    }
     28
    3429}
  • app/Models/File.php

    r4d73966 r0a1fb54  
    1212
    1313    protected $table = "files";
    14     protected $fillable = ["name", "location", "document_id"];
     14    protected $fillable = ["name", "location", "folder_id"];
    1515
    1616    public function folder()
     
    2121    public function getSize($location)
    2222    {
    23         $fileSize = Storage::disk('uploads')->size($location) / 1024 / 1024;
     23        $fileSize = Storage::disk('local')->size($location) / 1024 / 1024;
    2424        $fileSize = round($fileSize, 2);
    2525        return $fileSize;
  • app/Models/User.php

    r4d73966 r0a1fb54  
    134134    }
    135135
     136    public function getCreatedByUsername()
     137    {
     138        return User::where('id', $this->created_by)->pluck('username')->first();
     139    }
     140
    136141    public function getCreatedByName()
    137142    {
    138         return User::where('id', $this->created_by)->pluck('username')->first();
     143        $name = User::where('id', $this->created_by)->pluck('name')->first();
     144        $surname = User::where('id', $this->created_by)->pluck('surname')->first();
     145
     146        return $name . " " . $surname;
    139147    }
    140148
     
    142150        return $this->hasMany(Folder::class);
    143151    }
     152
     153    public function department() {
     154        return $this->hasMany(Department::class);
     155    }
    144156}
  • app/Notifications/VerifyUser.php

    r4d73966 r0a1fb54  
    7070        ];
    7171    }
    72 
    73 
    7472}
  • app/Notifications/WelcomeUser.php

    r4d73966 r0a1fb54  
    4949            ->line("Security Code: " . $this->user->security_code)
    5050            ->line("To create password for your account just click the button then create something good. :))")
    51             ->line("NOTE: You have only 10 minutes to create your password.")
     51            ->line("NOTE: You have only 3 hours to create your password.")
    5252            ->action("Create Password", url("/auth/create-password/" . $this->user->id . "/" . $this->user->verify_token));
    5353    }
Note: See TracChangeset for help on using the changeset viewer.