profil update dan gate tanaman
This commit is contained in:
parent
5845f491ce
commit
66ec20699c
@ -175,6 +175,7 @@ public function update(Request $request, string $id): JSONResponse
|
||||
'file_kk' => ['nullable', 'file', 'mimes:jpg,jpeg,png,pdf', 'max:2048'],
|
||||
'file_ktp' => ['nullable', 'file', 'mimes:jpg,jpeg,png,pdf', 'max:2048'],
|
||||
'desa_kelurahan_id' => ['nullable', 'exists:master_desa_kelurahan,id'],
|
||||
'email_verified_at' => ['nullable', 'date'],
|
||||
]);
|
||||
|
||||
if ($request->hasFile('file_kk')) {
|
||||
@ -195,6 +196,7 @@ public function update(Request $request, string $id): JSONResponse
|
||||
$user->update([
|
||||
'name' => $validated['nama'],
|
||||
'email' => $validated['email'],
|
||||
'email_verified_at' => $validated['email_verified_at'],
|
||||
'updated_by' => $user->id,
|
||||
]);
|
||||
});
|
||||
|
||||
@ -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 @@ public function create()
|
||||
*/
|
||||
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 @@ public function store(Request $request): JsonResponse
|
||||
*/
|
||||
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 @@ public function edit(string $id)
|
||||
*/
|
||||
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 @@ public function update(Request $request, string $id): JsonResponse
|
||||
*/
|
||||
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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user