Skip to content

Commit

Permalink
refactor(customer): Model sync with Lead. Adding missing field for ve…
Browse files Browse the repository at this point in the history
…rified phone, mobile
  • Loading branch information
gnovaro committed Jan 23, 2024
1 parent 251a362 commit 59a226a
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 11 deletions.
7 changes: 5 additions & 2 deletions app/Models/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,19 @@ class Customer extends Model
protected $table = 'customer';

protected $fillable = [
'external_id',
'company_id',
'external_id',
'name',
'business_name',
'dob',
'vat',
'phone',
'phone_verified',
'extension',
'phone2',
'phone2_verified',
'mobile',
'mobile_verified',
'email',
'email_verified',
'email2',
Expand Down Expand Up @@ -187,7 +190,7 @@ class Customer extends Model
'deleted_by',
];

protected $with = ['country', 'seller', 'industry'];
protected $with = ['country', 'seller', 'industry', 'company'];

public function company(): HasOne
{
Expand Down
7 changes: 6 additions & 1 deletion app/Models/Lead.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @OA\Schema(
* schema="Lead",
* type="object",
* required={"name", "country"},
* required={"name", "country", "seller_id"},
* @OA\Property(
* property="name",
* description="Name of the lead",
Expand Down Expand Up @@ -100,6 +100,11 @@
* type="string",
* format="url",
* example="https://www.likedin.com/in/profile"
* ),
* @OA\Property(
* property="seller_id",
* description="SellerID of the lead",
* type="string"
* )
* )
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('customer', function (Blueprint $table) {
$table->boolean('phone_verified')->nullable()->after('phone')->default(false);
$table->boolean('phone2_verified')->nullable()->after('phone2')->default(false);
$table->boolean('mobile_verified')->nullable()->after('mobile')->default(false);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('customer', function (Blueprint $table) {
$table->dropColumn('phone_verified');
$table->dropColumn('phone2_verified');
$table->dropColumn('mobile_verified');
});
}
};
47 changes: 40 additions & 7 deletions resources/views/customer/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ class="link-secondary link-underline-opacity-25 link-underline-opacity-100-hover
<th>{{ __('Country') }}</th>
<th>{{ __('Province') }}</th>
<th class="d-none d-sm-table-cell">Social</th>
<th class="text-center">{{ __('Seller') }}</th>
<th class="text-center d-none d-sm-table-cell">
<a href="{{ request()->fullUrlWithQuery(['order_by' => 'industry_id']) }}"
class="link-secondary link-underline-opacity-25 link-underline-opacity-100-hover">
{{ __('Industry') }}
</a>
</th>
<th class="text-center">{{ __('Seller') }}</th>
<th class="text-center d-none d-sm-table-cell">{{ __('Tags') }}</th>
<th class="d-none d-sm-table-cell">{{ __('Status') }}</th>
<th class="d-none d-sm-table-cell">
<a href="{{ request()->fullUrlWithQuery(['order_by' => 'created_at']) }}"
class="link-secondary link-underline-opacity-25 link-underline-opacity-100-hover">
{{ __('Created at') }}
{{ __('Created at') }}
</a>
</th>
<th class="d-none d-sm-table-cell">
<a href="{{ request()->fullUrlWithQuery(['order_by' => 'updated_at']) }}"
class="link-secondary link-underline-opacity-25 link-underline-opacity-100-hover">
{{ __('Updated at') }}
{{ __('Updated at') }}
</a>
</th>
<th>{{ __('Actions') }}</th>
Expand All @@ -103,9 +103,14 @@ class="link-secondary link-underline-opacity-25 link-underline-opacity-100-hover
@if($customer->phone)
<a href="tel:{{ $customer->phone }}@isset($customer->extension),{{$customer->extension}}@endisset"
title="{{ \App\Helpers\PhoneHelper::format($customer->phone) }}"
target="_blank" class="link-secondary text-decoration-none">
target="_blank" class="link-secondary text-decoration-none">
<i class="las la-phone fs-4"></i>
</a>
@if($customer->phone_verified == 1)
<i class="las la-check-circle text-success"></i>
@else
<i class="las la-times-circle text-danger"></i>
@endif

<a href="sip:{{ $customer->phone }}@isset($customer->extension),{{$customer->extension}}@endisset" title="{{ \App\Helpers\PhoneHelper::format($customer->phone) }}"
target="_blank" class="link-secondary text-decoration-none">
Expand All @@ -120,6 +125,29 @@ class="link-secondary link-underline-opacity-25 link-underline-opacity-100-hover
class="link-secondary text-decoration-none">
<i class="las la-mobile fs-4"></i>
</a>

@if($customer->mobile_verified == 1)
<i class="las la-check-circle text-success"></i>
@else
<i class="las la-times-circle text-danger"></i>
@endif

<a href="sip:{{ $customer->mobile }}" title="{{ \App\Helpers\PhoneHelper::format($customer->mobile) }}"
target="_blank" class="link-secondary text-decoration-none">
<i class="las la-headset fs-4"></i>
</a>

<a href="https://api.whatsapp.com/send/?phone={{ $customer->mobile }}&text={{ __('Hello') }}"
title="{{ \App\Helpers\PhoneHelper::format($customer->mobile) }}" target="_blank"
class="link-secondary text-decoration-none">
<i class="lab la-whatsapp fs-4"></i>
</a>

<a href="https://telegram.me/{{ $customer->mobile }}"
title="{{ \App\Helpers\PhoneHelper::format($customer->mobile) }}" target="_blank"
class="link-secondary text-decoration-none">
<i class="lab la-telegram-plane fs-4"></i>
</a>
@endif
</td>
<td class="text-nowrap text-center">
Expand All @@ -140,7 +168,7 @@ class="link-secondary text-decoration-none">
</a>
@endif
</td>
<td class="text-center d-sm-table-cell link-secondary"
<td class="text-center d-sm-table-cell link-secondary text-decoration-none"
title="{{ (!empty($customer->country)) ? $customer->country->name : '' }}">
@if(!empty($customer->country))
{{ $customer->country->flag }}
Expand Down Expand Up @@ -193,8 +221,12 @@ class="link-secondary text-decoration-none">
</a>
@endif
</td>
<td class="text-center text-nowrap">{{ (!empty($customer->seller)) ? $customer->seller->first_name : '' }}</td>
<td class="text-center text-nowrap d-none d-sm-table-cell">{{ ($customer->industry) ? __($customer->industry->name) : '' }}</td>
<td class="text-center text-nowrap">
@isset($customer->seller)
{{ $customer->seller->first_name }}
@endisset
</td>
<td class="text-center text-nowrap d-none d-sm-table-cell">
@if(is_array($customer->tags) || is_object($customer->tags))
@foreach($customer->tags as $tag)
Expand Down Expand Up @@ -236,7 +268,8 @@ class="link-secondary text-decoration-none">
<script>
const Customer = {
delete : function(id, name) {
let res = confirm("{{ __('Are you sure you want to delete the customer?') }}");
let message = `{{ __('Are you sure you want to delete the customer: ') }}${name}?`;
let res = confirm(message);
if(res)
window.location = '{{ url('/customer/delete') }}/'+id;
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
const APP_VERSION = '3.4.8';
const APP_VERSION = '3.4.9';

0 comments on commit 59a226a

Please sign in to comment.