first upload all files
This commit is contained in:
30
Modules/Transaction/Admin/TransactionTable.php
Normal file
30
Modules/Transaction/Admin/TransactionTable.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Transaction\Admin;
|
||||
|
||||
use Modules\Admin\Ui\AdminTable;
|
||||
|
||||
class TransactionTable extends AdminTable
|
||||
{
|
||||
/**
|
||||
* Raw columns that will not be escaped.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rawColumns = ['order_id'];
|
||||
|
||||
/**
|
||||
* Make table response for the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function make()
|
||||
{
|
||||
return $this->newTable()
|
||||
->addColumn('order_id', function ($transaction) {
|
||||
$orderUrl = route('admin.orders.show', $transaction->order_id);
|
||||
|
||||
return "<a href='{$orderUrl}'>{$transaction->order_id}</a>";
|
||||
});
|
||||
}
|
||||
}
|
||||
7
Modules/Transaction/Config/permissions.php
Normal file
7
Modules/Transaction/Config/permissions.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'admin.transactions' => [
|
||||
'index' => 'transaction::permissions.index',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTransactionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('order_id')->unsigned()->unique();
|
||||
$table->string('transaction_id');
|
||||
$table->string('payment_method');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('transactions');
|
||||
}
|
||||
}
|
||||
52
Modules/Transaction/Entities/Transaction.php
Normal file
52
Modules/Transaction/Entities/Transaction.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Transaction\Entities;
|
||||
|
||||
use Modules\Order\Entities\Order;
|
||||
use Modules\Support\Eloquent\Model;
|
||||
use Modules\Payment\Facades\Gateway;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Modules\Transaction\Admin\TransactionTable;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
|
||||
public function getPaymentMethodAttribute($paymentMethod)
|
||||
{
|
||||
return Gateway::get($paymentMethod)->label ?? '';
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
return new TransactionTable($this->newQuery());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Transaction\Http\Controllers\Admin;
|
||||
|
||||
use Modules\Admin\Traits\HasCrudActions;
|
||||
use Modules\Transaction\Entities\Transaction;
|
||||
use Modules\Transaction\Http\Requests\SaveTransactionRequest;
|
||||
|
||||
class TransactionController
|
||||
{
|
||||
use HasCrudActions;
|
||||
|
||||
/**
|
||||
* Model for the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Transaction::class;
|
||||
|
||||
/**
|
||||
* Label of the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'transaction::transactions.transaction';
|
||||
|
||||
/**
|
||||
* View path of the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $viewPath = 'transaction::admin.transactions';
|
||||
|
||||
/**
|
||||
* Form requests for the resource.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $validation = SaveTransactionRequest::class;
|
||||
}
|
||||
5
Modules/Transaction/Resources/lang/en/permissions.php
Normal file
5
Modules/Transaction/Resources/lang/en/permissions.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'index' => 'Index Transaction',
|
||||
];
|
||||
10
Modules/Transaction/Resources/lang/en/transactions.php
Normal file
10
Modules/Transaction/Resources/lang/en/transactions.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'transactions' => 'Transactions',
|
||||
'table' => [
|
||||
'order_id' => 'Order ID',
|
||||
'transaction_id' => 'Transaction ID',
|
||||
'payment_method' => 'Payment Method',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,41 @@
|
||||
@extends('admin::layout')
|
||||
|
||||
@component('admin::components.page.header')
|
||||
@slot('title', trans('transaction::transactions.transactions'))
|
||||
|
||||
<li class="active">{{ trans('transaction::transactions.transactions') }}</li>
|
||||
@endcomponent
|
||||
|
||||
@section('content')
|
||||
<div class="box box-primary">
|
||||
<div class="box-body index-table" id="transactions-table"">
|
||||
@component('admin::components.table')
|
||||
@slot('thead')
|
||||
<tr>
|
||||
<th>{{ trans('transaction::transactions.table.order_id') }}</th>
|
||||
<th>{{ trans('transaction::transactions.table.transaction_id') }}</th>
|
||||
<th>{{ trans('transaction::transactions.table.payment_method') }}</th>
|
||||
<th data-sort>{{ trans('admin::admin.table.created') }}</th>
|
||||
</tr>
|
||||
@endslot
|
||||
@endcomponent
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
DataTable.setRoutes('#transactions-table .table', {
|
||||
index: '{{ "admin.transactions.index" }}',
|
||||
});
|
||||
|
||||
new DataTable('#transactions-table .table', {
|
||||
columns: [
|
||||
{ data: 'order_id' },
|
||||
{ data: 'transaction_id' },
|
||||
{ data: 'payment_method' },
|
||||
{ data: 'created', name: 'created_at' },
|
||||
],
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
9
Modules/Transaction/Routes/admin.php
Normal file
9
Modules/Transaction/Routes/admin.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('transactions', [
|
||||
'as' => 'admin.transactions.index',
|
||||
'uses' => 'TransactionController@index',
|
||||
'middleware' => 'can:admin.transactions.index',
|
||||
]);
|
||||
26
Modules/Transaction/Sidebar/SidebarExtender.php
Normal file
26
Modules/Transaction/Sidebar/SidebarExtender.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Transaction\Sidebar;
|
||||
|
||||
use Maatwebsite\Sidebar\Item;
|
||||
use Maatwebsite\Sidebar\Menu;
|
||||
use Maatwebsite\Sidebar\Group;
|
||||
use Modules\Admin\Sidebar\BaseSidebarExtender;
|
||||
|
||||
class SidebarExtender extends BaseSidebarExtender
|
||||
{
|
||||
public function extend(Menu $menu)
|
||||
{
|
||||
$menu->group(trans('admin::sidebar.content'), function (Group $group) {
|
||||
$group->item(trans('admin::sidebar.sales'), function (Item $item) {
|
||||
$item->item(trans('transaction::transactions.transactions'), function (Item $item) {
|
||||
$item->weight(10);
|
||||
$item->route('admin.transactions.index');
|
||||
$item->authorize(
|
||||
$this->auth->hasAccess('admin.transactions.index')
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
27
Modules/Transaction/composer.json
Normal file
27
Modules/Transaction/composer.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "fleetcart/transaction",
|
||||
"description": "The FleetCart Transaction Module.",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Envay Soft",
|
||||
"email": "envaysoft@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.0.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Transaction\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
6
Modules/Transaction/module.json
Normal file
6
Modules/Transaction/module.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "Transaction",
|
||||
"alias": "transaction",
|
||||
"description": "The FleetCart Transaction Module.",
|
||||
"priority": 100
|
||||
}
|
||||
Reference in New Issue
Block a user