1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace jeremykenedy\LaravelRoles\App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use jeremykenedy\LaravelRoles\Traits\RolesAndPermissionsHelpersTrait; |
8
|
|
|
use jeremykenedy\LaravelRoles\Traits\RolesUsageAuthTrait; |
9
|
|
|
|
10
|
|
|
class LaravelpermissionsDeletedController extends Controller |
11
|
|
|
{ |
12
|
|
|
use RolesUsageAuthTrait; |
13
|
|
|
use RolesAndPermissionsHelpersTrait; |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Show the deleted permission items. |
17
|
|
|
* |
18
|
|
|
* @return \Illuminate\Http\Response |
19
|
|
|
*/ |
20
|
|
|
public function index() |
21
|
|
|
{ |
22
|
|
|
$deletedPermissions = $this->getDeletedPermissions()->get(); |
23
|
|
|
$data = [ |
24
|
|
|
'deletedPermissions' => $deletedPermissions, |
25
|
|
|
]; |
26
|
|
|
|
27
|
|
|
return view('laravelroles::laravelroles.crud.permissions.deleted.index', $data); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Display the specified resource. |
32
|
|
|
* |
33
|
|
|
* @param int $id |
34
|
|
|
* |
35
|
|
|
* @return \Illuminate\Http\Response |
36
|
|
|
*/ |
37
|
|
|
public function show($id) |
38
|
|
|
{ |
39
|
|
|
$item = $this->getDeletedPermissionAndDetails($id); |
40
|
|
|
$typeDeleted = 'deleted'; |
41
|
|
|
|
42
|
|
|
return view('laravelroles::laravelroles.crud.permissions.show', compact('item', 'typeDeleted')); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Dashbaord Method to restore all deleted permissions. |
47
|
|
|
* |
48
|
|
|
* @param \Illuminate\Http\Request $request The request |
49
|
|
|
* |
50
|
|
|
* @return \Illuminate\Http\Response |
51
|
|
|
*/ |
52
|
|
|
public function restoreAllDeletedPermissions(Request $request) |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
$deletedPermissions = $this->restoreAllTheDeletedPermissions(); |
55
|
|
|
|
56
|
|
|
if ($deletedPermissions['status'] === 'success') { |
57
|
|
|
return redirect()->route('laravelroles::roles.index') |
|
|
|
|
58
|
|
|
->with('success', trans_choice('laravelroles::laravelroles.flash-messages.successRestoredAllPermissions', $deletedPermissions['count'], ['count' => $deletedPermissions['count']])); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return redirect()->route('laravelroles::roles.index') |
|
|
|
|
62
|
|
|
->with('error', trans('laravelroles::laravelroles.flash-messages.errorRestoringAllPermissions')); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Restore the specified resource in storage. |
67
|
|
|
* |
68
|
|
|
* @param \Illuminate\Http\Request $request |
69
|
|
|
* @param int $id |
70
|
|
|
* |
71
|
|
|
* @return \Illuminate\Http\Response |
72
|
|
|
*/ |
73
|
|
|
public function restorePermission(Request $request, $id) |
|
|
|
|
74
|
|
|
{ |
75
|
|
|
$permission = $this->restoreDeletedPermission($id); |
76
|
|
|
|
77
|
|
|
return redirect()->route('laravelroles::roles.index') |
|
|
|
|
78
|
|
|
->with('success', trans('laravelroles::laravelroles.flash-messages.successRestoredPermission', ['permission' => $permission->name])); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Destroy all the specified resource from storage. |
83
|
|
|
* |
84
|
|
|
* @param \Illuminate\Http\Request $request The request |
85
|
|
|
* |
86
|
|
|
* @return \Illuminate\Http\Response |
87
|
|
|
*/ |
88
|
|
|
public function destroyAllDeletedPermissions(Request $request) |
|
|
|
|
89
|
|
|
{ |
90
|
|
|
$deletedPermissions = $this->destroyAllTheDeletedPermissions(); |
91
|
|
|
|
92
|
|
|
if ($deletedPermissions['status'] === 'success') { |
93
|
|
|
return redirect()->route('laravelroles::roles.index') |
|
|
|
|
94
|
|
|
->with('success', trans_choice('laravelroles::laravelroles.flash-messages.successDestroyedAllPermissions', $deletedPermissions['count'], ['count' => $deletedPermissions['count']])); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return redirect()->route('laravelroles::roles.index') |
|
|
|
|
98
|
|
|
->with('error', trans('laravelroles::laravelroles.flash-messages.errorDestroyingAllPermissions')); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Remove the specified resource from storage. |
103
|
|
|
* |
104
|
|
|
* @param int $id |
105
|
|
|
* |
106
|
|
|
* @return \Illuminate\Http\Response |
107
|
|
|
*/ |
108
|
|
|
public function destroy($id) |
109
|
|
|
{ |
110
|
|
|
$permission = $this->destroyPermission($id); |
111
|
|
|
|
112
|
|
|
return redirect()->route('laravelroles::roles.index') |
|
|
|
|
113
|
|
|
->with('success', trans('laravelroles::laravelroles.flash-messages.successDestroyedPermission', ['permission' => $permission->name])); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|