Skip to content

Commit

Permalink
Merge branch 'main' of github.com:inikoo/wowsbar into main
Browse files Browse the repository at this point in the history
  • Loading branch information
YudhistiraA committed Oct 6, 2023
2 parents 2a6a111 + 1f4c739 commit ae771ca
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
6 changes: 4 additions & 2 deletions app/Actions/CRM/Customer/UI/ShowCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public function htmlResponse(Customer $customer, ActionRequest $request): Respon
parent: $customer,
modelOperations: [
'createLink' => [
/*
[
'route' => [
'name' => 'org.models.customers.websites.upload',
Expand All @@ -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'),
Expand Down
23 changes: 13 additions & 10 deletions app/Actions/Portfolios/CustomerWebsite/UI/IndexCustomerWebsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand All @@ -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',
Expand All @@ -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');
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Resources/Prospects/CustomerWebsiteResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* @property string $customer_name
* @property string $customer_slug
*/
class CustomerWebsiteResource extends JsonResource
{
Expand All @@ -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
];
}
Expand Down
19 changes: 19 additions & 0 deletions resources/js/Components/Tables/TableCustomerWebsites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);

}
}

</script>

<template>
Expand All @@ -50,6 +64,11 @@ function websiteRoute(website: Website) {
{{ website['slug'] }}
</Link>
</template>
<template #cell(customer_name)="{ item: website }">
<Link :href="customerRoute(website)" :id=" website['customer_slug']" class="py-2 px-1">
{{ website['customer_name'] }}
</Link>
</template>
</Table>


Expand Down
3 changes: 3 additions & 0 deletions routes/org/web/crm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 () {
Expand Down

0 comments on commit ae771ca

Please sign in to comment.