diff --git a/app/Entities/Partners/Customer.php b/app/Entities/Partners/Customer.php index 424b570..24ea533 100644 --- a/app/Entities/Partners/Customer.php +++ b/app/Entities/Partners/Customer.php @@ -9,7 +9,7 @@ class Customer extends Model { use OwnedByAgency; - protected $fillable = ['name', 'email', 'phone', 'pic', 'address', 'notes', 'is_active', 'owner_id']; + protected $fillable = ['name', 'email', 'phone', 'pic', 'address', 'website', 'notes', 'is_active', 'owner_id']; public function owner() { diff --git a/app/Http/Controllers/Partners/CustomersController.php b/app/Http/Controllers/Partners/CustomersController.php index 16ef193..efc0404 100644 --- a/app/Http/Controllers/Partners/CustomersController.php +++ b/app/Http/Controllers/Partners/CustomersController.php @@ -15,19 +15,13 @@ class CustomersController extends Controller */ 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')); + return view('customers.index', compact('customers')); } /** @@ -54,6 +48,7 @@ class CustomersController extends Controller 'phone' => 'nullable|max:255', 'pic' => 'nullable|max:255', 'address' => 'nullable|max:255', + 'website' => 'nullable|url|max:255', 'notes' => 'nullable|max:255', ]); @@ -103,6 +98,7 @@ class CustomersController extends Controller 'phone' => 'nullable|max:255', 'pic' => 'nullable|max:255', 'address' => 'nullable|max:255', + 'website' => 'nullable|url|max:255', 'notes' => 'nullable|max:255', 'is_active' => 'required|boolean', ]); diff --git a/database/migrations/2017_10_26_134455_create_customers_table.php b/database/migrations/2017_10_26_134455_create_customers_table.php index 37678f2..b788c71 100644 --- a/database/migrations/2017_10_26_134455_create_customers_table.php +++ b/database/migrations/2017_10_26_134455_create_customers_table.php @@ -20,6 +20,7 @@ class CreateCustomersTable extends Migration $table->string('phone')->nullable(); $table->string('pic')->nullable(); $table->string('address')->nullable(); + $table->string('website')->nullable(); $table->string('notes')->nullable(); $table->boolean('is_active')->default(1); $table->unsignedInteger('owner_id'); diff --git a/resources/views/customers/create.blade.php b/resources/views/customers/create.blade.php index b1ac436..9699d57 100644 --- a/resources/views/customers/create.blade.php +++ b/resources/views/customers/create.blade.php @@ -28,6 +28,7 @@
{!! FormField::email('email') !!}
{!! FormField::text('phone') !!}
+ {!! FormField::text('website') !!} {!! FormField::textarea('address') !!} diff --git a/resources/views/customers/edit.blade.php b/resources/views/customers/edit.blade.php index 772b8ac..7006511 100644 --- a/resources/views/customers/edit.blade.php +++ b/resources/views/customers/edit.blade.php @@ -33,6 +33,7 @@
{!! FormField::email('email') !!}
{!! FormField::text('phone') !!}
+ {!! FormField::text('website') !!} {!! FormField::textarea('address') !!} diff --git a/tests/Feature/Partners/ManageCustomersTest.php b/tests/Feature/Partners/ManageCustomersTest.php index 8760b40..a73002a 100644 --- a/tests/Feature/Partners/ManageCustomersTest.php +++ b/tests/Feature/Partners/ManageCustomersTest.php @@ -13,7 +13,7 @@ class ManageCustomersTest extends TestCase /** @test */ public function user_can_see_customer_list_in_customer_index_page() { - $user = $this->adminUserSigningIn(); + $user = $this->adminUserSigningIn(); $customer1 = factory(Customer::class)->create(['owner_id' => $user->agency->id]); $customer2 = factory(Customer::class)->create(['owner_id' => $user->agency->id]); @@ -37,6 +37,7 @@ class ManageCustomersTest extends TestCase 'phone' => '081234567890', 'pic' => 'Nama PIC Customer', 'address' => 'Alamat customer 1', + 'website' => 'https://example.com', 'notes' => '', ]); @@ -48,6 +49,7 @@ class ManageCustomersTest extends TestCase 'phone' => '081234567890', 'pic' => 'Nama PIC Customer', 'address' => 'Alamat customer 1', + 'website' => 'https://example.com', 'notes' => null, 'owner_id' => $user->agency->id, ]); @@ -56,7 +58,7 @@ class ManageCustomersTest extends TestCase /** @test */ public function user_can_edit_a_customer() { - $user = $this->adminUserSigningIn(); + $user = $this->adminUserSigningIn(); $customer = factory(Customer::class)->create(['owner_id' => $user->agency->id, 'name' => 'Testing 123']); $this->visit(route('customers.show', [$customer->id])); @@ -69,6 +71,7 @@ class ManageCustomersTest extends TestCase 'phone' => '081234567890', 'pic' => 'Nama PIC Customer', 'address' => 'Alamat customer 1', + 'website' => 'https://example.com', 'notes' => '', 'is_active' => 0, ]); @@ -81,6 +84,7 @@ class ManageCustomersTest extends TestCase 'phone' => '081234567890', 'pic' => 'Nama PIC Customer', 'address' => 'Alamat customer 1', + 'website' => 'https://example.com', 'notes' => null, 'is_active' => 0, ]); @@ -89,7 +93,7 @@ class ManageCustomersTest extends TestCase /** @test */ public function user_can_delete_a_customer() { - $user = $this->adminUserSigningIn(); + $user = $this->adminUserSigningIn(); $customer = factory(Customer::class)->create(['owner_id' => $user->agency->id]); $this->visit(route('customers.edit', [$customer->id]));