From 4f8063214f0bccd0ca63e3762761eac8c84c39e7 Mon Sep 17 00:00:00 2001 From: FreeScout Date: Thu, 19 Nov 2020 01:15:00 -0800 Subject: [PATCH] Rename customer background into notes, delete age, gender fields --- app/Customer.php | 6 ++-- ...20_11_19_070000_update_customers_table.php | 36 +++++++++++++++++++ .../customers/partials/edit_form.blade.php | 8 ++--- .../views/customers/profile_snippet.blade.php | 4 +-- 4 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 database/migrations/2020_11_19_070000_update_customers_table.php diff --git a/app/Customer.php b/app/Customer.php index 2505b4a5..394be6b4 100644 --- a/app/Customer.php +++ b/app/Customer.php @@ -446,7 +446,7 @@ class Customer extends Model * * @var [type] */ - protected $fillable = ['first_name', 'last_name', 'company', 'job_title', 'address', 'city', 'state', 'zip', 'country', 'photo_url', 'age', 'gender', 'background']; + protected $fillable = ['first_name', 'last_name', 'company', 'job_title', 'address', 'city', 'state', 'zip', 'country', 'photo_url', 'age', 'gender', 'notes']; /** * Fields stored as JSON. @@ -920,8 +920,8 @@ class Customer extends Model unset($data['photo_url']); } - if (!empty($data['notes']) && empty($data['background'])) { - $data['background'] = $data['notes']; + if (!empty($data['background']) && empty($data['notes'])) { + $data['notes'] = $data['background']; } if ($replace_data) { diff --git a/database/migrations/2020_11_19_070000_update_customers_table.php b/database/migrations/2020_11_19_070000_update_customers_table.php new file mode 100644 index 00000000..516b01a6 --- /dev/null +++ b/database/migrations/2020_11_19_070000_update_customers_table.php @@ -0,0 +1,36 @@ +dropColumn('age'); + $table->dropColumn('gender'); + $table->renameColumn('background', 'notes'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('customers', function (Blueprint $table) { + $table->string('age', 7)->nullable(); + $table->unsignedTinyInteger('gender')->nullable(); + $table->renameColumn('notes', 'background'); + }); + } +} diff --git a/resources/views/customers/partials/edit_form.blade.php b/resources/views/customers/partials/edit_form.blade.php index 7ce9b732..ee2d3a39 100644 --- a/resources/views/customers/partials/edit_form.blade.php +++ b/resources/views/customers/partials/edit_form.blade.php @@ -241,13 +241,13 @@ -
- +
+
- + - @include('partials/field_error', ['field'=>'background']) + @include('partials/field_error', ['field'=>'notes'])
diff --git a/resources/views/customers/profile_snippet.blade.php b/resources/views/customers/profile_snippet.blade.php index 5d096c7f..c544a527 100644 --- a/resources/views/customers/profile_snippet.blade.php +++ b/resources/views/customers/profile_snippet.blade.php @@ -46,9 +46,9 @@ @if ($customer->address)
{{ $customer->address }}
@endif
@endif - @if ($customer->background) + @if ($customer->notes)
- {{ $customer->background }} + {{ $customer->notes }}
@endif