diff --git a/app/Actions/CRM/Customer/UI/ShowCustomer.php b/app/Actions/CRM/Customer/UI/ShowCustomer.php index 0934cba06..a02aa1f0c 100644 --- a/app/Actions/CRM/Customer/UI/ShowCustomer.php +++ b/app/Actions/CRM/Customer/UI/ShowCustomer.php @@ -146,6 +146,7 @@ public function htmlResponse(Customer $customer, ActionRequest $request): Respon parent: $customer, modelOperations: [ 'createLink' => [ + /* [ 'route' => [ 'name' => 'org.models.customers.websites.upload', @@ -154,11 +155,12 @@ public function htmlResponse(Customer $customer, ActionRequest $request): Respon 'icon' => 'fal fa-upload', 'label' => 'upload', 'style' => 'secondary', - 'mode' => 'upload', // To able to call in parent page as template #buttonupload + 'mode' => 'upload', // To be able to call in parent page as template #buttonupload ], + */ [ 'route' => [ - 'name' => 'org.shops.show.products.create', + 'name' => 'org.crm.shop.customers.show.customer-websites.create', 'parameters' => array_values($this->originalParameters) ], 'label' => __('create'), diff --git a/app/Actions/Portfolios/CustomerWebsite/UI/IndexCustomerWebsites.php b/app/Actions/Portfolios/CustomerWebsite/UI/IndexCustomerWebsites.php index 6584620f3..57ab4c360 100644 --- a/app/Actions/Portfolios/CustomerWebsite/UI/IndexCustomerWebsites.php +++ b/app/Actions/Portfolios/CustomerWebsite/UI/IndexCustomerWebsites.php @@ -71,8 +71,8 @@ public function handle(Organisation|Shop|Customer $parent, $prefix = null): Leng $globalSearch = AllowedFilter::callback('global', function ($query, $value) { $query->where(function ($query) use ($value) { $query->whereAnyWordStartWith('portfolio_websites.name', $value) - ->orWhere('portfolio_websites.domain', 'ilike', "%$value%") - ->orWhere('portfolio_websites.code', 'ilike', "$value%"); + ->orWhere('portfolio_websites.url', 'ilike', "%$value%") + ->orWhere('portfolio_websites.slug', 'ilike', "$value%"); }); }); if ($prefix) { @@ -91,10 +91,10 @@ public function handle(Organisation|Shop|Customer $parent, $prefix = null): Leng } return $queryBuilder - ->select('customers.name as customer_name', 'portfolio_websites.slug', 'portfolio_websites.name', 'domain') - ->defaultSort('portfolio_websites.code') + ->select('customers.name as customer_name', 'portfolio_websites.slug', 'portfolio_websites.name', 'url','customers.slug as customer_slug') + ->defaultSort('portfolio_websites.slug') ->leftJoin('customers', 'customer_id', 'customers.id') - ->allowedSorts(['slug', 'code', 'name', 'number_banners', 'domain']) + ->allowedSorts(['slug', 'name', 'number_banners', 'url']) ->allowedFilters([$globalSearch]) ->withPaginator($prefix) ->withQueryString(); @@ -117,7 +117,7 @@ public function tableStructure(Organisation|Shop|Customer $parent, ?array $model 'Customer' => [ 'title' => __("This customer don't have any website"), 'description' => $this->canEdit ? __('New website.') : null, - 'count' => $parent->stats->number_portfolio_websites, + 'count' => $parent->portfolioStats->number_portfolio_websites, 'action' => [ 'type' => 'button', 'style' => 'create', @@ -137,10 +137,13 @@ public function tableStructure(Organisation|Shop|Customer $parent, ?array $model } ) ->withExportLinks($exportLinks) - ->column(key: 'slug', label: __('code'), sortable: true) - ->column(key: 'customer_name', label: __('customer'), sortable: true) - ->column(key: 'name', label: __('name'), sortable: true) - ->column(key: 'domain', label: __('domain'), sortable: true) + ->column(key: 'slug', label: __('code'), sortable: true); + + if(class_basename($parent)!='Customer') { + $table->column(key: 'customer_name', label: __('customer'), sortable: true); + } + $table->column(key: 'name', label: __('name'), sortable: true) + ->column(key: 'url', label: __('url'), sortable: true) ->defaultSort('slug'); }; } diff --git a/app/Actions/Portfolios/CustomerWebsite/UI/ShowCustomerWebsite.php b/app/Actions/Portfolios/CustomerWebsite/UI/ShowCustomerWebsite.php index 827138fee..22582c6aa 100644 --- a/app/Actions/Portfolios/CustomerWebsite/UI/ShowCustomerWebsite.php +++ b/app/Actions/Portfolios/CustomerWebsite/UI/ShowCustomerWebsite.php @@ -210,14 +210,14 @@ public function getBreadcrumbs(string $routeName, array $routeParameters, string public function getPrevious(CustomerWebsite $customerWebsite, ActionRequest $request): ?array { - $previous = CustomerWebsite::where('code', '<', $customerWebsite->code)->orderBy('code', 'desc')->first(); + $previous = CustomerWebsite::where('slug', '<', $customerWebsite->slug)->orderBy('slug', 'desc')->first(); return $this->getNavigation($previous, $request->route()->getName()); } public function getNext(CustomerWebsite $customerWebsite, ActionRequest $request): ?array { - $next = CustomerWebsite::where('code', '>', $customerWebsite->code)->orderBy('code')->first(); + $next = CustomerWebsite::where('slug', '>', $customerWebsite->slug)->orderBy('slug')->first(); return $this->getNavigation($next, $request->route()->getName()); } diff --git a/app/Http/Resources/Prospects/CustomerWebsiteResource.php b/app/Http/Resources/Prospects/CustomerWebsiteResource.php index 6cb62002e..3f9a25cb2 100644 --- a/app/Http/Resources/Prospects/CustomerWebsiteResource.php +++ b/app/Http/Resources/Prospects/CustomerWebsiteResource.php @@ -11,6 +11,7 @@ /** * @property string $customer_name + * @property string $customer_slug */ class CustomerWebsiteResource extends JsonResource { @@ -23,9 +24,10 @@ public function toArray($request): array return [ 'slug' => $customerWebsite->slug, 'customer_name' => $this->customer_name, - 'code' => $customerWebsite->code, + 'customer_slug' => $this->customer_slug, + 'name' => $customerWebsite->name, - 'domain' => $customerWebsite->domain, + 'url' => $customerWebsite->url, // 'number_banners' => $customerWebsite->stats->number_banners ]; } diff --git a/resources/js/Components/Tables/TableCustomerWebsites.vue b/resources/js/Components/Tables/TableCustomerWebsites.vue index 2510fb659..fbcd6d8f5 100644 --- a/resources/js/Components/Tables/TableCustomerWebsites.vue +++ b/resources/js/Components/Tables/TableCustomerWebsites.vue @@ -41,6 +41,20 @@ function websiteRoute(website: Website) { } } +function customerRoute(website: Website) { + + switch (route().current()) { + case 'org.portfolios.shop.customer-websites.index': + return route( + 'org.crm.shop.customers.show', + [ + route().params['shop'], + website.customer_slug + ]); + + } +} + + diff --git a/routes/org/web/crm.php b/routes/org/web/crm.php index d0eb5c485..711d91727 100644 --- a/routes/org/web/crm.php +++ b/routes/org/web/crm.php @@ -16,6 +16,7 @@ use App\Actions\CRM\User\UI\IndexUsers; use App\Actions\CRM\User\UI\ShowUser; use App\Actions\Leads\Prospect\UI\CreateProspect; +use App\Actions\Portfolio\PortfolioWebsite\UI\CreatePortfolioWebsite; use App\Actions\Portfolios\CustomerWebsite\UI\CreateCustomerWebsite; use App\Actions\Portfolios\CustomerWebsite\UI\EditCustomerWebsite; use App\Actions\Portfolios\CustomerWebsite\UI\IndexCustomerWebsites; @@ -41,6 +42,8 @@ Route::get('web-users/create', [CreateUser::class, 'inCustomer'])->name('show.web-users.create'); Route::get('web-users/{user}', [ShowUser::class, 'inCustomer'])->name('show.web-users.show'); Route::get('web-users/{user}/edit', [EditUser::class, 'inCustomer'])->name('show.web-users.edit'); + + }); Route::prefix('prospects')->as('prospects.')->group(function () {