- Timestamp:
- 10/17/21 18:39:50 (3 years ago)
- Branches:
- develop, master
- Children:
- bd9e8e3
- Parents:
- 120759b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/DepartmentsController.php
r120759b rd795fa6 7 7 use App\Http\Requests\Dashboard\UpdateDepartmentRequest; 8 8 use App\Models\Department; 9 use App\Models\Document; 9 10 use App\Models\User; 11 use Carbon\Carbon; 10 12 use Illuminate\Http\Request; 11 13 use App\Http\Controllers\Controller; … … 25 27 { 26 28 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 ]);34 29 } 35 30 … … 55 50 } 56 51 52 public function editShow($id) 53 { 54 return view("dashboard.departments.edit")->with([ 55 "department" => Department::findOrFail($id) 56 ]); 57 } 58 57 59 public function edit(UpdateDepartmentRequest $request, $id) 58 60 { … … 63 65 $department->name = $request->name; 64 66 $department->code = $request->code; 67 $department->updated_at = Carbon::now();; 65 68 66 69 $path = '/Departments/' . $request->code; … … 83 86 } 84 87 85 public function destroy( Request $request,$id)88 public function destroy($id) 86 89 { 87 90 $department = Department::find($id); 91 //$department->delete(); 92 $documents = $department->document()->count(); 88 93 89 $department->delete(); 94 if($documents > 0){ 95 Alert::flash($department->name . " has " . $documents . " document/s associated", "error"); 96 } 97 else { 98 $department->delete(); 90 99 91 Alert::flash($department->name . " deleted successfully"); 100 Alert::flash($department->name . " deleted successfully"); 101 } 92 102 93 103 return redirect()->route("dashboard.departments.index");
Note:
See TracChangeset
for help on using the changeset viewer.