Browse Source

Change description column to notes on vendors table

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
0dbacbfff6
  1. 2
      app/Entities/Partners/Vendor.php
  2. 14
      app/Http/Controllers/Partners/VendorsController.php
  3. 5
      database/factories/VendorFactory.php
  4. 4
      database/migrations/2017_11_01_185745_create_vendors_table.php
  5. 4
      resources/views/vendors/forms.blade.php
  6. 32
      tests/Feature/ManageVendorsTest.php

2
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()
{

14
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');

5
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;
},
];

4
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();
});
}

4
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

32
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,
]);
}

Loading…
Cancel
Save