profil update dan gate tanaman
This commit is contained in:
@@ -22,7 +22,9 @@ class TanamanController extends Controller
|
||||
*/
|
||||
public function index(Request $request): AnonymousResourceCollection
|
||||
{
|
||||
Gate::authorize('petani');
|
||||
if (!Gate::any(['petani', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$profile = Auth::user()->profile;
|
||||
|
||||
@@ -88,7 +90,9 @@ class TanamanController extends Controller
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
Gate::authorize('petani');
|
||||
if (!Gate::any(['petani', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
$profile = Auth::user()->profile;
|
||||
|
||||
$validated = $request->validate([
|
||||
@@ -121,7 +125,9 @@ class TanamanController extends Controller
|
||||
*/
|
||||
public function show(string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('petani');
|
||||
if (!Gate::any(['petani', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tanaman = Tanaman::findOrFail($id);
|
||||
if ($tanaman->profile_id !== Auth::user()->profile->id) {
|
||||
@@ -144,7 +150,9 @@ class TanamanController extends Controller
|
||||
*/
|
||||
public function update(Request $request, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('petani');
|
||||
if (!Gate::any(['petani', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
$tanaman = Tanaman::findOrFail($id);
|
||||
if ($tanaman->profile_id !== Auth::user()->profile->id) {
|
||||
return response()->json(['message' => 'Unauthorized'], 403);
|
||||
@@ -177,7 +185,9 @@ class TanamanController extends Controller
|
||||
*/
|
||||
public function destroy(string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('petani');
|
||||
if (!Gate::any(['petani', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
$tanaman = Tanaman::findOrFail($id);
|
||||
if ($tanaman->profile_id !== Auth::user()->profile->id) {
|
||||
return response()->json(['message' => 'Unauthorized'], 403);
|
||||
|
||||
Reference in New Issue
Block a user