diff --git a/app/Http/Controllers/PaymentsController.php b/app/Http/Controllers/PaymentsController.php
index 0f8a1ed..a17fcc5 100755
--- a/app/Http/Controllers/PaymentsController.php
+++ b/app/Http/Controllers/PaymentsController.php
@@ -2,12 +2,12 @@
namespace App\Http\Controllers;
+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\UpdateRequest;
use App\Http\Requests\Payments\DeleteRequest;
-use App\Http\Controllers\Controller;
-use App\Entities\Payments\PaymentsRepository;
-
+use App\Http\Requests\Payments\UpdateRequest;
use Illuminate\Http\Request;
class PaymentsController extends Controller {
@@ -21,8 +21,9 @@ class PaymentsController extends Controller {
public function index(Request $request)
{
- $payments = $this->repo->getPayments($request->only('customer_id'));
- return view('payments.index',compact('payments'));
+ $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()
diff --git a/resources/lang/id/payment.php b/resources/lang/id/payment.php
index 5445d35..f34f9f6 100644
--- a/resources/lang/id/payment.php
+++ b/resources/lang/id/payment.php
@@ -1,9 +1,15 @@
'Pembayaran',
'payments' => 'Daftar Pembayaran',
- 'name' => 'Nama Pembayaran',
+ 'found' => 'Pembayaran ditemukan',
+ 'not_found' => 'Pembayaran tidak ditemukan',
+ 'empty' => 'Belum ada Pembayaran',
+ 'back_to_index' => 'Kembali ke daftar Pembayaran',
+
+ // Actions
'create' => 'Input Pembayaran Baru',
'created' => 'Input Pembayaran baru telah berhasil.',
'show' => 'Detail Pembayaran',
@@ -13,11 +19,9 @@ return [
'delete' => 'Hapus Pembayaran',
'deleted' => 'Hapus data Pembayaran telah berhasil.',
'undeleted' => 'Data Pembayaran gagal dihapus.',
- 'search' => 'Cari Pembayaran',
- 'found' => 'Pembayaran ditemukan',
- 'not_found' => 'Pembayaran tidak ditemukan',
- 'empty' => 'Belum ada Pembayaran',
- 'back_to_index' => 'Kembali ke daftar Pembayaran',
+ 'search' => 'Cari Pembayaran Project',
+
+ // Attrubutes
'description' => 'Deskripsi',
'date' => 'Tanggal Pembayaran',
'in_out' => 'Jenis Transaksi',
diff --git a/resources/views/payments/index.blade.php b/resources/views/payments/index.blade.php
index 787e5ae..d56bd60 100755
--- a/resources/views/payments/index.blade.php
+++ b/resources/views/payments/index.blade.php
@@ -9,11 +9,12 @@
{!! str_replace('/?', '?', $payments->appends(Request::except('page'))->render()) !!}
- {!! Form::open(['method'=>'get','class'=>'form-inline']) !!}
- {!! Form::text('q', Request::get('q'), ['class'=>'form-control index-search-field','placeholder'=>trans('payment.search'),'style' => 'width:350px']) !!}
- {!! Form::submit(trans('payment.search'), ['class' => 'btn btn-info btn-sm']) !!}
- {!! link_to_route('payments.index','Reset',[],['class' => 'btn btn-default btn-sm']) !!}
- {!! Form::close() !!}
+ {{ Form::open(['method'=>'get','class'=>'form-inline']) }}
+ {{ Form::text('q', Request::get('q'), ['class'=>'form-control index-search-field','placeholder' => trans('payment.search')]) }}
+ {{ Form::select('customer_id', ['' => '-- '.trans('payment.customer').' --'] + $usersList, request('customer_id'), ['class' => 'form-control', 'id' => 'customer_id']) }}
+ {{ Form::submit(trans('app.search'), ['class' => 'btn btn-info btn-sm']) }}
+ {{ link_to_route('payments.index','Reset',[],['class' => 'btn btn-default btn-sm']) }}
+ {{ Form::close() }}
{!! str_replace('/?', '?', $payments->appends(Request::except('page'))->render()) !!}
@endsection
+
+@section('ext_css')
+ {!! Html::style(url('assets/css/plugins/select2.min.css')) !!}
+@endsection
+
+@section('ext_js')
+ {!! Html::script(url('assets/js/plugins/select2.min.js')) !!}
+@endsection
+
+@section('script')
+
+@endsection
\ No newline at end of file
diff --git a/tests/Feature/Payments/ManagePaymentsTest.php b/tests/Feature/Payments/ManagePaymentsTest.php
index d750694..693e05a 100644
--- a/tests/Feature/Payments/ManagePaymentsTest.php
+++ b/tests/Feature/Payments/ManagePaymentsTest.php
@@ -156,24 +156,4 @@ class ManagePaymentsTest extends TestCase
// $this->see(formatRp($payments[4]->amount));
// $this->see($payments[4]->customer->name);
// }
-
- /** @test */
- public function admin_can_search_payment_by_customer_name()
- {
- $user = factory(User::class)->create();
- $user->assignRole('admin');
- $this->actingAs($user);
-
- $payments = factory(Payment::class, 2)->create(['owner_id' => $user->id]);
- $this->assertEquals(2, $payments->count());
-
- $this->visit(route('payments.index'));
-
- $firstName = explode(' ', $payments[0]->project->name)[0];
-
- $this->type($firstName, 'q');
- $this->press(trans('payment.search'));
- $this->seePageIs(route('payments.index', ['q' => $firstName]));
- $this->see($payments[0]->project->name);
- }
}
diff --git a/tests/Feature/Payments/PaymentSearchTest.php b/tests/Feature/Payments/PaymentSearchTest.php
index 3184bba..60b9212 100644
--- a/tests/Feature/Payments/PaymentSearchTest.php
+++ b/tests/Feature/Payments/PaymentSearchTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Payments;
use App\Entities\Payments\Payment;
+use App\Entities\Projects\Project;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
@@ -11,14 +12,37 @@ use Tests\TestCase;
class PaymentSearchTest extends TestCase
{
/** @test */
+ public function user_can_find_payment_by_project_name()
+ {
+ $admin = $this->adminUserSigningIn();
+ $project = factory(Project::class)->create(['name' => 'Project']);
+ $payment = factory(Payment::class)->create(['owner_id' => $admin->id, 'project_id' => $project->id]);
+ $unShownPayment = factory(Payment::class)->create(['owner_id' => $admin->id]);
+
+ $this->visit(route('payments.index'));
+ $this->submitForm(trans('app.search'), [
+ 'q' => 'Project',
+ 'customer_id' => '',
+ ]);
+ $this->seePageIs(route('payments.index', ['customer_id' => '', 'q' => 'Project']));
+
+ $this->see($payment->project->name);
+ $this->dontSee($unShownPayment->project->name);
+ }
+
+ /** @test */
public function user_can_find_payment_by_customer_id()
{
$admin = $this->adminUserSigningIn();
$payment = factory(Payment::class)->create(['owner_id' => $admin->id]);
$unShownPayment = factory(Payment::class)->create(['owner_id' => $admin->id]);
- $this->visit(route('payments.index', ['customer_id' => $payment->customer_id]));
- $this->seePageIs(route('payments.index', ['customer_id' => $payment->customer_id]));
+ $this->visit(route('payments.index'));
+ $this->submitForm(trans('app.search'), [
+ 'q' => '',
+ 'customer_id' => $payment->customer_id,
+ ]);
+ $this->seePageIs(route('payments.index', ['customer_id' => $payment->customer_id, 'q' => '']));
$this->see($payment->project->name);
$this->dontSee($unShownPayment->project->name);