Changeset d795fa6 for app/Http


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
Files:
1 deleted
13 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")) {
  • app/Http/Requests/Dashboard/DocumentRequest.php

    r120759b rd795fa6  
    44
    55use App\Models\Document;
     6use App\Models\FileType;
    67use Illuminate\Foundation\Http\FormRequest;
    78
     
    3031    public function rules()
    3132    {
     33
    3234        $rules = [
    3335            "arch_id" => "required|min:10|max:255",
     
    4042            $fileRules = [
    4143                "file_item.*" => "mimes:jpg,jpeg,png|max:4096"
    42             ];
     44                ];
    4345        } else {
    4446            $fileRules = [
  • app/Http/Requests/Dashboard/EmailSettingsRequest.php

    r120759b rd795fa6  
    2525    {
    2626        return [
    27             "email" => "required|string|email|max:255|unique:users,email,$this->id,id",
     27            "email" => "required|string|email|max:50|unique:users,email,$this->id,id",
    2828        ];
    2929    }
  • app/Http/Requests/Dashboard/NewDepartmentRequest.php

    r120759b rd795fa6  
    2525    {
    2626        return [
    27         "name" => "required|min:2|max:25|unique:departments,name",
     27        "name" => "required|min:2|max:30|unique:departments,name",
    2828        "code" => "required|min:2|max:10|unique:departments,code"
    2929        ];
  • app/Http/Requests/Dashboard/NewUserRequest.php

    r120759b rd795fa6  
    2525    {
    2626        return [
    27             "name" => "required|alpha|min:2|max:255",
    28             "surname" => "required|alpha|min:2|max:255",
    29             "mobile_number" => "required|unique:users,mobile_number",
    30             "email" => "required|string|email|max:255|unique:users,email",
    31             "username" => "required|min:8|unique:users,username",
     27            "name" => "required|alpha|min:2|max:30",
     28            "surname" => "required|alpha|min:2|max:30",
     29            "phone_number" => "required|unique:users,phone_number",
     30            "email" => "required|string|email|max:50|unique:users,email",
     31            "username" => "required|min:5|max:30|unique:users,username",
    3232            "userRole" => "required|exists:roles,id",
    3333            "avatar" => "mimes:jpeg,png,gif|max:5000",
  • app/Http/Requests/Dashboard/PasswordSettingsRequest.php

    r120759b rd795fa6  
    3434                }
    3535            ],
    36             "password" => "required|string|confirmed|min:8",
     36            "password" => "required|string|confirmed|min:6",
    3737        ];
    3838    }
  • app/Http/Requests/Dashboard/UpdateDepartmentRequest.php

    r120759b rd795fa6  
    2525    {
    2626        return [
    27             "name" => "required|min:2|max:25|unique:departments,name,$this->id,id",
    28             "code" => "required|min:2|max:10|unique:departments,code,$this->id,id"
     27            "name" => "required|min:2|max:30|unique:departments,name,$this->id,id",
     28            "code" => "required|min:2|max:30|unique:departments,code,$this->id,id"
    2929        ];
    3030    }
  • app/Http/Requests/Dashboard/UpdateUserData.php

    r120759b rd795fa6  
    2525    {
    2626        return [
    27             "name" => "required|alpha|min:2|max:255",
    28             "surname" => "required|alpha|min:2|max:255",
    29             "mobile_number" => "required|unique:users,mobile_number,$this->id,id",
     27            "name" => "required|alpha|min:2|max:30",
     28            "surname" => "required|alpha|min:2|max:30",
     29            "phone_number" => "required|unique:users,phone_number,$this->id,id",
    3030            "avatar" => "mimes:jpeg,png,gif|max:5000",
    3131        ];
  • app/Http/Requests/Dashboard/UpdateUserRequest.php

    r120759b rd795fa6  
    2525    {
    2626        return [
    27             "name" => "required|alpha|min:2|max:255",
    28             "surname" => "required|alpha|min:2|max:255",
    29             "mobile_number" => "required|unique:users,mobile_number,$this->id,id",
    30             "email" => "required|string|email|max:255|unique:users,email,$this->id,id",
    31             "username" => "required|min:8|unique:users,username,$this->id,id",
     27            "name" => "required|alpha|min:2|max:30",
     28            "surname" => "required|alpha|min:2|max:30",
     29            "phone_number" => "required|unique:users,phone_number,$this->id,id",
     30            "email" => "required|string|email|max:50|unique:users,email,$this->id,id",
     31            "username" => "required|min:5|unique:users,username,$this->id,id",
    3232            "userRole" => "required|exists:roles,id",
    3333            "avatar" => "mimes:jpeg,png,gif|max:5000",
  • app/Http/Requests/Dashboard/UsernameSettingsRequest.php

    r120759b rd795fa6  
    2525    {
    2626        return [
    27             "username" => "required|alpha_dash|min:8|unique:users,username,$this->id,id"
     27            "username" => "required|alpha_dash|min:5|unique:users,username,$this->id,id"
    2828        ];
    2929    }
Note: See TracChangeset for help on using the changeset viewer.