Browse Source

Fixed sintax to pass StyleCI

pull/3/head
Nafies Luthfi 9 years ago
parent
commit
87bbaf78ba
  1. 8
      app/Cart/TransactionDraft.php
  2. 9
      app/Helpers/helpers.php
  3. 8
      app/Http/Controllers/CartController.php
  4. 4
      database/migrations/2017_04_27_121204_create_transactions_table.php
  5. 1
      resources/lang/id/app.php

8
app/Cart/TransactionDraft.php

@ -105,7 +105,7 @@ abstract class TransactionDraft
public function store()
{
$transaction = new Transaction;
$transaction = new Transaction();
$transaction->invoice_no = $this->getNewInvoiceNo();
$transaction->items = $this->getItemsArray();
$transaction->customer = $this->customer;
@ -123,16 +123,16 @@ abstract class TransactionDraft
{
$prefix = date('ym');
$lastTransaction = Transaction::orderBy('invoice_no','desc')->first();
$lastTransaction = Transaction::orderBy('invoice_no', 'desc')->first();
if (! is_null($lastTransaction)) {
if (!is_null($lastTransaction)) {
$lastInvoiceNo = $lastTransaction->invoice_no;
if (substr($lastInvoiceNo, 0, 4) == $prefix) {
return ++$lastInvoiceNo;
}
}
return $prefix . '0001';
return $prefix.'0001';
}
protected function getItemsArray()

9
app/Helpers/helpers.php

@ -15,7 +15,8 @@ function formatRp($number)
}
/**
* Overide Laravel Collective link_to_route helper function
* Overide Laravel Collective link_to_route helper function.
*
* @param string $name Name of route
* @param string $title Text that displayed on view
* @param array $parameters URL Parameter
@ -23,8 +24,10 @@ function formatRp($number)
*/
function html_link_to_route($name, $title = null, $parameters = [], $attributes = [])
{
if (array_key_exists('icon', $attributes))
$title = '<i class="fa fa-' . $attributes['icon'] . '"></i> ' . $title;
if (array_key_exists('icon', $attributes)) {
$title = '<i class="fa fa-'.$attributes['icon'].'"></i> '.$title;
}
return app('html')->decode(link_to_route($name, $title, $parameters, $attributes));
}

8
app/Http/Controllers/CartController.php

@ -89,8 +89,9 @@ class CartController extends Controller
{
$this->cart->removeDraft($request->draft_key);
if ($this->cart->isEmpty())
if ($this->cart->isEmpty()) {
return redirect()->route('cart.index');
}
$lastDraft = $this->cart->content()->last();
return redirect()->route('cart.show', $lastDraft->draftKey);
@ -112,7 +113,7 @@ class CartController extends Controller
'payment' => 'required|numeric',
'notes' => 'nullable|string|max:100',
]);
$draft = $this->cart->updateDraftAttributes($draftKey, $request->only('customer','notes','payment'));
$draft = $this->cart->updateDraftAttributes($draftKey, $request->only('customer', 'notes', 'payment'));
if ($draft->getItemsCount() == 0) {
flash(trans('transaction.item_list_empty'), 'warning')->important();
@ -126,8 +127,9 @@ class CartController extends Controller
public function store(Request $request, $draftKey)
{
$draft = $this->cart->get($draftKey);
if (is_null($draft))
if (is_null($draft)) {
return redirect()->route('cart.index');
}
$transaction = $draft->store();
$draft->destroy();

4
database/migrations/2017_04_27_121204_create_transactions_table.php

@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTransactionsTable extends Migration
{

1
resources/lang/id/app.php

@ -34,4 +34,5 @@ return [
'count' => 'Jumlah',
'welcome' => 'Selamat datang',
'export-pdf' => 'Export PDF',
];
Loading…
Cancel
Save