diff --git a/app/Entities/Partners/Vendor.php b/app/Entities/Partners/Vendor.php index db719b5..79471f0 100644 --- a/app/Entities/Partners/Vendor.php +++ b/app/Entities/Partners/Vendor.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; class Vendor extends Model { - protected $fillable = ['name', 'description', 'website', 'owner_id', 'is_active']; + protected $fillable = ['name', 'notes', 'website', 'owner_id', 'is_active']; public function owner() { diff --git a/app/Http/Controllers/Partners/VendorsController.php b/app/Http/Controllers/Partners/VendorsController.php index 1776855..0787114 100644 --- a/app/Http/Controllers/Partners/VendorsController.php +++ b/app/Http/Controllers/Partners/VendorsController.php @@ -36,9 +36,9 @@ class VendorsController extends Controller public function store(Request $request) { $newVendorData = $this->validate($request, [ - 'name' => 'required|max:60', - 'description' => 'nullable|max:255', - 'website' => 'nullable|url|max:255', + 'name' => 'required|max:60', + 'notes' => 'nullable|max:255', + 'website' => 'nullable|url|max:255', ]); $newVendorData['owner_id'] = auth()->user()->agency->id; @@ -59,10 +59,10 @@ class VendorsController extends Controller public function update(Request $request, Vendor $vendor) { $vendorData = $this->validate($request, [ - 'name' => 'required|max:60', - 'description' => 'nullable|max:255', - 'website' => 'nullable|url|max:255', - 'is_active' => 'required|boolean', + 'name' => 'required|max:60', + 'notes' => 'nullable|max:255', + 'website' => 'nullable|url|max:255', + 'is_active' => 'required|boolean', ]); $routeParam = request()->only('page', 'q'); diff --git a/database/factories/VendorFactory.php b/database/factories/VendorFactory.php index 2ae3a3c..fac2ebc 100644 --- a/database/factories/VendorFactory.php +++ b/database/factories/VendorFactory.php @@ -7,9 +7,8 @@ use Faker\Generator as Faker; $factory->define(Vendor::class, function (Faker $faker) { return [ - 'name' => $faker->word, - 'description' => $faker->sentence, - 'owner_id' => function () { + 'name' => $faker->word, + 'owner_id' => function () { return factory(Agency::class)->create()->id; }, ]; diff --git a/database/migrations/2017_11_01_185745_create_vendors_table.php b/database/migrations/2017_11_01_185745_create_vendors_table.php index 38f83d1..dc5cc91 100644 --- a/database/migrations/2017_11_01_185745_create_vendors_table.php +++ b/database/migrations/2017_11_01_185745_create_vendors_table.php @@ -16,10 +16,10 @@ class CreateVendorsTable extends Migration Schema::create('vendors', function (Blueprint $table) { $table->increments('id'); $table->string('name', 60); - $table->string('description')->nullable(); - $table->unsignedInteger('owner_id'); $table->string('website')->nullable(); + $table->unsignedInteger('owner_id'); $table->boolean('is_active')->default(1); + $table->string('notes')->nullable(); $table->timestamps(); }); } diff --git a/resources/views/vendors/forms.blade.php b/resources/views/vendors/forms.blade.php index b395d81..71c4505 100644 --- a/resources/views/vendors/forms.blade.php +++ b/resources/views/vendors/forms.blade.php @@ -1,8 +1,8 @@ @if (Request::get('action') == 'create') {!! Form::open(['route' => 'vendors.store']) !!} {!! FormField::text('name', ['required' => true]) !!} - {!! FormField::textarea('description') !!} {!! FormField::text('website') !!} + {!! FormField::textarea('notes') !!} {!! Form::submit(trans('vendor.create'), ['class' => 'btn btn-success']) !!} {{ link_to_route('vendors.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }} {!! Form::close() !!} @@ -10,9 +10,9 @@ @if (Request::get('action') == 'edit' && $editableVendor) {!! Form::model($editableVendor, ['route' => ['vendors.update', $editableVendor->id],'method' => 'patch']) !!} {!! FormField::text('name', ['required' => true]) !!} - {!! FormField::textarea('description') !!} {!! FormField::text('website') !!} {!! FormField::radios('is_active', ['Non Aktif', 'Aktif']) !!} + {!! FormField::textarea('notes') !!} @if (request('q')) {{ Form::hidden('q', request('q')) }} @endif diff --git a/tests/Feature/ManageVendorsTest.php b/tests/Feature/ManageVendorsTest.php index 2ba31c2..4a04395 100644 --- a/tests/Feature/ManageVendorsTest.php +++ b/tests/Feature/ManageVendorsTest.php @@ -13,8 +13,8 @@ class ManageVendorsTest extends TestCase /** @test */ public function user_can_see_vendor_list_in_vendor_index_page() { - $vendor1 = factory(Vendor::class)->create(['name' => 'Testing name', 'description' => 'Testing 123']); - $vendor2 = factory(Vendor::class)->create(['name' => 'Testing name', 'description' => 'Testing 456']); + $vendor1 = factory(Vendor::class)->create(['name' => 'Testing name']); + $vendor2 = factory(Vendor::class)->create(['name' => 'Testing name']); $this->adminUserSigningIn(); $this->visit(route('vendors.index')); @@ -32,18 +32,18 @@ class ManageVendorsTest extends TestCase $this->seePageIs(route('vendors.index', ['action' => 'create'])); $this->submitForm(trans('vendor.create'), [ - 'name' => 'Vendor 1 name', - 'description' => 'Vendor 1 description', - 'website' => 'https://example.com', + 'name' => 'Vendor 1 name', + 'notes' => 'Vendor 1 notes', + 'website' => 'https://example.com', ]); $this->see(trans('vendor.created')); $this->seePageIs(route('vendors.index')); $this->seeInDatabase('vendors', [ - 'name' => 'Vendor 1 name', - 'description' => 'Vendor 1 description', - 'website' => 'https://example.com', + 'name' => 'Vendor 1 name', + 'notes' => 'Vendor 1 notes', + 'website' => 'https://example.com', ]); } @@ -58,20 +58,20 @@ class ManageVendorsTest extends TestCase $this->seePageIs(route('vendors.index', ['action' => 'edit', 'id' => $vendor->id, 'q' => '123'])); $this->submitForm(trans('vendor.update'), [ - 'name' => 'Vendor 1 name', - 'description' => 'Vendor 1 description', - 'website' => 'https://example.com', - 'is_active' => 0, + 'name' => 'Vendor 1 name', + 'notes' => 'Vendor 1 notes', + 'website' => 'https://example.com', + 'is_active' => 0, ]); $this->see(trans('vendor.updated')); $this->seePageIs(route('vendors.index', ['q' => '123'])); $this->seeInDatabase('vendors', [ - 'name' => 'Vendor 1 name', - 'description' => 'Vendor 1 description', - 'website' => 'https://example.com', - 'is_active' => 0, + 'name' => 'Vendor 1 name', + 'notes' => 'Vendor 1 notes', + 'website' => 'https://example.com', + 'is_active' => 0, ]); }