add payments by invoice
This commit is contained in:
43
app/Datatables/Shop/InvoicePaymentsDataTable.php
Normal file
43
app/Datatables/Shop/InvoicePaymentsDataTable.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\InvoicePayment;
|
||||
use App\Repositories\Shop\InvoicePayments;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class InvoicesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'InvoicePayments';
|
||||
|
||||
public function query(InvoicePayment $model)
|
||||
{
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('payment_type', function (InvoicePayment $payment) {
|
||||
return InvoicePayments::getPaymentType($payment->payment_type);
|
||||
})
|
||||
->editColumn('date', function (InvoicePayment $payment) {
|
||||
return $payment->date;
|
||||
})
|
||||
->rawColumns(['action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('payment_type')->title('Type')->width(80),
|
||||
Column::make('status')->width(60),
|
||||
Column::make('amount')->title('Montant')->width(100),
|
||||
Column::make('reference')->title('Référence'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Admin\Shop;
|
||||
|
||||
use App\Datatables\Admin\Shop\InvoicesDataTable;
|
||||
use App\Datatables\Admin\Shop\InvoicePaymentsDataTable;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Shop\Invoices;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -28,15 +29,20 @@ class InvoiceController extends Controller
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data['invoice'] = Invoices::get($id)->toArray();
|
||||
$data['invoice'] = Invoices::getFull($id)->toArray();
|
||||
|
||||
return view('Admin.Shop.Invoices.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['invoice'] = Invoices::get($id, ['order.customer', 'order.address', 'order.detail'])->toArray();
|
||||
$data['statuses'] = Invoices::statuses();
|
||||
$data = Invoices::init();
|
||||
$data['invoice'] = Invoices::getFull($id)->toArray();
|
||||
$model = new invoicePaymentsDataTable();
|
||||
$data['invoice_payments'] = $model->html();
|
||||
|
||||
// dump($data);
|
||||
// exit;
|
||||
|
||||
return view('Admin.Shop.Invoices.edit', $data);
|
||||
}
|
||||
|
||||
50
app/Http/Controllers/Admin/Shop/InvoicePaymentController.php
Normal file
50
app/Http/Controllers/Admin/Shop/InvoicePaymentController.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Shop;
|
||||
|
||||
use App\Datatables\Admin\Shop\InvoicePaymentsDataTable;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Shop\InvoicePayments;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoicePaymentController extends Controller
|
||||
{
|
||||
public function index(InvoicePaymentsDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Admin.Shop.InvoicePayments.list');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Admin.Shop.InvoicePayments.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = InvoicePayments::store($request->all());
|
||||
|
||||
return redirect()->route('Admin.Shop.InvoicePayments.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data['invoice_payment'] = InvoicePayments::getFull($id)->toArray();
|
||||
|
||||
return view('Admin.Shop.InvoicePayments.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = InvoicePayments::init();
|
||||
$data['invoice_payment'] = InvoicePayments::getFull($id)->toArray();
|
||||
$model = new invoice_paymentPaymentsDataTable();
|
||||
$data['invoice_payment_payments'] = $model->html();
|
||||
|
||||
return view('Admin.Shop.InvoicePayments.edit', $data);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return InvoicePayments::delete($id);
|
||||
}
|
||||
}
|
||||
21
app/Http/Requests/Admin/Shop/StoreMerchandisePost.php
Normal file
21
app/Http/Requests/Admin/Shop/StoreMerchandisePost.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin\Shop;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreMerchandisePost extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'producer_id' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -37,10 +37,10 @@ class InvoicePayments
|
||||
|
||||
public static function getPaymentType($id)
|
||||
{
|
||||
return self::PaymentTypes()[$id] ?? false;
|
||||
return self::paymentTypes()[$id] ?? false;
|
||||
}
|
||||
|
||||
public static function PaymentTypes()
|
||||
public static function paymentTypes()
|
||||
{
|
||||
return [
|
||||
'',
|
||||
|
||||
@@ -13,7 +13,7 @@ class Invoices
|
||||
|
||||
public static function getInvoiceHtml($id)
|
||||
{
|
||||
$invoice = self::get($id, ['order.customer', 'order.delivery_address', 'order.detail']);
|
||||
$invoice = self::getFull($id);
|
||||
$order = $invoice->order;
|
||||
$customer = $order->customer;
|
||||
unset($invoice->order, $order->customer);
|
||||
@@ -26,6 +26,19 @@ class Invoices
|
||||
return view('Shop.Invoices.mail', $data)->render();
|
||||
}
|
||||
|
||||
public static function init()
|
||||
{
|
||||
return [
|
||||
'statuses' => Invoices::statuses(),
|
||||
'payment_types' => InvoicePayments::paymentTypes(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
return self::get($id, ['address', 'order.customer', 'order.delivery_address', 'order.detail']);
|
||||
}
|
||||
|
||||
public static function getByUUID($uuid)
|
||||
{
|
||||
return Invoice::byUUID($uuid)->first();
|
||||
|
||||
Reference in New Issue
Block a user