Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sampoyigi committed Oct 17, 2021
2 parents 9e1491f + c1cfb18 commit 14fc954
Show file tree
Hide file tree
Showing 34 changed files with 381 additions and 197 deletions.
9 changes: 6 additions & 3 deletions app/admin/bulkactionwidgets/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
namespace Admin\BulkActionWidgets;

use Admin\Classes\BaseBulkActionWidget;
use Illuminate\Support\Facades\DB;

class Delete extends BaseBulkActionWidget
{
public function handleAction($requestData, $records)
{
// Delete records
if ($count = $records->count()) {
foreach ($records as $record) {
$record->delete();
}
DB::transaction(function () use ($records) {
foreach ($records as $record) {
$record->delete();
}
});

$prefix = ($count > 1) ? ' records' : 'record';
flash()->success(sprintf(lang('admin::lang.alert_success'), '['.$count.']'.$prefix.' '.lang('admin::lang.text_deleted')));
Expand Down
11 changes: 8 additions & 3 deletions app/admin/bulkactionwidgets/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Admin\BulkActionWidgets;

use Admin\Classes\BaseBulkActionWidget;
use Illuminate\Support\Facades\DB;

class Status extends BaseBulkActionWidget
{
Expand All @@ -19,11 +20,15 @@ public function handleAction($requestData, $records)
{
$code = array_get($requestData, 'code');
[$actionCode, $statusCode] = explode('.', $code, 2);
$statusColumn = $this->statusColumn;

if ($count = $records->count()) {
foreach ($records as $record) {
$record->update([$this->statusColumn => ($statusCode === 'enable')]);
}
DB::transaction(function () use ($records, $statusColumn, $statusCode) {
foreach ($records as $record) {
$record->$statusColumn = ($statusCode === 'enable');
$record->save();
}
});

$prefix = ($count > 1) ? ' records' : 'record';
flash()->success(sprintf(lang('admin::lang.alert_success'),
Expand Down
7 changes: 5 additions & 2 deletions app/admin/models/Customers_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,12 @@ public function mailGetRecipients($type)

public function mailGetData()
{
$model = $this->fresh();

return [
'full_name' => $this->full_name,
'email' => $this->email,
'customer' => $model,
'full_name' => $model->full_name,
'email' => $model->email,
];
}
}
2 changes: 2 additions & 0 deletions app/admin/models/Orders_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ public function mailGetData()
$data = [];

$model = $this->fresh();
$data['order'] = $model;
$data['order_number'] = $model->order_id;
$data['order_id'] = $model->order_id;
$data['first_name'] = $model->first_name;
Expand Down Expand Up @@ -404,6 +405,7 @@ public function mailGetData()
if ($model->location) {
$data['location_name'] = $model->location->location_name;
$data['location_email'] = $model->location->location_email;
$data['location_telephone'] = $model->location->location_telephone;
$data['location_address'] = format_address($model->location->getAddress());
}

Expand Down
4 changes: 3 additions & 1 deletion app/admin/models/Reservations_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function scopeWhereBetweenReservationDateTime($query, $start, $end)
public function scopeWhereBetweenDate($query, $dateTime)
{
$query->whereRaw(
'? between ADDTIME(reserve_date, reserve_time)'.
'? between DATE_SUB(ADDTIME(reserve_date, reserve_time), INTERVAL (duration - 2) MINUTE)'.
' and DATE_ADD(ADDTIME(reserve_date, reserve_time), INTERVAL duration MINUTE)',
[$dateTime]
);
Expand Down Expand Up @@ -422,6 +422,7 @@ public function mailGetData()
$data = [];

$model = $this->fresh();
$data['reservation'] = $model;
$data['reservation_number'] = $model->reservation_id;
$data['reservation_id'] = $model->reservation_id;
$data['reservation_time'] = Carbon::createFromTimeString($model->reserve_time)->format(lang('system::lang.php.time_format'));
Expand All @@ -436,6 +437,7 @@ public function mailGetData()
if ($model->location) {
$data['location_name'] = $model->location->location_name;
$data['location_email'] = $model->location->location_email;
$data['location_telephone'] = $model->location->location_telephone;
}

$statusHistory = Status_history_model::applyRelated($model)->whereStatusIsLatest($model->status_id)->first();
Expand Down
9 changes: 6 additions & 3 deletions app/admin/models/Users_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ public function mailGetRecipients($type)

public function mailGetData()
{
$model = $this->fresh();

return [
'staff_name' => $this->staff_name,
'staff_email' => $this->staff->staff_email,
'username' => $this->username,
'staff' => $model,
'staff_name' => $model->staff_name,
'staff_email' => $model->staff->staff_email,
'username' => $model->username,
];
}
}
33 changes: 25 additions & 8 deletions app/admin/models/config/allergens_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,33 @@
'class' => 'btn btn-primary',
'href' => 'allergens/create',
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-danger',
'data-attach-loading' => '',
'data-request' => 'onDelete',
'data-request-form' => '#list-form',
'data-request-data' => "_method:'DELETE'",
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

$config['list']['bulkActions'] = [
'status' => [
'label' => 'lang:admin::lang.list.actions.label_status',
'type' => 'dropdown',
'class' => 'btn btn-light',
'statusColumn' => 'status',
'menuItems' => [
'enable' => [
'label' => 'lang:admin::lang.list.actions.label_enable',
'type' => 'button',
'class' => 'dropdown-item',
],
'disable' => [
'label' => 'lang:admin::lang.list.actions.label_disable',
'type' => 'button',
'class' => 'dropdown-item text-danger',
],
],
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-light text-danger',
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

$config['list']['columns'] = [
Expand Down
1 change: 0 additions & 1 deletion app/admin/models/config/categories_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-light text-danger',
'data-request-data' => "_method:'DELETE'",
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];
Expand Down
17 changes: 8 additions & 9 deletions app/admin/models/config/customer_groups_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
'class' => 'btn btn-primary',
'href' => 'customer_groups/create',
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-danger',
'data-attach-loading' => '',
'data-request' => 'onDelete',
'data-request-form' => '#list-form',
'data-request-data' => "_method:'DELETE'",
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
],
];

$config['list']['bulkActions'] = [
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-light text-danger',
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

Expand Down
35 changes: 26 additions & 9 deletions app/admin/models/config/customers_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@
'class' => 'btn btn-primary',
'href' => 'customers/create',
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-danger',
'data-attach-loading' => '',
'data-request' => 'onDelete',
'data-request-form' => '#list-form',
'data-request-data' => "_method:'DELETE'",
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
'groups' => [
'label' => 'lang:admin::lang.side_menu.customer_group',
'class' => 'btn btn-default',
Expand All @@ -42,6 +33,32 @@
],
];

$config['list']['bulkActions'] = [
'status' => [
'label' => 'lang:admin::lang.list.actions.label_status',
'type' => 'dropdown',
'class' => 'btn btn-light',
'statusColumn' => 'status',
'menuItems' => [
'enable' => [
'label' => 'lang:admin::lang.list.actions.label_enable',
'type' => 'button',
'class' => 'dropdown-item',
],
'disable' => [
'label' => 'lang:admin::lang.list.actions.label_disable',
'type' => 'button',
'class' => 'dropdown-item text-danger',
],
],
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-light text-danger',
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

$config['list']['columns'] = [
'edit' => [
'type' => 'button',
Expand Down
33 changes: 25 additions & 8 deletions app/admin/models/config/locations_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,33 @@
'class' => 'btn btn-primary',
'href' => 'locations/create',
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-danger',
'data-attach-loading' => '',
'data-request' => 'onDelete',
'data-request-form' => '#list-form',
'data-request-data' => "_method:'DELETE'",
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

$config['list']['bulkActions'] = [
'status' => [
'label' => 'lang:admin::lang.list.actions.label_status',
'type' => 'dropdown',
'class' => 'btn btn-light',
'statusColumn' => 'location_status',
'menuItems' => [
'enable' => [
'label' => 'lang:admin::lang.list.actions.label_enable',
'type' => 'button',
'class' => 'dropdown-item',
],
'disable' => [
'label' => 'lang:admin::lang.list.actions.label_disable',
'type' => 'button',
'class' => 'dropdown-item text-danger',
],
],
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-light text-danger',
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

$config['list']['columns'] = [
Expand Down
33 changes: 25 additions & 8 deletions app/admin/models/config/mealtimes_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,33 @@
'class' => 'btn btn-primary',
'href' => 'mealtimes/create',
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-danger',
'data-attach-loading' => '',
'data-request' => 'onDelete',
'data-request-form' => '#list-form',
'data-request-data' => "_method:'DELETE'",
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

$config['list']['bulkActions'] = [
'status' => [
'label' => 'lang:admin::lang.list.actions.label_status',
'type' => 'dropdown',
'class' => 'btn btn-light',
'statusColumn' => 'mealtime_status',
'menuItems' => [
'enable' => [
'label' => 'lang:admin::lang.list.actions.label_enable',
'type' => 'button',
'class' => 'dropdown-item',
],
'disable' => [
'label' => 'lang:admin::lang.list.actions.label_disable',
'type' => 'button',
'class' => 'dropdown-item text-danger',
],
],
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-light text-danger',
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

$config['list']['columns'] = [
Expand Down
35 changes: 26 additions & 9 deletions app/admin/models/config/menus_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@
'class' => 'btn btn-primary',
'href' => 'menus/create',
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-danger',
'data-attach-loading' => '',
'data-request' => 'onDelete',
'data-request-form' => '#list-form',
'data-request-data' => "_method:'DELETE'",
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
'allergens' => [
'label' => 'lang:admin::lang.allergens.text_allergens',
'class' => 'btn btn-default',
Expand All @@ -53,6 +44,32 @@
],
];

$config['list']['bulkActions'] = [
'status' => [
'label' => 'lang:admin::lang.list.actions.label_status',
'type' => 'dropdown',
'class' => 'btn btn-light',
'statusColumn' => 'menu_status',
'menuItems' => [
'enable' => [
'label' => 'lang:admin::lang.list.actions.label_enable',
'type' => 'button',
'class' => 'dropdown-item',
],
'disable' => [
'label' => 'lang:admin::lang.list.actions.label_disable',
'type' => 'button',
'class' => 'dropdown-item text-danger',
],
],
],
'delete' => [
'label' => 'lang:admin::lang.button_delete',
'class' => 'btn btn-light text-danger',
'data-request-confirm' => 'lang:admin::lang.alert_warning_confirm',
],
];

$config['list']['columns'] = [
'edit' => [
'type' => 'button',
Expand Down
Loading

0 comments on commit 14fc954

Please sign in to comment.