Skip to content

Commit

Permalink
Middleware can manage for seeing users etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 24, 2024
1 parent a491506 commit a4ad8de
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 42 deletions.
95 changes: 57 additions & 38 deletions resources/views/livewire/user-edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,64 @@
<div class="max-w-7xl mx-auto py-10 sm:px-6 lg:px-8">
@if (session()->has('message'))
<div class="bg-green-100 mb-4 border border-green-400 text-green-700 px-4 py-3 rounded relative" role="alert">
<span class="block sm:inline">{{ session('message') }}</span>
</div>
@endif
<div class="p-2 md:p-0 md:py-4">
<x-slot name="header">
<h2 class="text-gray-800 flex items-center gap-4 leading-tight">
<i class="fas text-green-500 fa-shopping-bag"></i>
{{ __('Edit User') }}
</h2>
</x-slot>

<form wire:submit.prevent="save" enctype="multipart/form-data">
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
<div>
<label for="name" class="block text-sm font-medium text-gray-700">Name</label>
<input type="text" wire:model="name" id="name" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
@error('name') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>
<div class="max-w-7xl relative h-full mx-auto">
<div class="flex gap-4 sm:mx-3 lg:mx-4 flex-col h-full md:flex-row">
<div class="bg-white p-6 relative md:w-2/3 rounded-lg shadow-sm">
@if (session()->has('message'))
<div class="bg-green-100 mb-4 border border-green-400 text-green-700 px-4 py-3 rounded relative"
role="alert">
<span class="block sm:inline">{{ session('message') }}</span>
</div>
@endif

<div>
<label for="phone" class="block text-sm font-medium text-gray-700">Phone</label>
<input type="text" wire:model="phone" id="phone" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
@error('phone') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>
<form wire:submit.prevent="save" enctype="multipart/form-data">
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
<div>
<label for="name" class="block text-sm font-medium text-gray-700">Name</label>
<input type="text" wire:model="name" id="name"
class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
@error('name') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>

<div>
<label for="location" class="block text-sm font-medium text-gray-700">Location</label>
<input type="text" wire:model="location" id="location" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
@error('location') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label for="phone" class="block text-sm font-medium text-gray-700">Phone</label>
<input type="text" wire:model="phone" id="phone"
class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
@error('phone') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>

<div>
<label for="role" class="block text-sm font-medium text-gray-700">Role</label>
<select wire:model="role" id="role" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
<option value="writer">Writer</option>
<option value="client">Client</option>
<option value="admin">Admin</option>
</select>
@error('role') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>
</div>
<div>
<label for="location" class="block text-sm font-medium text-gray-700">Location</label>
<input type="text" wire:model="location" id="location"
class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
@error('location') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>

<div class="mt-6">
<button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-500 focus:outline-none focus:border-blue-700 focus:ring focus:ring-blue-200 active:bg-blue-600 disabled:opacity-25 transition">
Save
</button>
<div>
<label for="role" class="block text-sm font-medium text-gray-700">Role</label>
<select wire:model="role" id="role"
class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
<option value="writer">Writer</option>
<option value="client">Client</option>
<option value="admin">Admin</option>
</select>
@error('role') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>
</div>

<div class="mt-6">
<button type="submit"
class="inline-flex items-center px-4 py-2 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-500 focus:outline-none focus:border-blue-700 focus:ring focus:ring-blue-200 active:bg-blue-600 disabled:opacity-25 transition">
Save
</button>
</div>
</form>
</div>
</div>
</form>
</div>
</div>
8 changes: 4 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
Route::view('/referrals', 'static.coming-soon')->name('referrals');

Route::get('/payments', VerifyPayments::class)->name('payments.index');
Route::get('/users', ManageUsers::class)->name('users.index');
Route::get('/users/{user}', [ManageUsers::class, 'show'])->name('users.show');
Route::get('/users/edit/{id}', UserEdit::class)->name('users.edit');
Route::get('/users', ManageUsers::class)->name('users.index')->middleware('can:manage');
Route::get('/users/{user}', [ManageUsers::class, 'show'])->name('users.show')->middleware('can:manage');
Route::get('/users/edit/{id}', UserEdit::class)->name('users.edit')->middleware('can:manage');

Route::get('/payments/{paymentId}', VerifyOrderPayment::class)->name('payments.show');
Route::get('/payments/{paymentId}', VerifyOrderPayment::class)->name('payments.show')->middleware('can:manage');
});

Route::get('/contact', [PagesController::class, 'contact'])->name('contact');
Expand Down

0 comments on commit a4ad8de

Please sign in to comment.