14 changed files with 560 additions and 184 deletions
-
10app/Entities/Partners/Customer.php
-
104app/Http/Controllers/Partners/CustomersController.php
-
64app/Policies/Partners/CustomerPolicy.php
-
1app/Providers/AuthServiceProvider.php
-
11database/factories/CustomerFactory.php
-
38database/migrations/2017_10_26_134455_create_customers_table.php
-
27resources/lang/id/customer.php
-
66resources/views/customers/forms.blade.php
-
67resources/views/customers/index.blade.php
-
4routes/web.php
-
182routes/web/helpers.php
-
108tests/Feature/ManageCustomersTest.php
-
19tests/Unit/Models/CustomerTest.php
-
43tests/Unit/Policies/CustomerPolicyTest.php
@ -0,0 +1,10 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Entities\Partners; |
||||
|
|
||||
|
use Illuminate\Database\Eloquent\Model; |
||||
|
|
||||
|
class Customer extends Model |
||||
|
{ |
||||
|
protected $fillable = ['name', 'email', 'phone', 'pic', 'address', 'notes', 'is_active']; |
||||
|
} |
||||
@ -0,0 +1,104 @@ |
|||||
|
<?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').'%'); |
||||
|
})->paginate(25); |
||||
|
|
||||
|
if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { |
||||
|
$editableCustomer = Customer::find(request('id')); |
||||
|
} |
||||
|
|
||||
|
return view('customers.index', compact('customers', 'editableCustomer')); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 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', |
||||
|
]); |
||||
|
|
||||
|
Customer::create($newCustomerData); |
||||
|
|
||||
|
flash(trans('customer.created'), 'success'); |
||||
|
|
||||
|
return redirect()->route('customers.index'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 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', |
||||
|
]); |
||||
|
|
||||
|
$routeParam = request()->only('page', 'q'); |
||||
|
|
||||
|
$customer = $customer->update($customerData); |
||||
|
|
||||
|
flash(trans('customer.updated'), 'success'); |
||||
|
return redirect()->route('customers.index', $routeParam); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 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(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Policies\Partners; |
||||
|
|
||||
|
use App\Entities\Users\User; |
||||
|
use App\Entities\Partners\Customer; |
||||
|
use Illuminate\Auth\Access\HandlesAuthorization; |
||||
|
|
||||
|
class CustomerPolicy |
||||
|
{ |
||||
|
use HandlesAuthorization; |
||||
|
|
||||
|
/** |
||||
|
* Determine whether the user can view the project. |
||||
|
* |
||||
|
* @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 projects. |
||||
|
* |
||||
|
* @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 project. |
||||
|
* |
||||
|
* @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 project. |
||||
|
* |
||||
|
* @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; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use Faker\Generator as Faker; |
||||
|
|
||||
|
$factory->define(Customer::class, function (Faker $faker) { |
||||
|
|
||||
|
return [ |
||||
|
'name' => $faker->company, |
||||
|
]; |
||||
|
}); |
||||
@ -0,0 +1,38 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use Illuminate\Support\Facades\Schema; |
||||
|
use Illuminate\Database\Schema\Blueprint; |
||||
|
use Illuminate\Database\Migrations\Migration; |
||||
|
|
||||
|
class CreateCustomersTable extends Migration |
||||
|
{ |
||||
|
/** |
||||
|
* Run the migrations. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function up() |
||||
|
{ |
||||
|
Schema::create('customers', function (Blueprint $table) { |
||||
|
$table->increments('id'); |
||||
|
$table->string('name', 60); |
||||
|
$table->string('email')->nullable()->unique(); |
||||
|
$table->string('phone')->nullable(); |
||||
|
$table->string('pic')->nullable(); |
||||
|
$table->string('address')->nullable(); |
||||
|
$table->string('notes')->nullable(); |
||||
|
$table->boolean('is_active')->default(1); |
||||
|
$table->timestamps(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Reverse the migrations. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function down() |
||||
|
{ |
||||
|
Schema::dropIfExists('customers'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
// Labels
|
||||
|
'customer' => 'Customer', |
||||
|
'list' => 'Customer List', |
||||
|
'search' => 'Search Customer', |
||||
|
'not_found' => 'Customer not found.', |
||||
|
'empty' => 'Customer is empty.', |
||||
|
'back_to_show' => 'Back to Customer Detail', |
||||
|
'back_to_index' => 'Back to Customer List', |
||||
|
|
||||
|
// Actions
|
||||
|
'create' => 'Create new Customer', |
||||
|
'created' => 'Create new Customer succeded.', |
||||
|
'edit' => 'Edit Customer', |
||||
|
'update' => 'Update Customer', |
||||
|
'updated' => 'Update Customer succeded.', |
||||
|
'delete' => 'Delete Customer', |
||||
|
'delete_confirm' => 'Are you sure to delete this Customer?', |
||||
|
'deleted' => 'Delete Customer succeded.', |
||||
|
'undeleted' => 'Customer not deleted.', |
||||
|
|
||||
|
// Attributes
|
||||
|
'name' => 'Customer Name', |
||||
|
'description' => 'Customer Description', |
||||
|
]; |
||||
@ -0,0 +1,66 @@ |
|||||
|
@if (Request::get('action') == 'create') |
||||
|
{!! Form::open(['route' => 'customers.store']) !!} |
||||
|
{!! FormField::text('name', ['required' => true]) !!} |
||||
|
{!! FormField::email('email') !!} |
||||
|
{!! FormField::text('phone') !!} |
||||
|
{!! FormField::text('pic') !!} |
||||
|
{!! FormField::textarea('address') !!} |
||||
|
{!! FormField::textarea('notes') !!} |
||||
|
{!! Form::submit(trans('customer.create'), ['class' => 'btn btn-success']) !!} |
||||
|
{{ link_to_route('customers.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }} |
||||
|
{!! Form::close() !!} |
||||
|
@endif |
||||
|
@if (Request::get('action') == 'edit' && $editableCustomer) |
||||
|
{!! Form::model($editableCustomer, ['route' => ['customers.update', $editableCustomer->id],'method' => 'patch']) !!} |
||||
|
{!! FormField::text('name', ['required' => true]) !!} |
||||
|
{!! FormField::email('email') !!} |
||||
|
{!! FormField::text('phone') !!} |
||||
|
{!! FormField::text('pic') !!} |
||||
|
{!! FormField::textarea('address') !!} |
||||
|
{!! FormField::textarea('notes') !!} |
||||
|
{!! FormField::radios('is_active', ['Non Aktif', 'Aktif']) !!} |
||||
|
@if (request('q')) |
||||
|
{{ Form::hidden('q', request('q')) }} |
||||
|
@endif |
||||
|
@if (request('page')) |
||||
|
{{ Form::hidden('page', request('page')) }} |
||||
|
@endif |
||||
|
{!! Form::submit(trans('customer.update'), ['class' => 'btn btn-success']) !!} |
||||
|
{{ link_to_route('customers.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }} |
||||
|
{!! Form::close() !!} |
||||
|
@endif |
||||
|
@if (Request::get('action') == 'delete' && $editableCustomer) |
||||
|
<div class="panel panel-default"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">{{ trans('customer.delete') }}</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<label class="control-label">{{ trans('customer.name') }}</label> |
||||
|
<p>{{ $editableCustomer->name }}</p> |
||||
|
<label class="control-label">{{ trans('contact.email') }}</label> |
||||
|
<p>{{ $editableCustomer->email }}</p> |
||||
|
<label class="control-label">{{ trans('contact.phone') }}</label> |
||||
|
<p>{{ $editableCustomer->phone }}</p> |
||||
|
<label class="control-label">{{ trans('app.address') }}</label> |
||||
|
<p>{{ $editableCustomer->address }}</p> |
||||
|
<label class="control-label">{{ trans('app.status') }}</label> |
||||
|
<p>{{ $editableCustomer->is_active }}</p> |
||||
|
<label class="control-label">{{ trans('app.notes') }}</label> |
||||
|
<p>{{ $editableCustomer->notes }}</p> |
||||
|
{!! $errors->first('customer_id', '<span class="form-error small">:message</span>') !!} |
||||
|
</div> |
||||
|
<hr style="margin:0"> |
||||
|
<div class="panel-body">{{ trans('app.delete_confirm') }}</div> |
||||
|
<div class="panel-footer"> |
||||
|
{!! FormField::delete( |
||||
|
['route'=>['customers.destroy',$editableCustomer->id]], |
||||
|
trans('app.delete_confirm_button'), |
||||
|
['class'=>'btn btn-danger'], |
||||
|
[ |
||||
|
'customer_id' => $editableCustomer->id, |
||||
|
'page' => request('page'), |
||||
|
'q' => request('q'), |
||||
|
] |
||||
|
) !!} |
||||
|
{{ link_to_route('customers.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }} |
||||
|
</div> |
||||
|
</div> |
||||
|
@endif |
||||
@ -0,0 +1,67 @@ |
|||||
|
@extends('layouts.app') |
||||
|
|
||||
|
@section('title', trans('customer.list')) |
||||
|
|
||||
|
@section('content') |
||||
|
<h1 class="page-header"> |
||||
|
<div class="pull-right"> |
||||
|
{{ link_to_route('customers.index', trans('customer.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }} |
||||
|
</div> |
||||
|
{{ trans('customer.list') }} |
||||
|
<small>{{ trans('app.total') }} : {{ $customers->total() }} {{ trans('customer.customer') }}</small> |
||||
|
</h1> |
||||
|
<div class="row"> |
||||
|
<div class="col-md-9"> |
||||
|
<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('app.status') }}</th> |
||||
|
<th class="text-center">{{ trans('app.action') }}</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
@foreach($customers as $key => $customer) |
||||
|
<tr> |
||||
|
<td class="text-center">{{ $customers->firstItem() + $key }}</td> |
||||
|
<td>{{ $customer->name }}</td> |
||||
|
<td>{{ $customer->email }}</td> |
||||
|
<td>{{ $customer->phone }}</td> |
||||
|
<td class="text-center">{{ $customer->is_active }}</td> |
||||
|
<td class="text-center"> |
||||
|
{!! link_to_route( |
||||
|
'customers.index', |
||||
|
trans('app.edit'), |
||||
|
['action' => 'edit', 'id' => $customer->id] + Request::only('page', 'q'), |
||||
|
['id' => 'edit-customer-' . $customer->id] |
||||
|
) !!} | |
||||
|
{!! link_to_route( |
||||
|
'customers.index', |
||||
|
trans('app.delete'), |
||||
|
['action' => 'delete', 'id' => $customer->id] + Request::only('page', 'q'), |
||||
|
['id' => 'del-customer-' . $customer->id] |
||||
|
) !!} |
||||
|
</td> |
||||
|
</tr> |
||||
|
@endforeach |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<div class="panel-body">{{ $customers->appends(Request::except('page'))->render() }}</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="col-md-3"> |
||||
|
@includeWhen(Request::has('action'), 'customers.forms') |
||||
|
</div> |
||||
|
</div> |
||||
|
@endsection |
||||
@ -1,182 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
use App\Entities\Projects\Project; |
|
||||
|
|
||||
// Event::listen('illuminate.query', function($query)
|
|
||||
// {
|
|
||||
// echo $query; echo '<br><br>';
|
|
||||
// });
|
|
||||
|
|
||||
// Route::get('add-customers', function() {
|
|
||||
// $customers = ['Huda','Om Ekong','Isra Tanjung','Ahmad Fatah','STAI Buntok','Hasto','Jakhoster','Ujang Rahman','Donny','Ipul Batulicin','Joenathan Tanumiha','Prima','Dinas Koperasi UKM Kalsel','Stikes Husada Borneo','Rumah Web','Herbert','Donny Kurniawan'];
|
|
||||
// foreach ($customers as $customer) {
|
|
||||
// $user = new App\Entities\Users\User;
|
|
||||
// $user->name = $customer;
|
|
||||
// $user->username = str_replace(' ', '_', strtolower($customer));
|
|
||||
// $user->email = $user->username . '@mail.com';
|
|
||||
// $user->password = 'member';
|
|
||||
// $user->save();
|
|
||||
// $user->assignRole('customer');
|
|
||||
// }
|
|
||||
// });
|
|
||||
|
|
||||
Route::get('add-existing-payments', function() { |
|
||||
// $payments = [
|
|
||||
// ['Frestour.com','500000','2014-05-14','Jasa website','Heru Yugo'],
|
|
||||
// ['Elfbandung','500000','2014-06-12','Sistem reservasi','Heru Yugo'],
|
|
||||
// ['Skripsi Ryan','250000','2014-06-21','Input jadwal, export to XL & PDF','Heru Yugo'],
|
|
||||
// ['Bandungrafting.com','300000','2014-06-30','Jasa website','Heru Yugo'],
|
|
||||
// ['Cianjurnews.com','150000','2014-07-09','Halaman index','Heru Yugo'],
|
|
||||
// ['Bandungrafting.com','150000','2014-07-11','Jasa website','Heru Yugo'],
|
|
||||
// ['Glowinklash.com','250000','2014-07-20','Jasa website','Heru Yugo'],
|
|
||||
// ['Trijayatrans.com','50000','2014-07-20','Form reservasi email','Heru Yugo'],
|
|
||||
// ['Skripsi Rotan','500000','2014-08-10','Shopping cart, halaman produk dgn pengurutan produk terlaris, CRUD tarif pengiriman','Andie'],
|
|
||||
// ['Skripsi Makarizo','500000','2014-08-10','Shopping cart, laporan penjualan, backup database MySQL','Andie'],
|
|
||||
// ['Stimi-bjm.ac.id','2000000','2014-08-11','DP jasa website','STIMI'],
|
|
||||
// ['Stimi-bjm.ac.id','-1000000','2014-08-11','DP jasa website, hosting, domain','Heru Yugo'],
|
|
||||
// ['Belimukena.com','5000000','2014-08-17','Shopping cart, management sistem','Heru Yugo'],
|
|
||||
// ['Belimukena.com','-500000','2014-08-17','Pembagian belimukena.com','Heru Yugo'],
|
|
||||
// ['Skripsi Absensi (sms gateway)','700000','2014-08-17','SMS gateway broadcast, input absen dan laporan semester','Andie'],
|
|
||||
// ['Skripsi SPB (sms gateway)','300000','2014-08-17','SMS gateway broadcast dan laporan','Andie'],
|
|
||||
// ['Belimukena.com','200000','2014-09-08','Revisi tambahan','Heru Yugo'],
|
|
||||
// ['Imet18.com','750000','2014-09-12','Sistem informasi laporan prospecting','Heru Yugo'],
|
|
||||
// ['Livescore','2000000','2014-09-18','Website seperti livescore','Heru Yugo'],
|
|
||||
// ['Rajabagus','1400000','2014-09-24','Pembuatan import code/voucher dan signup with voucher','Heru Yugo'],
|
|
||||
// ['Stimi-bjm.ac.id','2000000','2014-10-14','Pelunasan website stimi','STIMI'],
|
|
||||
// ['Belimukena.com','600000','2014-11-07','Biaya maintenance 2014-11','Heru Yugo'],
|
|
||||
// ['bandungtraverservice.com','500000','2014-11-13','fee isi content bandung travel service','Heru Yugo'],
|
|
||||
// ['Belimukena.com','300000','2014-12-08','Biaya maintenance 2014-12','Heru Yugo'],
|
|
||||
// ['Belimukena.com','100000','2014-12-08','fee buat reject order reason','Heru Yugo'],
|
|
||||
// ['Legacyvapestore.com','350000','2014-12-12','fee isi content dan buat tutorial','Heru Yugo'],
|
|
||||
// ['Aplikasi Toko Obat Sholah (Andie)','700000','2014-12-23','fee buat shopping cart apotik dan print nota','Andie'],
|
|
||||
// ['Panjimitra.co.id','344500','2015-01-02','DP corporate email panjimitra.co.id','Heru Yugo'],
|
|
||||
// ['Aplikasi Toko Obat Sholah (Andie)','1000000','2015-01-02','fee revisi shopping cart apotik dan management stok','Andie'],
|
|
||||
// ['Panjimitra.co.id','580000','2015-01-05','Pelunasan corporate email panjimitra.co.id','Heru Yugo'],
|
|
||||
// ['elfjakarta.com','150000','2015-01-05','DP pembuatan website dan aplikasi reservasi elfjakarta.com','Heru Yugo'],
|
|
||||
// ['Aplikasi Toko Obat Sholah (Andie)','100000','2015-01-09','Jasa setting printer dan printout nota','Sholah'],
|
|
||||
// ['Belimukena.com','300000','2015-01-09','Biaya maintenance 2015-01','Heru Yugo'],
|
|
||||
// ['elfjakarta.com','150000','2015-01-10','Pelunasan Elfjakarta.com','Heru Yugo'],
|
|
||||
// ['mambabykid.com','250000','2015-01-16','DP MambabyKid.com','Heru Yugo'],
|
|
||||
// ['mambabykid.com','250000','2015-01-20','Pelunasan Mambabykid.com','Heru Yugo'],
|
|
||||
// ['Aplikasi Reservasi Frestour','1000000','2015-01-21','DP Payapps','Heru Yugo'],
|
|
||||
// ['Belimukena.com','300000','2015-02-10','Biaya maintenance 2015-02','Heru Yugo'],
|
|
||||
// ['alamjayatrans.com','350000','2015-02-20','Buat landing page untuk car rental','Heru Yugo'],
|
|
||||
// ['Rajatourbandung.com','50000','2015-02-20','Form reservasi email','Heru Yugo'],
|
|
||||
// ['Belimukena.com','300000','2015-03-04','Biaya maintenance 2015-03','Heru Yugo'],
|
|
||||
// ['Belimukena.com','350000','2015-03-04','Revisi form cart (ditambahkan custom nama pengirim di akun admin, reseller dan company reseller)','Heru Yugo'],
|
|
||||
// ['Diskonmobisuzuki.com','350000','2015-03-20','Pembuatan fitur sales area','Eko'],
|
|
||||
// ['Aplikasi Order','200000','2015-03-22','DP aplikasi order','Heru Yugo'],
|
|
||||
// ['azka.co.id','300000','2015-03-30','Landing page car rental','Heru Yugo'],
|
|
||||
// ['Legacyvapestore.com','350000','2015-04-04','DP redesign Legacyvapestore','Heru Yugo'],
|
|
||||
// ['autodaihatsu.com','300000','2015-04-08','DP pembuatan website sales daihatsu bandung','Heru Yugo'],
|
|
||||
// ['Belimukena.com','450000','2015-04-13','Biaya maintenance 2015-04 (plus security)','Heru Yugo'],
|
|
||||
// ['my-trans.co.id','1300000','2015-04-27','DP pembuatan web company profile www.my-trans.co.id','Yamin'],
|
|
||||
// ['my-trans.co.id','-650000','2015-04-27','Biaya hosting dan domain','Heru Yugo'],
|
|
||||
// ['berkahsynergy.com','300000','2015-04-28','Pembuatan template berkahsynergy.com (redesign)','Erwin Fastweb'],
|
|
||||
// ['autodaihatsu.com','200000','2015-04-30','Pelunasan pembuatan website sales daihatsu bandung','Heru Yugo'],
|
|
||||
// ['Legacyvapestore.com','250000','2015-05-04','Pelunasan redesign website legacyvapestore','Heru Yugo'],
|
|
||||
// ['Belimukena.com','1350000','2015-05-15','Biaya maintenance 2015-05, 2015-06, 2015-07','Heru Yugo'],
|
|
||||
// ['Belimukena.com','150000','2015-05-15','Sebagian biaya maintenance 2015-08 (dipake mas yugo/pak Arise)','Heru Yugo'],
|
|
||||
// ['Aplikasi Toko Obat Sholah (Andie)','100000','2015-05-23','Backup dan restore aplikasi web toko sholah','Sholah'],
|
|
||||
// ['Aplikasi Toko Obat Sholah','1000000','2015-05-26','DP pembuatan aplikasi','Sholah'],
|
|
||||
// ['Kursus Private PHP dan Konsul Skripsi','900000','2015-05-28','DP Kursus Private Pemrograman PHP dan Konsultasi Skirpsi','Huda'],
|
|
||||
// ['my-trans.co.id','500000','2015-05-29','Pembayaran ke 2 website my-trans dan aplikasi connote','Yamin'],
|
|
||||
// ['my-trans.co.id','1250000','2015-06-22','Pelunasan website my trans','Yamin'],
|
|
||||
// ['Aplikasi Toko Obat Sholah','700000','2015-06-23','Pelunasan pembuatan aplikasi toko obat Sholah','Sholah'],
|
|
||||
// ['Ambasadortrans.com','250000','2015-07-01','DP aplikasi reservasi ambasador trans','Heru Yugo'],
|
|
||||
// ['Kursus Private PHP dan Konsul Skripsi','900000','2015-07-02','Pelunasan Kursus Private Pemrograman PHP dan Konsultasi Skirpsi','Huda'],
|
|
||||
// ['Aplikasi Reservasi Frestour','1200000','2015-07-06','Pelunasan payapps tourbandung.com dari total (Rp. 1.500.000)','Heru Yugo'],
|
|
||||
// ['my-trans.co.id','150000','2015-07-08','Pembayaran fitur Konversi kurs dollar Tarif international dan setting email di ponsel','Yamin'],
|
|
||||
// ['Aplikasi Toko Obat Sholah','100000','2015-07-23','Perbaiki Jaringan toko Sholah','Sholah'],
|
|
||||
// ['pulaupermata.com','1000000','2015-07-28','Biaya pembuatan website toko permata','Om Ekong'],
|
|
||||
// ['Belimukena.com','450000','2015-08-10','Biaya maintenance 2015-08','Heru Yugo'],
|
|
||||
// ['Ambasadortrans.com','100000','2015-08-18','Pembayaran ke 2 (sisa Rp. 150.000)','Heru Yugo'],
|
|
||||
// ['Stimi-bjm.ac.id','500000','2015-08-19','Pembayaran perbaikan pengumuman kopertis, pasang channel youtube stimi, setting social icons','STIMI'],
|
|
||||
// ['Belimukena.com','450000','2015-09-07','Biaya maintenance 2015-09','Heru Yugo'],
|
|
||||
// ['online.my-trans.co.id','4400000','2015-09-08','Pembayaran uang muka aplikasi My-Trans','Yamin'],
|
|
||||
// ['Stimi-bjm.ac.id','1000000','2015-09-16','Perpanjangan hosting dan domain s/d 2016-10-01','STIMI'],
|
|
||||
// ['Stimi-bjm.ac.id','-800000','2015-09-16','Transfer to mas Yugo (plus Rp. 100Rb utk talangan perpanjangan Indonet 2015-09)','Heru Yugo'],
|
|
||||
// ['Aplikasi Apotek Iloenk','1000000','2015-09-27','DP Aplikasi Apotek Iloenk','Isra Tanjung'],
|
|
||||
// ['Belimukena.com','900000','2015-09-29','Modifikasi kalkulasi ongkir dgn API Rajaongkir (Migrasi Rajaongkir)','Heru Yugo'],
|
|
||||
// ['Belimukena.com','450000','2015-10-10','Biaya maintenance 2015-10','Heru Yugo'],
|
|
||||
// ['Aplikasi Toko Obat Sholah','200000','2015-10-13','Install ulang aplikasi Toko Obat dan Restore Database','Sholah'],
|
|
||||
// ['sia.stimi-bjm.ac.id','5000000','2015-10-28','Uang muka pembuatan aplikasi SIAKAD STIMI Banjarmasin','STIMI'],
|
|
||||
// ['Aplikasi Apotek Iloenk','1000000','2015-11-02','Pelunasan Aplikasi Apotek Iloenk','Isra Tanjung'],
|
|
||||
// ['Belimukena.com','450000','2015-11-06','Biaya maintenance 2015-11','Heru Yugo'],
|
|
||||
// ['Ambasadortrans.com','150000','2015-12-05','Pelunasan','Heru Yugo'],
|
|
||||
// ['Belimukena.com','450000','2015-12-07','Biaya maintenance 2015-12','Heru Yugo'],
|
|
||||
// ['DutaKurirBorneo.co.id','525000','2015-12-08','Biaya hosting dan domain','Ahmad Fatah'],
|
|
||||
// ['DutaKurirBorneo.co.id','-425000','2015-12-08','Biaya hosting dan domain','Heru Yugo'],
|
|
||||
// ['Aplikasi Reservasi Frestour','100000','2015-12-08','Cicilan Frestour.com Payapps (sisa Rp. 200.000)','Heru Yugo'],
|
|
||||
// ['Panjimitra.co.id','300000','2015-12-11','Fee hosting domain panjimitra.co.id','Heru Yugo'],
|
|
||||
// ['stai-almaarif-buntok.ac.id','2300000','2015-12-14','DP+domain+hosting','STAI Buntok'],
|
|
||||
// ['stai-almaarif-buntok.ac.id','-1800000','2015-12-14','DP+domain+hosting','Heru Yugo'],
|
|
||||
// ['stai-almaarif-buntok.ac.id','100000','2015-12-14','Bonus dari Yugo','Heru Yugo'],
|
|
||||
// ['Aplikasi Reservasi Frestour','200000','2015-12-14','Cicilan Frestour.com Payapps (Lunas)','Heru Yugo'],
|
|
||||
// ['online.my-trans.co.id','4400000','2015-12-15','Pelunasan Aplikasi E-Connote My-trans','Yamin'],
|
|
||||
// ['online.my-trans.co.id','-300000','2015-12-15','Fee mas yugo','Heru Yugo'],
|
|
||||
// ['Belimukena.com','450000','2016-01-06','Biaya maintenance 2016-01','Heru Yugo'],
|
|
||||
// ['borneotaichiclass.com','500000','2016-01-12','DP Website BorneoTaichiClass.com','Hasto'],
|
|
||||
// ['borneotaichiclass.com','-240000','2016-01-12','Hosting Domain','Jakhoster'],
|
|
||||
// ['bintangtimur.co.id','1325000','2016-01-21','DP Website BintangTimur.co.id','Ujang Rahman'],
|
|
||||
// ['bintangtimur.co.id','-825000','2016-01-25','Domain Hosting Website BintangTimur.co.id','Heru Yugo'],
|
|
||||
// ['borneotaichiclass.com','650000','2016-01-27','Pelunasan Website BorneoTaichiClass.com, domain taichichuanpropatria-bjm.com dan domain kungfupropatria-bjm.com','Hasto'],
|
|
||||
// ['kungfupropatria-bjm.com','-240000','2016-01-27','domain taichichuanpropatria-bjm.com dan domain kungfupropatria-bjm.com','Jakhoster'],
|
|
||||
// ['Belimukena.com','450000','2016-02-10','Biaya maintenance 2016-02','Heru Yugo'],
|
|
||||
// ['majas.co.id','900000','2016-02-19','DP Pembuatan web majas.co.id','Donny'],
|
|
||||
// ['Aplikasi Apotek Mubarok','1000000','2016-02-24','DP Pembuatan Aplikasi Apotek Mubarok','Ipul Batulicin'],
|
|
||||
// ['Aplikasi Apotek Mubarok','1000000','2016-02-28','Pelunasan Pembuatan Aplikasi Apotek Mubarok','Ipul Batulicin'],
|
|
||||
// ['sia.stimi-bjm.ac.id','5000000','2016-03-03','Pelunasan Aplikasi Siakad dan Tracer Study STIMI','STIMI'],
|
|
||||
// ['Belimukena.com','450000','2016-03-08','Biaya maintenance 2016-03','Heru Yugo'],
|
|
||||
// ['attelierjewelry.com','1000000','2016-03-10','DP online store attelierjewelry.com','Joenathan Tanumiha'],
|
|
||||
// ['Aplikasi QRCode Haki','250000','2016-03-18','Cicilan 1 DP','Erwin Fastweb'],
|
|
||||
// ['Calief Gallery','1500000','2016-03-31','Cicilan 1 DP Aplikasi Order Calief Gallery','Heru Yugo'],
|
|
||||
// ['Aplikasi QRCode Haki','250000','2016-03-31','Cicilan 2 DP','Erwin Fastweb'],
|
|
||||
// ['my-trans.co.id','650000','2016-04-04','Biaya hosting dan domain','Yamin'],
|
|
||||
// ['my-trans.co.id','-650000','2016-04-04','Biaya hosting dan domain','Heru Yugo'],
|
|
||||
// ['Calief Gallery','1000000','2016-04-04','Cicilan 2 DP Aplikasi Order Calief Gallery','Heru Yugo'],
|
|
||||
// ['stai-almaarif-buntok.ac.id','2300000','2016-04-04','Pelunasan pembuatan website stai-almaarif-buntok.ac.id','STAI Buntok'],
|
|
||||
// ['stai-almaarif-buntok.ac.id','-800000','2016-04-04','Pelunasan pembuatan website stai-almaarif-buntok.ac.id','Heru Yugo'],
|
|
||||
// ['Belimukena.com','450000','2016-04-05','Biaya maintenance 2016-04','Heru Yugo'],
|
|
||||
// ['stai-almaarif-buntok.ac.id','-400000','2016-04-06','Fee marketing dari pak Prima','Prima'],
|
|
||||
// ['Bimtek Pemasaran Online','4000000','2016-04-14','Honor narasumber','Dinas Koperasi UKM Kalsel'],
|
|
||||
// ['sia.stikeshusada-borneo.ac.id','8000000','2016-04-18','DP Aplikasi Siakad dan Tracer Study STIKES HB','Stikes Husada Borneo'],
|
|
||||
// ['sia.stikeshusada-borneo.ac.id','-2000000','2016-04-19','Fee Aplikasi Siakad STIKES HB','Prima'],
|
|
||||
// ['Calief Gallery','1800000','2016-04-19','Pelunasan Aplikasi Order Calief Gallery','Heru Yugo'],
|
|
||||
// ['borneotaichiclass.com','150000','2016-04-26','Fee revisi website dan edit artikel','Hasto'],
|
|
||||
// ['attelierjewelry.com','-315000','2016-04-27','Domain Hosting Attelierjewelry.com','Rumah Web'],
|
|
||||
// ['bintangtimur.co.id','1000000','2016-04-28','Pelunasan Website BintangTimur.co.id (belum entry content)','Ujang Rahman'],
|
|
||||
// ['Aplikasi QRCode Haki','500000','2016-04-29','Cicilan 3 DP','Erwin Fastweb'],
|
|
||||
// ['Belimukena.com','450000','2016-05-04','Biaya maintenance 2016-05','Heru Yugo'],
|
|
||||
// ['majas.co.id','-110000','2016-05-10','Domain majas.co.id','Rumah Web'],
|
|
||||
// ['majas.co.id','-250000','2016-05-11','Hosting 2GB majas.co.id','Jakhoster'],
|
|
||||
// ['Belimukena.com','450000','2016-06-06','Biaya maintenance 2016-06','Heru Yugo'],
|
|
||||
// ['Aplikasi Toko Obat Berkah','1900000','2016-06-17','Aplikasi Toko Obat Berkah','Sholah'],
|
|
||||
// ['Aplikasi e-report CK Balangan','1200000','2016-06-18','DP Aplikasi Pelaporan Online & Domain+Hosting','Herbert'],
|
|
||||
// ['Aplikasi Direktori KKF','400000','2016-06-18','DP Aplikasi Direktori Pelaku Usaha KKF','Donny Kurniawan'],
|
|
||||
// ['Aplikasi e-report CK Balangan','-55000','2016-06-24','Domain ckbalangan.web.id','Rumah Web'],
|
|
||||
// ['Aplikasi QRCode Haki','1000000','2016-06-29','Cicilan 4','Erwin Fastweb'],
|
|
||||
// ];
|
|
||||
// $formated = [];
|
|
||||
// $projects = Project::all();
|
|
||||
// $customers = App\Entities\Users\User::latest()->hasRoles(['customer'])->get();
|
|
||||
// // dump($projects->lists('name'));
|
|
||||
// foreach ($payments as $payment) {
|
|
||||
// $formated[] = [
|
|
||||
// 'project_id' => ($project = $projects->where('name', $payment[0])->first()) ? $project->id : 'hit',
|
|
||||
// 'amount' => abs($payment[1]),
|
|
||||
// 'type' => $payment[1] < 0 ? 0 : 1,
|
|
||||
// 'date' => $payment[2],
|
|
||||
// 'description' => $payment[3],
|
|
||||
// 'customer_id' => ($customer = $customers->where('name', $payment[4])->first()) ? $customer->id : 'hit',
|
|
||||
// 'created_at' => $payment[2] . ' 00:00:00',
|
|
||||
// ];
|
|
||||
// }
|
|
||||
|
|
||||
// DB::beginTransaction();
|
|
||||
// DB::table('payments')->insert($formated);
|
|
||||
// DB::commit();
|
|
||||
|
|
||||
// echo '<pre>$formated : ', print_r($formated, true), '</pre>';
|
|
||||
// die();
|
|
||||
}); |
|
||||
@ -0,0 +1,108 @@ |
|||||
|
<?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() |
||||
|
{ |
||||
|
$customer1 = factory(Customer::class)->create(); |
||||
|
$customer2 = factory(Customer::class)->create(); |
||||
|
|
||||
|
$this->adminUserSigningIn(); |
||||
|
$this->visit(route('customers.index')); |
||||
|
$this->see($customer1->name); |
||||
|
$this->see($customer2->name); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_create_a_customer() |
||||
|
{ |
||||
|
$this->adminUserSigningIn(); |
||||
|
$this->visit(route('customers.index')); |
||||
|
|
||||
|
$this->click(trans('customer.create')); |
||||
|
$this->seePageIs(route('customers.index', ['action' => '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->seePageIs(route('customers.index')); |
||||
|
|
||||
|
$this->seeInDatabase('customers', [ |
||||
|
'name' => 'Customer 1 name', |
||||
|
'email' => 'customer1@mail.com', |
||||
|
'phone' => '081234567890', |
||||
|
'pic' => 'Nama PIC Customer', |
||||
|
'address' => 'Alamat customer 1', |
||||
|
'notes' => null, |
||||
|
]); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function user_can_edit_a_customer_within_search_query() |
||||
|
{ |
||||
|
$this->adminUserSigningIn(); |
||||
|
$customer = factory(Customer::class)->create(['name' => 'Testing 123']); |
||||
|
|
||||
|
$this->visit(route('customers.index', ['q' => '123'])); |
||||
|
$this->click('edit-customer-'.$customer->id); |
||||
|
$this->seePageIs(route('customers.index', ['action' => 'edit', 'id' => $customer->id, 'q' => '123'])); |
||||
|
|
||||
|
$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.index', ['q' => '123'])); |
||||
|
|
||||
|
$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() |
||||
|
{ |
||||
|
$this->adminUserSigningIn(); |
||||
|
$customer = factory(Customer::class)->create(); |
||||
|
|
||||
|
$this->visit(route('customers.index', [$customer->id])); |
||||
|
$this->click('del-customer-'.$customer->id); |
||||
|
$this->seePageIs(route('customers.index', ['action' => 'delete', 'id' => $customer->id])); |
||||
|
|
||||
|
$this->seeInDatabase('customers', [ |
||||
|
'id' => $customer->id, |
||||
|
]); |
||||
|
|
||||
|
$this->press(trans('app.delete_confirm_button')); |
||||
|
|
||||
|
$this->dontSeeInDatabase('customers', [ |
||||
|
'id' => $customer->id, |
||||
|
]); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Unit\Models; |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations; |
||||
|
use Tests\TestCase as TestCase; |
||||
|
|
||||
|
class CustomerTest extends TestCase |
||||
|
{ |
||||
|
use DatabaseMigrations; |
||||
|
|
||||
|
/** @test */ |
||||
|
public function it_has_name_attribute() |
||||
|
{ |
||||
|
$customer = factory(Customer::class)->create(['name' => 'Customer 1 name']); |
||||
|
$this->assertEquals('Customer 1 name', $customer->name); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Unit\Policies; |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations; |
||||
|
use Tests\TestCase as TestCase; |
||||
|
|
||||
|
class CustomerTest extends TestCase |
||||
|
{ |
||||
|
use DatabaseMigrations; |
||||
|
|
||||
|
/** @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)); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue