Skip to content

Commit 46553dd

Browse files
committed
Create JenisNaskahPolicy
1 parent 045432f commit 46553dd

File tree

3 files changed

+154
-464
lines changed

3 files changed

+154
-464
lines changed

app/Policies/JenisNaskahPolicy.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace App\Policies;
4+
5+
use App\Models\JenisNaskah;
6+
use App\Models\User;
7+
use Illuminate\Auth\Access\Response;
8+
9+
class JenisNaskahPolicy
10+
{
11+
/**
12+
* Determine whether the user can view any models.
13+
*/
14+
public function viewAny(User $user): bool
15+
{
16+
return (session('role') === 'admin');
17+
}
18+
19+
/**
20+
* Determine whether the user can view the model.
21+
*/
22+
public function view(User $user, JenisNaskah $jenisNaskah): bool
23+
{
24+
return (session('role') === 'admin');
25+
}
26+
27+
/**
28+
* Determine whether the user can create models.
29+
*/
30+
public function create(User $user): bool
31+
{
32+
return (session('role') === 'admin');
33+
}
34+
35+
/**
36+
* Determine whether the user can update the model.
37+
*/
38+
public function update(User $user, JenisNaskah $jenisNaskah): bool
39+
{
40+
return (session('role') === 'admin');
41+
}
42+
43+
/**
44+
* Determine whether the user can delete the model.
45+
*/
46+
public function delete(User $user, JenisNaskah $jenisNaskah): bool
47+
{
48+
return (session('role') === 'admin');
49+
}
50+
51+
/**
52+
* Determine whether the user can restore the model.
53+
*/
54+
public function restore(User $user, JenisNaskah $jenisNaskah): bool
55+
{
56+
return (session('role') === 'admin');
57+
}
58+
59+
/**
60+
* Determine whether the user can permanently delete the model.
61+
*/
62+
public function forceDelete(User $user, JenisNaskah $jenisNaskah): bool
63+
{
64+
return (session('role') === 'admin');
65+
}
66+
67+
/**
68+
* Determine whether the user can replicate the model.
69+
*/
70+
public function replicate(User $user, JenisNaskah $jenisNaskah): bool
71+
{
72+
return (session('role') === 'admin');
73+
}
74+
}

modified/policy.stub

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
namespace {{ namespace }};
4+
5+
use Illuminate\Auth\Access\Response;
6+
use {{ namespacedModel }};
7+
use {{ namespacedUserModel }};
8+
9+
class {{ class }}
10+
{
11+
/**
12+
* Determine whether the user can view any models.
13+
*/
14+
public function viewAny({{ user }} $user): bool
15+
{
16+
return (session('role') === 'admin');
17+
}
18+
19+
/**
20+
* Determine whether the user can view the model.
21+
*/
22+
public function view({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
23+
{
24+
return (session('role') === 'admin') &&
25+
(session('year') == ${{ modelVariable }}->tahun);
26+
}
27+
28+
/**
29+
* Determine whether the user can create models.
30+
*/
31+
public function create({{ user }} $user): bool
32+
{
33+
return (session('role') === 'admin');
34+
}
35+
36+
/**
37+
* Determine whether the user can update the model.
38+
*/
39+
public function update({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
40+
{
41+
return (session('role') === 'admin') &&
42+
(session('year') == ${{ modelVariable }}->tahun);
43+
}
44+
45+
/**
46+
* Determine whether the user can delete the model.
47+
*/
48+
public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
49+
{
50+
return (session('role') === 'admin') &&
51+
(session('year') == ${{ modelVariable }}->tahun);
52+
}
53+
54+
/**
55+
* Determine whether the user can restore the model.
56+
*/
57+
public function restore({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
58+
{
59+
return (session('role') === 'admin') &&
60+
(session('year') == ${{ modelVariable }}->tahun);
61+
}
62+
63+
/**
64+
* Determine whether the user can permanently delete the model.
65+
*/
66+
public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
67+
{
68+
return (session('role') === 'admin') &&
69+
(session('year') == ${{ modelVariable }}->tahun);
70+
}
71+
72+
/**
73+
* Determine whether the user can replicate the model.
74+
*/
75+
public function replicate({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
76+
{
77+
return (session('role') === 'admin') &&
78+
(session('year') == ${{ modelVariable }}->tahun);
79+
}
80+
}

0 commit comments

Comments
 (0)