-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create CRUD dashboard payment method
- Loading branch information
1 parent
516ca4f
commit 7aee2ac
Showing
11 changed files
with
212 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\Admin\PaymentMethodRequest; | ||
use App\Http\Requests\Admin\UserStoreRequest; | ||
use App\Models\PaymentMethod; | ||
use App\Models\User; | ||
use App\Services\PaginationService; | ||
use Illuminate\Http\Request; | ||
|
||
class PaymentMethodController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$paymentMethods = PaginationService::make(PaymentMethod::query()) | ||
->setSearchables([ | ||
'name', | ||
'account_holder_name', | ||
]) | ||
->build(); | ||
|
||
return view('admin::paymentMethod.index', [ | ||
'paymentMethods' => $paymentMethods, | ||
]); | ||
} | ||
|
||
public function create() | ||
{ | ||
return view('admin::paymentMethod.create'); | ||
} | ||
|
||
public function store(PaymentMethodRequest $request) | ||
{ | ||
$paymentMethod = PaymentMethod::create($request->validated()); | ||
|
||
return redirect() | ||
->route('admin::paymentMethod.index') | ||
->with('success', __('crud.created', ['name' => 'paymentMethod'])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Admin; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class PaymentMethodRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'name' => [ | ||
'required', | ||
'string', | ||
], | ||
'account_holder_name' => [ | ||
'required', | ||
], | ||
'account_number' => [ | ||
'required', | ||
'integer', | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
resources/views/admin/components/paymentMethod/form.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@props(['paymentMethod' => new \App\Models\PaymentMethod()]) | ||
|
||
<div> | ||
<label class="block text-sm mb-4"> | ||
<x-admin::label value="Nama" required /> | ||
<x-admin::input type="text" name="name" placeholder="Nama Bank" :error="$errors->has('name')" | ||
:value="old('name', $paymentMethod->name)" /> | ||
@error('name') | ||
<x-admin::input-helper error :value="$message" /> | ||
@enderror | ||
</label> | ||
<label class="block text-sm mb-4"> | ||
<x-admin::label value="Nama Pemegang" required /> | ||
<x-admin::input type="text" name="account_holder_name" placeholder="Nama Pemegang" :error="$errors->has('email')" | ||
:value="old('email', $paymentMethod->account_holder_name)" /> | ||
@error('email') | ||
<x-admin::input-helper error :value="$message" /> | ||
@enderror | ||
</label> | ||
<label class="block text-sm mb-4"> | ||
<x-admin::label value="Nomor Rekening" required /> | ||
<x-admin::input type="text" name="account_number" placeholder="Nomor Rekening" :error="$errors->has('phone')" | ||
:value="old('phone', $paymentMethod->account_number)" /> | ||
@error('phone') | ||
<x-admin::input-helper error :value="$message" /> | ||
@enderror | ||
</label> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<x-admin::app> | ||
<div class="flex items-center space-x-2"> | ||
<x-admin::back :href="route('admin::users.index')" /> | ||
<x-admin::page-title value="Buat Pengguna" /> | ||
</div> | ||
|
||
<x-admin::form-container> | ||
<form action="{{ route('admin::paymentMethod.store') }}" method="POST"> | ||
@csrf | ||
<x-admin::paymentMethod.form /> | ||
<x-admin::button variant="primary" type="submit" value="Simpan" /> | ||
</form> | ||
</x-admin::form-container> | ||
</x-admin::app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<x-admin::app> | ||
<div class="flex items-center space-x-2"> | ||
<x-admin::back :href="route('admin::users.index')" /> | ||
<x-admin::page-title value="Ubah Pengguna" /> | ||
</div> | ||
|
||
<x-admin::form-container> | ||
<form action="{{ route('admin::users.update', $user) }}" method="POST"> | ||
@csrf | ||
@method('PUT') | ||
<x-admin::users.form :user="$user" /> | ||
<x-admin::button variant="primary" type="submit" value="Simpan" /> | ||
</form> | ||
</x-admin::form-container> | ||
</x-admin::app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<x-admin::app> | ||
<x-admin::page-title value="Pengguna" /> | ||
|
||
<x-admin::success-alert /> | ||
|
||
<div class="flex justify-between items-center space-x-2 rounded-lg mb-4"> | ||
<div> | ||
<form action="{{ route('admin::paymentMethod.index') }}" method="GET"> | ||
<x-admin::search /> | ||
</form> | ||
</div> | ||
<div> | ||
<x-admin::link variant="primary" :href="route('admin::paymentMethod.create')" value="Buat" class="mt-1" /> | ||
</div> | ||
</div> | ||
|
||
<div class="w-full overflow-hidden rounded-lg shadow-md"> | ||
<x-admin::table> | ||
<thead> | ||
<x-admin::col-header> | ||
<x-admin::row-header> | ||
<x-admin::sortable value="ID" name="id" /> | ||
</x-admin::row-header> | ||
<x-admin::row-header> | ||
<x-admin::sortable value="Nama Bank" name="name" /> | ||
</x-admin::row-header> | ||
<x-admin::row-header> | ||
<x-admin::sortable value="Email" name="account_holder_name" /> | ||
</x-admin::row-header> | ||
<x-admin::row-header> | ||
<x-admin::sortable value="Nomor Rekening" name="account_number" /> | ||
</x-admin::row-header> | ||
<x-admin::row-header> | ||
<x-admin::sortable value="Waktu Dibuat" name="created_at" /> | ||
</x-admin::row-header> | ||
<x-admin::row-header>Aksi</x-admin::row-header> | ||
</x-admin::col-header> | ||
</thead> | ||
<x-admin::tbody> | ||
@forelse ($paymentMethods as $paymentMethod) | ||
<x-admin::col> | ||
<x-admin::row>{{ $paymentMethod->id }}</x-admin::row> | ||
<x-admin::row>{{ $paymentMethod->name }}</x-admin::row> | ||
<x-admin::row>{{ $paymentMethod->account_holder_name }}</x-admin::row> | ||
<x-admin::row>{{ $paymentMethod->account_number }}</x-admin::row> | ||
<x-admin::row>{{ $paymentMethod->created_at }}</x-admin::row> | ||
<x-admin::row> | ||
<div class="flex items-center text-sm"> | ||
<x-admin::row-show-action :href="route('admin::paymentMethod.show', $paymentMethod)" /> | ||
<x-admin::row-edit-action :href="route('admin::paymentMethod.edit', $paymentMethod)" /> | ||
<x-admin::row-delete-action :href="route('admin::paymentMethod.destroy', $paymentMethod)" /> | ||
</div> | ||
</x-admin::row> | ||
</x-admin::col> | ||
@empty | ||
<x-admin::col> | ||
<x-admin::row colspan="5"> | ||
<x-admin::empty /> | ||
</x-admin::row> | ||
</x-admin::col> | ||
@endforelse | ||
</x-admin::tbody> | ||
</x-admin::table> | ||
<x-admin::pagination :collection="$paymentMethods" /> | ||
</div> | ||
</x-admin::app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters