From 39bf5dc7bf24002e57ed0758cccd621bec3c6c34 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Mon, 25 Sep 2017 07:18:09 +0800 Subject: [PATCH] Add payment print view and Add terbilang package --- app/Http/Controllers/PaymentsController.php | 123 ++++++++++----------- composer.json | 7 +- composer.lock | 48 +++++++- config/app.php | 2 + resources/lang/id/payment.php | 1 + resources/views/layouts/partials/sidebar.blade.php | 2 +- resources/views/payments/pdf.blade.php | 79 +++++++++++++ resources/views/payments/show.blade.php | 1 + routes/web/payments.php | 3 +- 9 files changed, 198 insertions(+), 68 deletions(-) create mode 100755 resources/views/payments/pdf.blade.php diff --git a/app/Http/Controllers/PaymentsController.php b/app/Http/Controllers/PaymentsController.php index a17fcc5..35a58fe 100755 --- a/app/Http/Controllers/PaymentsController.php +++ b/app/Http/Controllers/PaymentsController.php @@ -2,84 +2,83 @@ namespace App\Http\Controllers; +use App\Entities\Payments\Payment; use App\Entities\Payments\PaymentsRepository; use App\Entities\Users\User; -use App\Http\Controllers\Controller; use App\Http\Requests\Payments\CreateRequest; use App\Http\Requests\Payments\DeleteRequest; use App\Http\Requests\Payments\UpdateRequest; use Illuminate\Http\Request; -class PaymentsController extends Controller { +class PaymentsController extends Controller +{ + private $repo; - private $repo; + public function __construct(PaymentsRepository $repo) + { + $this->repo = $repo; + } - public function __construct(PaymentsRepository $repo) - { - $this->repo = $repo; - } + public function index(Request $request) + { + $payments = $this->repo->getPayments($request->only('q', 'customer_id')); + $usersList = User::pluck('name', 'id')->all(); + return view('payments.index', compact('payments', 'usersList')); + } - public function index(Request $request) - { - $payments = $this->repo->getPayments($request->only('q', 'customer_id')); - $usersList = User::pluck('name', 'id')->all(); - return view('payments.index',compact('payments', 'usersList')); - } + public function create() + { + $projects = $this->repo->getProjectsList(); + $customers = $this->repo->getCustomersAndVendorsList(); + return view('payments.create', compact('projects', 'customers')); + } - public function create() - { - $projects = $this->repo->getProjectsList(); - $customers = $this->repo->getCustomersAndVendorsList(); - return view('payments.create',compact('projects','customers')); - } + public function store(CreateRequest $request) + { + $payment = $this->repo->create($request->except('_token')); + flash()->success(trans('payment.created')); + return redirect()->route('projects.payments', $payment->project_id); + } - public function store(CreateRequest $req) - { - $payment = $this->repo->create($req->except('_token')); - flash()->success(trans('payment.created')); - return redirect()->route('projects.payments', $payment->project_id); - } + public function show(Payment $payment) + { + return view('payments.show', compact('payment')); + } - public function show($paymentId) - { - $payment = $this->repo->requireById($paymentId); - return view('payments.show', compact('payment')); - } + public function edit(Payment $payment) + { + $projects = $this->repo->getProjectsList(); + $customers = $this->repo->getCustomersAndVendorsList(); + return view('payments.edit', compact('payment', 'projects', 'customers')); + } - public function edit($paymentId) - { - $payment = $this->repo->requireById($paymentId); - $projects = $this->repo->getProjectsList(); - $customers = $this->repo->getCustomersAndVendorsList(); - return view('payments.edit',compact('payment','projects','customers')); - } + public function update(UpdateRequest $request, $paymentId) + { + $payment = $this->repo->update($request->except(['_method','_token']), $paymentId); + flash()->success(trans('payment.updated')); + return redirect()->route('payments.show', $paymentId); + } - public function update(UpdateRequest $req, $paymentId) - { - $payment = $this->repo->update($req->except(['_method','_token']), $paymentId); - flash()->success(trans('payment.updated')); - return redirect()->route('payments.show', $paymentId); - } + public function delete(Payment $payment) + { + return view('payments.delete', compact('payment')); + } - public function delete($paymentId) - { - $payment = $this->repo->requireById($paymentId); - return view('payments.delete', compact('payment')); - } + public function destroy(DeleteRequest $request, Payment $payment) + { + $projectId = $payment->project_id; + if ($payment->id == $request->get('payment_id')) { + $payment->delete(); + flash()->success(trans('payment.deleted')); + } else { + flash()->error(trans('payment.undeleted')); + } - public function destroy(DeleteRequest $req, $paymentId) - { - $payment = $this->repo->requireById($paymentId); - $projectId = $payment->project_id; - if ($paymentId == $req->get('payment_id')) - { - $payment->delete(); - flash()->success(trans('payment.deleted')); - } - else - flash()->error(trans('payment.undeleted')); - - return redirect()->route('projects.payments', $projectId); - } + return redirect()->route('projects.payments', $projectId); + } + public function pdf(Payment $payment) + { + return view('payments.pdf', compact('payment')); + } } diff --git a/composer.json b/composer.json index c1e0c87..1383e5a 100644 --- a/composer.json +++ b/composer.json @@ -6,14 +6,15 @@ "type": "project", "require": { "php": ">=7.0.0", + "backup-manager/laravel": "^1.0", "barryvdh/laravel-dompdf": "^0.8.0", "intervention/image": "^2.3", - "laravel/framework": "5.5.*", - "luthfi/formfield": "^0.2.0", "laracasts/flash": "~2", "laracasts/presenter": "^0.2.1", - "backup-manager/laravel": "^1.0", + "laravel/framework": "5.5.*", + "luthfi/formfield": "^0.2.0", "maatwebsite/excel": "~2.1.0", + "riskihajar/terbilang": "^1.2", "spatie/laravel-fractal": "^5.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index a099e03..42c1522 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "6c61f297d80073ba97f8138e4ebd7a31", + "content-hash": "eb58ad569b92d48f00e1a5774b96dbca", "packages": [ { "name": "backup-manager/backup-manager", @@ -1907,6 +1907,52 @@ "time": "2017-09-22T20:46:04+00:00" }, { + "name": "riskihajar/terbilang", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/riskihajar/terbilang.git", + "reference": "8294ee3a854bd71e16f5e9c1516e8b5eebc1f497" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/riskihajar/terbilang/zipball/8294ee3a854bd71e16f5e9c1516e8b5eebc1f497", + "reference": "8294ee3a854bd71e16f5e9c1516e8b5eebc1f497", + "shasum": "" + }, + "require": { + "illuminate/support": "~4.2||~5", + "php": ">=5.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Riskihajar\\Terbilang\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "riskihajar", + "email": "riskihajar@gmail.com", + "homepage": "http://riskihajar.com" + } + ], + "description": "Convert number & date to words in any language for Laravel 4 | 5", + "homepage": "https://github.com/riskihajar/terbilang", + "keywords": [ + "date to words", + "laravel", + "number to roman", + "number to words", + "terbilang" + ], + "time": "2017-09-08T07:28:55+00:00" + }, + { "name": "sabberworm/php-css-parser", "version": "8.1.0", "source": { diff --git a/config/app.php b/config/app.php index 09c17ae..d6d8e73 100644 --- a/config/app.php +++ b/config/app.php @@ -163,6 +163,7 @@ return [ Laracasts\Flash\FlashServiceProvider::class, Luthfi\FormField\FormFieldServiceProvider::class, Maatwebsite\Excel\ExcelServiceProvider::class, + Riskihajar\Terbilang\TerbilangServiceProvider::class, Spatie\Fractal\FractalServiceProvider::class, ], @@ -218,6 +219,7 @@ return [ 'FormField' => Luthfi\FormField\FormFieldFacade::class, 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, + 'Terbilang' => Riskihajar\Terbilang\Facades\Terbilang::class, ], diff --git a/resources/lang/id/payment.php b/resources/lang/id/payment.php index f34f9f6..da0557d 100644 --- a/resources/lang/id/payment.php +++ b/resources/lang/id/payment.php @@ -20,6 +20,7 @@ return [ 'deleted' => 'Hapus data Pembayaran telah berhasil.', 'undeleted' => 'Data Pembayaran gagal dihapus.', 'search' => 'Cari Pembayaran Project', + 'print' => 'Cetak Kuitansi', // Attrubutes 'description' => 'Deskripsi', diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 641faf4..e31a48c 100755 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -9,7 +9,7 @@