42 changed files with 623 additions and 635 deletions
-
8app/Entities/BaseRepository.php
-
6app/Entities/Partners/Customer.php
-
3app/Entities/Payments/Payment.php
-
4app/Entities/Projects/Project.php
-
4app/Entities/Projects/ProjectsRepository.php
-
2app/Entities/Subscriptions/Subscription.php
-
140app/Http/Controllers/Partners/CustomersController.php
-
145app/Http/Controllers/Partners/PartnersController.php
-
4app/Http/Controllers/PaymentsController.php
-
64app/Policies/Partners/CustomerPolicy.php
-
64app/Policies/Partners/PartnerPolicy.php
-
8app/Providers/AuthServiceProvider.php
-
6database/factories/CustomerFactory.php
-
4database/factories/ModelFactory.php
-
4database/factories/PaymentFactory.php
-
4database/factories/ProjectFactory.php
-
6database/migrations/2017_10_26_134455_create_customers_table.php
-
34resources/lang/id/customer.php
-
40resources/lang/id/partner.php
-
16resources/views/customers/create.blade.php
-
22resources/views/customers/edit.blade.php
-
26resources/views/customers/forms.blade.php
-
50resources/views/customers/index.blade.php
-
30resources/views/customers/show.blade.php
-
2resources/views/layouts/partials/sidebar.blade.php
-
50resources/views/partners/index.blade.php
-
4routes/web.php
-
4tests/Feature/InvoiceEntryTest.php
-
10tests/Feature/ManageFeaturesTest.php
-
109tests/Feature/ManagePartnersTest.php
-
56tests/Feature/ManageProjectsTest.php
-
14tests/Feature/ManageSubscriptionsTest.php
-
109tests/Feature/Partners/ManageCustomersTest.php
-
12tests/Feature/Payments/ManagePaymentsTest.php
-
8tests/Feature/Payments/PaymentSearchTest.php
-
46tests/Unit/Models/CustomerTest.php
-
46tests/Unit/Models/PartnerTest.php
-
4tests/Unit/Models/PaymentTest.php
-
6tests/Unit/Models/ProjectTest.php
-
4tests/Unit/Models/SubscriptionTest.php
-
40tests/Unit/Policies/CustomerPolicyTest.php
-
40tests/Unit/Policies/PartnerPolicyTest.php
@ -0,0 +1,140 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Controllers\Partners; |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use App\Http\Controllers\Controller; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class CustomersController extends Controller |
||||
|
{ |
||||
|
/** |
||||
|
* Display a listing of the customer. |
||||
|
* |
||||
|
* @return \Illuminate\Http\Response |
||||
|
*/ |
||||
|
public function index() |
||||
|
{ |
||||
|
$editableCustomer = null; |
||||
|
|
||||
|
$customers = Customer::where(function ($query) { |
||||
|
$query->where('name', 'like', '%'.request('q').'%'); |
||||
|
}) |
||||
|
->withCount('projects') |
||||
|
->paginate(25); |
||||
|
|
||||
|
if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { |
||||
|
$editableCustomer = Customer::find(request('id')); |
||||
|
} |
||||
|
|
||||
|
return view('customers.index', compact('customers', 'editableCustomer')); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Show the create customer form. |
||||
|
* |
||||
|
* @return \Illuminate\Http\Response |
||||
|
*/ |
||||
|
public function create() |
||||
|
{ |
||||
|
return view('customers.create'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Store a newly created customer in storage. |
||||
|
* |
||||
|
* @param \Illuminate\Http\Request $request |
||||
|
* @return \Illuminate\Http\Response |
||||
|
*/ |
||||
|
public function store(Request $request) |
||||
|
{ |
||||
|
$newCustomerData = $this->validate($request, [ |
||||
|
'name' => 'required|max:60', |
||||
|
'email' => 'nullable|email|unique:customers,email', |
||||
|
'phone' => 'nullable|max:255', |
||||
|
'pic' => 'nullable|max:255', |
||||
|
'address' => 'nullable|max:255', |
||||
|
'notes' => 'nullable|max:255', |
||||
|
]); |
||||
|
|
||||
|
$newCustomerData['owner_id'] = auth()->user()->agency->id; |
||||
|
|
||||
|
Customer::create($newCustomerData); |
||||
|
|
||||
|
flash(trans('customer.created'), 'success'); |
||||
|
|
||||
|
return redirect()->route('customers.index'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Show the specified customer. |
||||
|
* |
||||
|
* @param \App\Entities\Partners\Customer $customer |
||||
|
* @return \Illuminate\Http\Response |
||||
|
*/ |
||||
|
public function show(Customer $customer) |
||||
|
{ |
||||
|
return view('customers.show', compact('customer')); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Show the edit customer form. |
||||
|
* |
||||
|
* @param \App\Entities\Partners\Customer $customer |
||||
|
* @return \Illuminate\Http\Response |
||||
|
*/ |
||||
|
public function edit(Customer $customer) |
||||
|
{ |
||||
|
return view('customers.edit', compact('customer')); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Update the specified customer in storage. |
||||
|
* |
||||
|
* @param \Illuminate\Http\Request $request |
||||
|
* @param \App\Entities\Partners\Customer $customer |
||||
|
* @return \Illuminate\Http\Response |
||||
|
*/ |
||||
|
public function update(Request $request, Customer $customer) |
||||
|
{ |
||||
|
$customerData = $this->validate($request, [ |
||||
|
'name' => 'required|max:60', |
||||
|
'email' => 'nullable|email|unique:customers,email,'.$customer->id, |
||||
|
'phone' => 'nullable|max:255', |
||||
|
'pic' => 'nullable|max:255', |
||||
|
'address' => 'nullable|max:255', |
||||
|
'notes' => 'nullable|max:255', |
||||
|
'is_active' => 'required|boolean', |
||||
|
]); |
||||
|
|
||||
|
$customer->update($customerData); |
||||
|
|
||||
|
flash(trans('customer.updated'), 'success'); |
||||
|
|
||||
|
return redirect()->route('customers.show', $customer->id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Remove the specified customer from storage. |
||||
|
* |
||||
|
* @param \App\Entities\Partners\Customer $customer |
||||
|
* @return \Illuminate\Http\Response |
||||
|
*/ |
||||
|
public function destroy(Customer $customer) |
||||
|
{ |
||||
|
// TODO: user cannot delete customer that has been used in other table
|
||||
|
$this->validate(request(), [ |
||||
|
'customer_id' => 'required', |
||||
|
]); |
||||
|
|
||||
|
$routeParam = request()->only('page', 'q'); |
||||
|
|
||||
|
if (request('customer_id') == $customer->id && $customer->delete()) { |
||||
|
flash(trans('customer.deleted'), 'warning'); |
||||
|
return redirect()->route('customers.index', $routeParam); |
||||
|
} |
||||
|
|
||||
|
flash(trans('customer.undeleted'), 'danger'); |
||||
|
return back(); |
||||
|
} |
||||
|
} |
||||
@ -1,145 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Http\Controllers\Partners; |
|
||||
|
|
||||
use App\Entities\Partners\Partner; |
|
||||
use App\Http\Controllers\Controller; |
|
||||
use Illuminate\Http\Request; |
|
||||
|
|
||||
class PartnersController extends Controller |
|
||||
{ |
|
||||
/** |
|
||||
* Display a listing of the partner. |
|
||||
* |
|
||||
* @return \Illuminate\Http\Response |
|
||||
*/ |
|
||||
public function index() |
|
||||
{ |
|
||||
$editablePartner = null; |
|
||||
|
|
||||
$partnerTypes = [ |
|
||||
1 => trans('partner.types.customer'), |
|
||||
2 => trans('partner.types.vendor'), |
|
||||
]; |
|
||||
|
|
||||
$partners = Partner::where(function ($query) { |
|
||||
$query->where('name', 'like', '%'.request('q').'%'); |
|
||||
}) |
|
||||
->withCount('projects') |
|
||||
->paginate(25); |
|
||||
|
|
||||
if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { |
|
||||
$editablePartner = Partner::find(request('id')); |
|
||||
} |
|
||||
|
|
||||
return view('partners.index', compact('partners', 'partnerTypes', 'editablePartner')); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Show the create partner form. |
|
||||
* |
|
||||
* @return \Illuminate\Http\Response |
|
||||
*/ |
|
||||
public function create() |
|
||||
{ |
|
||||
return view('partners.create'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Store a newly created partner in storage. |
|
||||
* |
|
||||
* @param \Illuminate\Http\Request $request |
|
||||
* @return \Illuminate\Http\Response |
|
||||
*/ |
|
||||
public function store(Request $request) |
|
||||
{ |
|
||||
$newPartnerData = $this->validate($request, [ |
|
||||
'name' => 'required|max:60', |
|
||||
'email' => 'nullable|email|unique:partners,email', |
|
||||
'phone' => 'nullable|max:255', |
|
||||
'pic' => 'nullable|max:255', |
|
||||
'address' => 'nullable|max:255', |
|
||||
'notes' => 'nullable|max:255', |
|
||||
]); |
|
||||
|
|
||||
$newPartnerData['owner_id'] = auth()->user()->agency->id; |
|
||||
|
|
||||
Partner::create($newPartnerData); |
|
||||
|
|
||||
flash(trans('partner.created'), 'success'); |
|
||||
|
|
||||
return redirect()->route('partners.index'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Show the specified partner. |
|
||||
* |
|
||||
* @param \App\Entities\Partners\Partner $partner |
|
||||
* @return \Illuminate\Http\Response |
|
||||
*/ |
|
||||
public function show(Partner $partner) |
|
||||
{ |
|
||||
return view('partners.show', compact('partner')); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Show the edit partner form. |
|
||||
* |
|
||||
* @param \App\Entities\Partners\Partner $partner |
|
||||
* @return \Illuminate\Http\Response |
|
||||
*/ |
|
||||
public function edit(Partner $partner) |
|
||||
{ |
|
||||
return view('partners.edit', compact('partner')); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Update the specified partner in storage. |
|
||||
* |
|
||||
* @param \Illuminate\Http\Request $request |
|
||||
* @param \App\Entities\Partners\Partner $partner |
|
||||
* @return \Illuminate\Http\Response |
|
||||
*/ |
|
||||
public function update(Request $request, Partner $partner) |
|
||||
{ |
|
||||
$partnerData = $this->validate($request, [ |
|
||||
'name' => 'required|max:60', |
|
||||
'email' => 'nullable|email|unique:partners,email,'.$partner->id, |
|
||||
'phone' => 'nullable|max:255', |
|
||||
'pic' => 'nullable|max:255', |
|
||||
'address' => 'nullable|max:255', |
|
||||
'notes' => 'nullable|max:255', |
|
||||
'is_active' => 'required|boolean', |
|
||||
]); |
|
||||
|
|
||||
$partner->update($partnerData); |
|
||||
|
|
||||
flash(trans('partner.updated'), 'success'); |
|
||||
|
|
||||
return redirect()->route('partners.show', $partner->id); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Remove the specified partner from storage. |
|
||||
* |
|
||||
* @param \App\Entities\Partners\Partner $partner |
|
||||
* @return \Illuminate\Http\Response |
|
||||
*/ |
|
||||
public function destroy(Partner $partner) |
|
||||
{ |
|
||||
// TODO: user cannot delete partner that has been used in other table
|
|
||||
$this->validate(request(), [ |
|
||||
'partner_id' => 'required', |
|
||||
]); |
|
||||
|
|
||||
$routeParam = request()->only('page', 'q'); |
|
||||
|
|
||||
if (request('partner_id') == $partner->id && $partner->delete()) { |
|
||||
flash(trans('partner.deleted'), 'warning'); |
|
||||
return redirect()->route('partners.index', $routeParam); |
|
||||
} |
|
||||
|
|
||||
flash(trans('partner.undeleted'), 'danger'); |
|
||||
return back(); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,64 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Policies\Partners; |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use App\Entities\Users\User; |
||||
|
use Illuminate\Auth\Access\HandlesAuthorization; |
||||
|
|
||||
|
class CustomerPolicy |
||||
|
{ |
||||
|
use HandlesAuthorization; |
||||
|
|
||||
|
/** |
||||
|
* Determine whether the user can view the customer. |
||||
|
* |
||||
|
* @param \App\Entities\Users\User $user |
||||
|
* @param \App\Entities\Partners\Customer $customer |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function view(User $user, Customer $customer) |
||||
|
{ |
||||
|
// Update $user authorization to view $customer here.
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Determine whether the user can create customers. |
||||
|
* |
||||
|
* @param \App\Entities\Users\User $user |
||||
|
* @param \App\Entities\Partners\Customer $customer |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function create(User $user, Customer $customer) |
||||
|
{ |
||||
|
// Update $user authorization to create $customer here.
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Determine whether the user can update the customer. |
||||
|
* |
||||
|
* @param \App\Entities\Users\User $user |
||||
|
* @param \App\Entities\Partners\Customer $customer |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function update(User $user, Customer $customer) |
||||
|
{ |
||||
|
// Update $user authorization to update $customer here.
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Determine whether the user can delete the customer. |
||||
|
* |
||||
|
* @param \App\Entities\Users\User $user |
||||
|
* @param \App\Entities\Partners\Customer $customer |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function delete(User $user, Customer $customer) |
||||
|
{ |
||||
|
// Update $user authorization to delete $customer here.
|
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
@ -1,64 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Policies\Partners; |
|
||||
|
|
||||
use App\Entities\Partners\Partner; |
|
||||
use App\Entities\Users\User; |
|
||||
use Illuminate\Auth\Access\HandlesAuthorization; |
|
||||
|
|
||||
class PartnerPolicy |
|
||||
{ |
|
||||
use HandlesAuthorization; |
|
||||
|
|
||||
/** |
|
||||
* Determine whether the user can view the partner. |
|
||||
* |
|
||||
* @param \App\Entities\Users\User $user |
|
||||
* @param \App\Entities\Partners\Partner $partner |
|
||||
* @return mixed |
|
||||
*/ |
|
||||
public function view(User $user, Partner $partner) |
|
||||
{ |
|
||||
// Update $user authorization to view $partner here.
|
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Determine whether the user can create partners. |
|
||||
* |
|
||||
* @param \App\Entities\Users\User $user |
|
||||
* @param \App\Entities\Partners\Partner $partner |
|
||||
* @return mixed |
|
||||
*/ |
|
||||
public function create(User $user, Partner $partner) |
|
||||
{ |
|
||||
// Update $user authorization to create $partner here.
|
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Determine whether the user can update the partner. |
|
||||
* |
|
||||
* @param \App\Entities\Users\User $user |
|
||||
* @param \App\Entities\Partners\Partner $partner |
|
||||
* @return mixed |
|
||||
*/ |
|
||||
public function update(User $user, Partner $partner) |
|
||||
{ |
|
||||
// Update $user authorization to update $partner here.
|
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Determine whether the user can delete the partner. |
|
||||
* |
|
||||
* @param \App\Entities\Users\User $user |
|
||||
* @param \App\Entities\Partners\Partner $partner |
|
||||
* @return mixed |
|
||||
*/ |
|
||||
public function delete(User $user, Partner $partner) |
|
||||
{ |
|
||||
// Update $user authorization to delete $partner here.
|
|
||||
return true; |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,34 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
// Labels
|
||||
|
'customer' => 'Customer', |
||||
|
'list' => 'Daftar Customer', |
||||
|
'search' => 'Cari Customer', |
||||
|
'not_found' => 'Customer tidak ditemukan', |
||||
|
'empty' => 'Belum ada Customer', |
||||
|
'back_to_show' => 'Kembali ke detail Customer', |
||||
|
'back_to_index' => 'Kembali ke daftar Customer', |
||||
|
'type' => 'Jenis Customer', |
||||
|
'detail' => 'Detail Customer', |
||||
|
'contact' => 'Kontak Customer', |
||||
|
|
||||
|
// Actions
|
||||
|
'create' => 'Input Customer Baru', |
||||
|
'created' => 'Input Customer baru telah berhasil.', |
||||
|
'show' => 'Detail Customer', |
||||
|
'edit' => 'Edit Customer', |
||||
|
'update' => 'Update Customer', |
||||
|
'updated' => 'Update data Customer telah berhasil.', |
||||
|
'delete' => 'Hapus Customer', |
||||
|
'delete_confirm' => 'Anda yakin akan menghapus Customer ini?', |
||||
|
'deleted' => 'Hapus data Customer telah berhasil.', |
||||
|
'undeleted' => 'Data Customer gagal dihapus.', |
||||
|
'undeleteable' => 'Data Customer tidak dapat dihapus.', |
||||
|
|
||||
|
// Attributes
|
||||
|
'name' => 'Nama Customer', |
||||
|
'description' => 'Deskripsi Customer', |
||||
|
'pic' => 'PIC', |
||||
|
'projects_count' => 'Jml Project', |
||||
|
]; |
||||
@ -1,40 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
return [ |
|
||||
// Labels
|
|
||||
'partner' => 'Partner', |
|
||||
'list' => 'Daftar Partner', |
|
||||
'search' => 'Cari Partner', |
|
||||
'not_found' => 'Partner tidak ditemukan', |
|
||||
'empty' => 'Belum ada Partner', |
|
||||
'back_to_show' => 'Kembali ke detail Partner', |
|
||||
'back_to_index' => 'Kembali ke daftar Partner', |
|
||||
'type' => 'Jenis Partner', |
|
||||
'detail' => 'Detail Partner', |
|
||||
'contact' => 'Kontak Partner', |
|
||||
|
|
||||
// Actions
|
|
||||
'create' => 'Input Partner Baru', |
|
||||
'created' => 'Input Partner baru telah berhasil.', |
|
||||
'show' => 'Detail Partner', |
|
||||
'edit' => 'Edit Partner', |
|
||||
'update' => 'Update Partner', |
|
||||
'updated' => 'Update data Partner telah berhasil.', |
|
||||
'delete' => 'Hapus Partner', |
|
||||
'delete_confirm' => 'Anda yakin akan menghapus Partner ini?', |
|
||||
'deleted' => 'Hapus data Partner telah berhasil.', |
|
||||
'undeleted' => 'Data Partner gagal dihapus.', |
|
||||
'undeleteable' => 'Data Partner tidak dapat dihapus.', |
|
||||
|
|
||||
// Attributes
|
|
||||
'name' => 'Nama Partner', |
|
||||
'description' => 'Deskripsi Partner', |
|
||||
'pic' => 'PIC', |
|
||||
'projects_count' => 'Jml Project', |
|
||||
|
|
||||
// Types
|
|
||||
'types' => [ |
|
||||
'customer' => 'Customer', |
|
||||
'vendor' => 'Vendor', |
|
||||
], |
|
||||
]; |
|
||||
@ -1,37 +1,37 @@ |
|||||
@if (Request::get('action') == 'delete' && $partner) |
|
||||
|
@if (Request::get('action') == 'delete' && $customer) |
||||
<div class="row"> |
<div class="row"> |
||||
<div class="col-md-4 col-md-offset-4"> |
<div class="col-md-4 col-md-offset-4"> |
||||
<div class="panel panel-default"> |
<div class="panel panel-default"> |
||||
<div class="panel-heading"><h3 class="panel-title">{{ trans('partner.delete') }}</h3></div> |
|
||||
|
<div class="panel-heading"><h3 class="panel-title">{{ trans('customer.delete') }}</h3></div> |
||||
<div class="panel-body"> |
<div class="panel-body"> |
||||
<label class="control-label">{{ trans('partner.name') }}</label> |
|
||||
<p>{{ $partner->name }}</p> |
|
||||
|
<label class="control-label">{{ trans('customer.name') }}</label> |
||||
|
<p>{{ $customer->name }}</p> |
||||
<label class="control-label">{{ trans('contact.email') }}</label> |
<label class="control-label">{{ trans('contact.email') }}</label> |
||||
<p>{{ $partner->email }}</p> |
|
||||
|
<p>{{ $customer->email }}</p> |
||||
<label class="control-label">{{ trans('contact.phone') }}</label> |
<label class="control-label">{{ trans('contact.phone') }}</label> |
||||
<p>{{ $partner->phone }}</p> |
|
||||
|
<p>{{ $customer->phone }}</p> |
||||
<label class="control-label">{{ trans('address.address') }}</label> |
<label class="control-label">{{ trans('address.address') }}</label> |
||||
<p>{{ $partner->address }}</p> |
|
||||
|
<p>{{ $customer->address }}</p> |
||||
<label class="control-label">{{ trans('app.status') }}</label> |
<label class="control-label">{{ trans('app.status') }}</label> |
||||
<p>{{ $partner->is_active }}</p> |
|
||||
|
<p>{{ $customer->is_active }}</p> |
||||
<label class="control-label">{{ trans('app.notes') }}</label> |
<label class="control-label">{{ trans('app.notes') }}</label> |
||||
<p>{{ $partner->notes }}</p> |
|
||||
{!! $errors->first('partner_id', '<span class="form-error small">:message</span>') !!} |
|
||||
|
<p>{{ $customer->notes }}</p> |
||||
|
{!! $errors->first('customer_id', '<span class="form-error small">:message</span>') !!} |
||||
</div> |
</div> |
||||
<hr style="margin:0"> |
<hr style="margin:0"> |
||||
<div class="panel-body">{{ trans('app.delete_confirm') }}</div> |
<div class="panel-body">{{ trans('app.delete_confirm') }}</div> |
||||
<div class="panel-footer"> |
<div class="panel-footer"> |
||||
{!! FormField::delete( |
{!! FormField::delete( |
||||
['route'=>['partners.destroy',$partner->id]], |
|
||||
|
['route'=>['customers.destroy',$customer->id]], |
||||
trans('app.delete_confirm_button'), |
trans('app.delete_confirm_button'), |
||||
['class'=>'btn btn-danger'], |
['class'=>'btn btn-danger'], |
||||
[ |
[ |
||||
'partner_id' => $partner->id, |
|
||||
|
'customer_id' => $customer->id, |
||||
'page' => request('page'), |
'page' => request('page'), |
||||
'q' => request('q'), |
'q' => request('q'), |
||||
] |
] |
||||
) !!} |
) !!} |
||||
{{ link_to_route('partners.edit', trans('app.cancel'), [$partner->id], ['class' => 'btn btn-default']) }} |
|
||||
|
{{ link_to_route('customers.edit', trans('app.cancel'), [$customer->id], ['class' => 'btn btn-default']) }} |
||||
</div> |
</div> |
||||
</div> |
</div> |
||||
</div> |
</div> |
||||
@ -0,0 +1,50 @@ |
|||||
|
@extends('layouts.app') |
||||
|
|
||||
|
@section('title', trans('customer.list')) |
||||
|
|
||||
|
@section('content') |
||||
|
<h1 class="page-header"> |
||||
|
<div class="pull-right"> |
||||
|
{{ link_to_route('customers.create', trans('customer.create'), [], ['class' => 'btn btn-success']) }} |
||||
|
</div> |
||||
|
{{ trans('customer.list') }} |
||||
|
<small>{{ trans('app.total') }} : {{ $customers->total() }} {{ trans('customer.customer') }}</small> |
||||
|
</h1> |
||||
|
|
||||
|
<div class="panel panel-default table-responsive"> |
||||
|
<div class="panel-heading"> |
||||
|
{{ Form::open(['method' => 'get','class' => 'form-inline']) }} |
||||
|
{!! FormField::text('q', ['value' => request('q'), 'label' => trans('customer.search'), 'class' => 'input-sm']) !!} |
||||
|
{{ Form::submit(trans('customer.search'), ['class' => 'btn btn-sm']) }} |
||||
|
{{ link_to_route('customers.index', trans('app.reset')) }} |
||||
|
{{ Form::close() }} |
||||
|
</div> |
||||
|
<table class="table table-condensed"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th class="text-center">{{ trans('app.table_no') }}</th> |
||||
|
<th>{{ trans('customer.name') }}</th> |
||||
|
<th>{{ trans('contact.email') }}</th> |
||||
|
<th>{{ trans('contact.phone') }}</th> |
||||
|
<th class="text-center">{{ trans('customer.projects_count') }}</th> |
||||
|
<th class="text-center">{{ trans('app.status') }}</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
@foreach($customers as $key => $customer) |
||||
|
<tr> |
||||
|
<td class="text-center">{{ $customers->firstItem() + $key }}</td> |
||||
|
<td>{{ $customer->nameLink() }}</td> |
||||
|
<td>{{ $customer->email }}</td> |
||||
|
<td>{{ $customer->phone }}</td> |
||||
|
<td class="text-center">{{ $customer->projects_count }}</td> |
||||
|
<td class="text-center">{{ $customer->is_active }}</td> |
||||
|
</tr> |
||||
|
@endforeach |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<div class="panel-body">{{ $customers->appends(Request::except('page'))->render() }}</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
@endsection |
||||
@ -1,50 +0,0 @@ |
|||||
@extends('layouts.app') |
|
||||
|
|
||||
@section('title', trans('partner.list')) |
|
||||
|
|
||||
@section('content') |
|
||||
<h1 class="page-header"> |
|
||||
<div class="pull-right"> |
|
||||
{{ link_to_route('partners.create', trans('partner.create'), [], ['class' => 'btn btn-success']) }} |
|
||||
</div> |
|
||||
{{ trans('partner.list') }} |
|
||||
<small>{{ trans('app.total') }} : {{ $partners->total() }} {{ trans('partner.partner') }}</small> |
|
||||
</h1> |
|
||||
|
|
||||
<div class="panel panel-default table-responsive"> |
|
||||
<div class="panel-heading"> |
|
||||
{{ Form::open(['method' => 'get','class' => 'form-inline']) }} |
|
||||
{!! FormField::text('q', ['value' => request('q'), 'label' => trans('partner.search'), 'class' => 'input-sm']) !!} |
|
||||
{{ Form::submit(trans('partner.search'), ['class' => 'btn btn-sm']) }} |
|
||||
{{ link_to_route('partners.index', trans('app.reset')) }} |
|
||||
{{ Form::close() }} |
|
||||
</div> |
|
||||
<table class="table table-condensed"> |
|
||||
<thead> |
|
||||
<tr> |
|
||||
<th class="text-center">{{ trans('app.table_no') }}</th> |
|
||||
<th>{{ trans('partner.name') }}</th> |
|
||||
<th>{{ trans('contact.email') }}</th> |
|
||||
<th>{{ trans('contact.phone') }}</th> |
|
||||
<th class="text-center">{{ trans('partner.projects_count') }}</th> |
|
||||
<th class="text-center">{{ trans('app.status') }}</th> |
|
||||
</tr> |
|
||||
</thead> |
|
||||
<tbody> |
|
||||
@foreach($partners as $key => $partner) |
|
||||
<tr> |
|
||||
<td class="text-center">{{ $partners->firstItem() + $key }}</td> |
|
||||
<td>{{ $partner->nameLink() }}</td> |
|
||||
<td>{{ $partner->email }}</td> |
|
||||
<td>{{ $partner->phone }}</td> |
|
||||
<td class="text-center">{{ $partner->projects_count }}</td> |
|
||||
<td class="text-center">{{ $partner->is_active }}</td> |
|
||||
</tr> |
|
||||
@endforeach |
|
||||
</tbody> |
|
||||
</table> |
|
||||
<div class="panel-body">{{ $partners->appends(Request::except('page'))->render() }}</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
@endsection |
|
||||
@ -1,109 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace Tests\Feature; |
|
||||
|
|
||||
use App\Entities\Partners\Partner; |
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations; |
|
||||
use Tests\TestCase as TestCase; |
|
||||
|
|
||||
class ManagePartnersTest extends TestCase |
|
||||
{ |
|
||||
use DatabaseMigrations; |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_see_partner_list_in_partner_index_page() |
|
||||
{ |
|
||||
$user = $this->adminUserSigningIn(); |
|
||||
$partner1 = factory(Partner::class)->create(['owner_id' => $user->agency->id]); |
|
||||
$partner2 = factory(Partner::class)->create(['owner_id' => $user->agency->id]); |
|
||||
|
|
||||
$this->visit(route('partners.index')); |
|
||||
$this->see($partner1->name); |
|
||||
$this->see($partner2->name); |
|
||||
} |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_create_a_partner() |
|
||||
{ |
|
||||
$user = $this->adminUserSigningIn(); |
|
||||
$this->visit(route('partners.index')); |
|
||||
|
|
||||
$this->click(trans('partner.create')); |
|
||||
$this->seePageIs(route('partners.create')); |
|
||||
|
|
||||
$this->submitForm(trans('partner.create'), [ |
|
||||
'name' => 'Partner 1 name', |
|
||||
'email' => 'partner1@mail.com', |
|
||||
'phone' => '081234567890', |
|
||||
'pic' => 'Nama PIC Partner', |
|
||||
'address' => 'Alamat partner 1', |
|
||||
'notes' => '', |
|
||||
]); |
|
||||
|
|
||||
$this->see(trans('partner.created')); |
|
||||
|
|
||||
$this->seeInDatabase('partners', [ |
|
||||
'name' => 'Partner 1 name', |
|
||||
'email' => 'partner1@mail.com', |
|
||||
'phone' => '081234567890', |
|
||||
'pic' => 'Nama PIC Partner', |
|
||||
'address' => 'Alamat partner 1', |
|
||||
'notes' => null, |
|
||||
'owner_id' => $user->agency->id, |
|
||||
]); |
|
||||
} |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_edit_a_partner() |
|
||||
{ |
|
||||
$user = $this->adminUserSigningIn(); |
|
||||
$partner = factory(Partner::class)->create(['owner_id' => $user->agency->id, 'name' => 'Testing 123']); |
|
||||
|
|
||||
$this->visit(route('partners.show', [$partner->id])); |
|
||||
$this->click('edit-partner-'.$partner->id); |
|
||||
$this->seePageIs(route('partners.edit', [$partner->id])); |
|
||||
|
|
||||
$this->submitForm(trans('partner.update'), [ |
|
||||
'name' => 'Partner 1 name', |
|
||||
'email' => 'partner1@mail.com', |
|
||||
'phone' => '081234567890', |
|
||||
'pic' => 'Nama PIC Partner', |
|
||||
'address' => 'Alamat partner 1', |
|
||||
'notes' => '', |
|
||||
'is_active' => 0, |
|
||||
]); |
|
||||
|
|
||||
$this->seePageIs(route('partners.show', $partner->id)); |
|
||||
|
|
||||
$this->seeInDatabase('partners', [ |
|
||||
'name' => 'Partner 1 name', |
|
||||
'email' => 'partner1@mail.com', |
|
||||
'phone' => '081234567890', |
|
||||
'pic' => 'Nama PIC Partner', |
|
||||
'address' => 'Alamat partner 1', |
|
||||
'notes' => null, |
|
||||
'is_active' => 0, |
|
||||
]); |
|
||||
} |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_delete_a_partner() |
|
||||
{ |
|
||||
$user = $this->adminUserSigningIn(); |
|
||||
$partner = factory(Partner::class)->create(['owner_id' => $user->agency->id]); |
|
||||
|
|
||||
$this->visit(route('partners.edit', [$partner->id])); |
|
||||
$this->click('del-partner-'.$partner->id); |
|
||||
$this->seePageIs(route('partners.edit', [$partner->id, 'action' => 'delete'])); |
|
||||
|
|
||||
$this->seeInDatabase('partners', [ |
|
||||
'id' => $partner->id, |
|
||||
]); |
|
||||
|
|
||||
$this->press(trans('app.delete_confirm_button')); |
|
||||
|
|
||||
$this->dontSeeInDatabase('partners', [ |
|
||||
'id' => $partner->id, |
|
||||
]); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,109 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Feature; |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations; |
||||
|
use Tests\TestCase as TestCase; |
||||
|
|
||||
|
class ManageCustomersTest extends TestCase |
||||
|
{ |
||||
|
use DatabaseMigrations; |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_see_customer_list_in_customer_index_page() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$customer1 = factory(Customer::class)->create(['owner_id' => $user->agency->id]); |
||||
|
$customer2 = factory(Customer::class)->create(['owner_id' => $user->agency->id]); |
||||
|
|
||||
|
$this->visit(route('customers.index')); |
||||
|
$this->see($customer1->name); |
||||
|
$this->see($customer2->name); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_create_a_customer() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$this->visit(route('customers.index')); |
||||
|
|
||||
|
$this->click(trans('customer.create')); |
||||
|
$this->seePageIs(route('customers.create')); |
||||
|
|
||||
|
$this->submitForm(trans('customer.create'), [ |
||||
|
'name' => 'Customer 1 name', |
||||
|
'email' => 'customer1@mail.com', |
||||
|
'phone' => '081234567890', |
||||
|
'pic' => 'Nama PIC Customer', |
||||
|
'address' => 'Alamat customer 1', |
||||
|
'notes' => '', |
||||
|
]); |
||||
|
|
||||
|
$this->see(trans('customer.created')); |
||||
|
|
||||
|
$this->seeInDatabase('customers', [ |
||||
|
'name' => 'Customer 1 name', |
||||
|
'email' => 'customer1@mail.com', |
||||
|
'phone' => '081234567890', |
||||
|
'pic' => 'Nama PIC Customer', |
||||
|
'address' => 'Alamat customer 1', |
||||
|
'notes' => null, |
||||
|
'owner_id' => $user->agency->id, |
||||
|
]); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_edit_a_customer() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$customer = factory(Customer::class)->create(['owner_id' => $user->agency->id, 'name' => 'Testing 123']); |
||||
|
|
||||
|
$this->visit(route('customers.show', [$customer->id])); |
||||
|
$this->click('edit-customer-'.$customer->id); |
||||
|
$this->seePageIs(route('customers.edit', [$customer->id])); |
||||
|
|
||||
|
$this->submitForm(trans('customer.update'), [ |
||||
|
'name' => 'Customer 1 name', |
||||
|
'email' => 'customer1@mail.com', |
||||
|
'phone' => '081234567890', |
||||
|
'pic' => 'Nama PIC Customer', |
||||
|
'address' => 'Alamat customer 1', |
||||
|
'notes' => '', |
||||
|
'is_active' => 0, |
||||
|
]); |
||||
|
|
||||
|
$this->seePageIs(route('customers.show', $customer->id)); |
||||
|
|
||||
|
$this->seeInDatabase('customers', [ |
||||
|
'name' => 'Customer 1 name', |
||||
|
'email' => 'customer1@mail.com', |
||||
|
'phone' => '081234567890', |
||||
|
'pic' => 'Nama PIC Customer', |
||||
|
'address' => 'Alamat customer 1', |
||||
|
'notes' => null, |
||||
|
'is_active' => 0, |
||||
|
]); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_delete_a_customer() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$customer = factory(Customer::class)->create(['owner_id' => $user->agency->id]); |
||||
|
|
||||
|
$this->visit(route('customers.edit', [$customer->id])); |
||||
|
$this->click('del-customer-'.$customer->id); |
||||
|
$this->seePageIs(route('customers.edit', [$customer->id, 'action' => 'delete'])); |
||||
|
|
||||
|
$this->seeInDatabase('customers', [ |
||||
|
'id' => $customer->id, |
||||
|
]); |
||||
|
|
||||
|
$this->press(trans('app.delete_confirm_button')); |
||||
|
|
||||
|
$this->dontSeeInDatabase('customers', [ |
||||
|
'id' => $customer->id, |
||||
|
]); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Unit\Models; |
||||
|
|
||||
|
use App\Entities\Agencies\Agency; |
||||
|
use App\Entities\Partners\Customer; |
||||
|
use App\Entities\Projects\Project; |
||||
|
use Illuminate\Support\Collection; |
||||
|
use Tests\TestCase as TestCase; |
||||
|
|
||||
|
class CustomerTest extends TestCase |
||||
|
{ |
||||
|
/** @test */ |
||||
|
public function a_customer_has_an_owner() |
||||
|
{ |
||||
|
$agency = factory(Agency::class)->create(); |
||||
|
$customer = factory(Customer::class)->create(['owner_id' => $agency->id]); |
||||
|
|
||||
|
$this->assertTrue($customer->owner instanceof Agency); |
||||
|
$this->assertEquals($customer->owner->id, $agency->id); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function a_customer_has_many_projects() |
||||
|
{ |
||||
|
$customer = factory(Customer::class)->create(); |
||||
|
$project = factory(Project::class)->create(['customer_id' => $customer->id]); |
||||
|
|
||||
|
$this->assertTrue($customer->projects instanceof Collection); |
||||
|
$this->assertTrue($customer->projects->first() instanceof Project); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function a_customer_has_name_link_method() |
||||
|
{ |
||||
|
$customer = factory(Customer::class)->make(); |
||||
|
$this->assertEquals( |
||||
|
link_to_route('customers.show', $customer->name, [$customer->id], [ |
||||
|
'title' => trans( |
||||
|
'app.show_detail_title', |
||||
|
['name' => $customer->name, 'type' => trans('customer.customer')] |
||||
|
), |
||||
|
]), $customer->nameLink() |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -1,46 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace Tests\Unit\Models; |
|
||||
|
|
||||
use App\Entities\Agencies\Agency; |
|
||||
use App\Entities\Partners\Partner; |
|
||||
use App\Entities\Projects\Project; |
|
||||
use Illuminate\Support\Collection; |
|
||||
use Tests\TestCase as TestCase; |
|
||||
|
|
||||
class PartnerTest extends TestCase |
|
||||
{ |
|
||||
/** @test */ |
|
||||
public function a_partner_has_an_owner() |
|
||||
{ |
|
||||
$agency = factory(Agency::class)->create(); |
|
||||
$partner = factory(Partner::class)->create(['owner_id' => $agency->id]); |
|
||||
|
|
||||
$this->assertTrue($partner->owner instanceof Agency); |
|
||||
$this->assertEquals($partner->owner->id, $agency->id); |
|
||||
} |
|
||||
|
|
||||
/** @test */ |
|
||||
public function a_partner_has_many_projects() |
|
||||
{ |
|
||||
$partner = factory(Partner::class)->create(); |
|
||||
$project = factory(Project::class)->create(['customer_id' => $partner->id]); |
|
||||
|
|
||||
$this->assertTrue($partner->projects instanceof Collection); |
|
||||
$this->assertTrue($partner->projects->first() instanceof Project); |
|
||||
} |
|
||||
|
|
||||
/** @test */ |
|
||||
public function a_partner_has_name_link_method() |
|
||||
{ |
|
||||
$partner = factory(Partner::class)->make(); |
|
||||
$this->assertEquals( |
|
||||
link_to_route('partners.show', $partner->name, [$partner->id], [ |
|
||||
'title' => trans( |
|
||||
'app.show_detail_title', |
|
||||
['name' => $partner->name, 'type' => trans('partner.partner')] |
|
||||
), |
|
||||
]), $partner->nameLink() |
|
||||
); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,40 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Unit\Policies; |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use Tests\TestCase as TestCase; |
||||
|
|
||||
|
class CustomerPolicyTest extends TestCase |
||||
|
{ |
||||
|
/** @test */ |
||||
|
public function user_can_create_customer() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$this->assertTrue($user->can('create', new Customer)); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_view_customer() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$customer = factory(Customer::class)->create(['name' => 'Customer 1 name']); |
||||
|
$this->assertTrue($user->can('view', $customer)); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_update_customer() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$customer = factory(Customer::class)->create(['name' => 'Customer 1 name']); |
||||
|
$this->assertTrue($user->can('update', $customer)); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_delete_customer() |
||||
|
{ |
||||
|
$user = $this->adminUserSigningIn(); |
||||
|
$customer = factory(Customer::class)->create(['name' => 'Customer 1 name']); |
||||
|
$this->assertTrue($user->can('delete', $customer)); |
||||
|
} |
||||
|
} |
||||
@ -1,40 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace Tests\Unit\Policies; |
|
||||
|
|
||||
use App\Entities\Partners\Partner; |
|
||||
use Tests\TestCase as TestCase; |
|
||||
|
|
||||
class PartnerPolicyTest extends TestCase |
|
||||
{ |
|
||||
/** @test */ |
|
||||
public function user_can_create_partner() |
|
||||
{ |
|
||||
$user = $this->adminUserSigningIn(); |
|
||||
$this->assertTrue($user->can('create', new Partner)); |
|
||||
} |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_view_partner() |
|
||||
{ |
|
||||
$user = $this->adminUserSigningIn(); |
|
||||
$partner = factory(Partner::class)->create(['name' => 'Partner 1 name']); |
|
||||
$this->assertTrue($user->can('view', $partner)); |
|
||||
} |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_update_partner() |
|
||||
{ |
|
||||
$user = $this->adminUserSigningIn(); |
|
||||
$partner = factory(Partner::class)->create(['name' => 'Partner 1 name']); |
|
||||
$this->assertTrue($user->can('update', $partner)); |
|
||||
} |
|
||||
|
|
||||
/** @test */ |
|
||||
public function user_can_delete_partner() |
|
||||
{ |
|
||||
$user = $this->adminUserSigningIn(); |
|
||||
$partner = factory(Partner::class)->create(['name' => 'Partner 1 name']); |
|
||||
$this->assertTrue($user->can('delete', $partner)); |
|
||||
} |
|
||||
} |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue