first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View 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>";
});
}
}

View File

@@ -0,0 +1,7 @@
<?php
return [
'admin.transactions' => [
'index' => 'transaction::permissions.index',
],
];

View File

@@ -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');
}
}

View 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());
}
}

View File

@@ -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;
}

View File

@@ -0,0 +1,5 @@
<?php
return [
'index' => 'Index Transaction',
];

View File

@@ -0,0 +1,10 @@
<?php
return [
'transactions' => 'Transactions',
'table' => [
'order_id' => 'Order ID',
'transaction_id' => 'Transaction ID',
'payment_method' => 'Payment Method',
],
];

View File

@@ -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

View 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',
]);

View 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')
);
});
});
});
}
}

View 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"
}

View File

@@ -0,0 +1,6 @@
{
"name": "Transaction",
"alias": "transaction",
"description": "The FleetCart Transaction Module.",
"priority": 100
}