Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Webkul\Admin\Http\Controllers\Settings\Marketing;

use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Event;
use Illuminate\View\View;
Expand Down Expand Up @@ -80,11 +81,19 @@ public function update(int $id): JsonResponse
*/
public function destroy(int $id): JsonResponse
{
Event::dispatch('settings.marketing.events.delete.before', $id);
$event = $this->eventRepository->findOrFail($id);

$this->eventRepository->delete($id);
if ($event->campaigns->isNotEmpty()) {
return response()->json([
'message' => trans('admin::app.settings.marketing.events.index.delete-failed-associated-campaigns'),
], 422);
}

Event::dispatch('settings.marketing.events.delete.before', $event);

$this->eventRepository->delete($event->id);

Event::dispatch('settings.marketing.events.delete.after', $id);
Event::dispatch('settings.marketing.events.delete.after', $event);

return response()->json([
'message' => trans('admin::app.settings.marketing.events.index.delete-success'),
Expand All @@ -94,20 +103,67 @@ public function destroy(int $id): JsonResponse
/**
* Remove the specified marketing events from storage.
*/
public function massDestroy(MassDestroyRequest $massDestroyRequest): JsonResponse
public function massDestroy(MassDestroyRequest $request): JsonResponse
{
$marketingEvents = $this->eventRepository->findWhereIn('id', $massDestroyRequest->input('indices'));
try {
$events = $this->eventRepository->findWhereIn('id', $request->input('indices', []));

foreach ($marketingEvents as $marketingEvent) {
Event::dispatch('settings.marketing.events.delete.before', $marketingEvent);
$deletedCount = 0;

$this->eventRepository->delete($marketingEvent->id);
$blockedCount = 0;

Event::dispatch('settings.marketing.events.delete.after', $marketingEvent);
}
foreach ($events as $event) {
if (
$event->campaigns
&& $event->campaigns->isNotEmpty()
) {
$blockedCount++;

return response()->json([
'message' => trans('admin::app.settings.marketing.events.index.mass-delete-success'),
]);
continue;
}

Event::dispatch('settings.marketing.events.delete.before', $event);

$this->eventRepository->delete($event->id);

Event::dispatch('settings.marketing.events.delete.after', $event);

$deletedCount++;
}

$statusCode = 200;

switch (true) {
case $deletedCount > 0 && $blockedCount === 0:
$message = trans('admin::app.settings.marketing.events.index.mass-delete-success');

break;

case $deletedCount > 0 && $blockedCount > 0:
$message = trans('admin::app.settings.marketing.events.index.partial-delete-warning');

break;

case $deletedCount === 0 && $blockedCount > 0:
$message = trans('admin::app.settings.marketing.events.index.none-delete-warning');

$statusCode = 400;

break;

default:
$message = trans('admin::app.settings.marketing.events.index.no-selection');

$statusCode = 400;

break;
}

return response()->json(['message' => $message], $statusCode);
} catch (Exception $e) {
return response()->json([
'message' => trans('admin::app.settings.marketing.events.index.mass-delete-failed'),
], 400);
}
}
}
18 changes: 11 additions & 7 deletions packages/Webkul/Admin/src/Resources/lang/ar/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,13 +1114,17 @@
'marketing' => [
'events' => [
'index' => [
'create-btn' => 'إنشاء حدث',
'title' => 'الأحداث',
'create-success' => 'تم إنشاء الحدث بنجاح.',
'update-success' => 'تم تحديث الحدث بنجاح.',
'delete-success' => 'تم حذف الحدث بنجاح.',
'delete-failed' => 'لا يمكن حذف الحدث.',
'mass-delete-success' => 'تم حذف الأحداث بنجاح',
'create-btn' => 'إنشاء حدث',
'title' => 'الأحداث',
'create-success' => 'تم إنشاء الحدث بنجاح.',
'update-success' => 'تم تحديث الحدث بنجاح.',
'delete-success' => 'تم حذف الحدث بنجاح.',
'delete-failed' => 'لا يمكن حذف الحدث.',
'delete-failed-associated-campaigns' => 'لا يمكن حذف الحدث لأنه مرتبط بحملات.',
'mass-delete-success' => 'تم حذف الأحداث بنجاح.',
'partial-delete-warning' => 'تعذر حذف بعض الأحداث لأنها مرتبطة بحملات.',
'none-delete-warning' => 'تعذر حذف أي من الأحداث المحددة لأنها مرتبطة بحملات.',
'no-selection' => 'لم يتم تحديد أي أحداث للحذف.',

'datagrid' => [
'delete' => 'حذف',
Expand Down
18 changes: 11 additions & 7 deletions packages/Webkul/Admin/src/Resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1116,13 +1116,17 @@
'marketing' => [
'events' => [
'index' => [
'create-btn' => 'Create Event',
'title' => 'Events',
'create-success' => 'Event created successfully.',
'update-success' => 'Event updated successfully.',
'delete-success' => 'Event deleted successfully.',
'delete-failed' => 'Event can not be deleted.',
'mass-delete-success' => 'Events deleted successfully',
'create-btn' => 'Create Event',
'title' => 'Events',
'create-success' => 'Event created successfully.',
'update-success' => 'Event updated successfully.',
'delete-success' => 'Event deleted successfully.',
'delete-failed' => 'Event can not be deleted.',
'delete-failed-associated-campaigns' => 'Event can not be deleted, as it is associated with campaigns.',
'mass-delete-success' => 'Events deleted successfully.',
'partial-delete-warning' => 'Some events could not be deleted, as they are associated with campaigns.',
'none-delete-warning' => 'None of the selected events could be deleted, as they are associated with campaigns.',
'no-selection' => 'No events were selected for deletion.',

'datagrid' => [
'delete' => 'Delete',
Expand Down
18 changes: 11 additions & 7 deletions packages/Webkul/Admin/src/Resources/lang/es/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1117,13 +1117,17 @@
'marketing' => [
'events' => [
'index' => [
'create-btn' => 'Crear Evento',
'title' => 'Eventos',
'create-success' => 'Evento creado con éxito.',
'update-success' => 'Evento actualizado con éxito.',
'delete-success' => 'Evento eliminado con éxito.',
'delete-failed' => 'No se puede eliminar el evento.',
'mass-delete-success' => 'Eventos eliminados con éxito',
'create-btn' => 'Crear Evento',
'title' => 'Eventos',
'create-success' => 'Evento creado exitosamente.',
'update-success' => 'Evento actualizado exitosamente.',
'delete-success' => 'Evento eliminado exitosamente.',
'delete-failed' => 'No se puede eliminar el evento.',
'delete-failed-associated-campaigns' => 'No se puede eliminar el evento porque está asociado a campañas.',
'mass-delete-success' => 'Eventos eliminados exitosamente.',
'partial-delete-warning' => 'Algunos eventos no se pudieron eliminar porque están asociados a campañas.',
'none-delete-warning' => 'Ninguno de los eventos seleccionados se pudo eliminar porque están asociados a campañas.',
'no-selection' => 'No se seleccionaron eventos para eliminar.',

'datagrid' => [
'delete' => 'Eliminar',
Expand Down
18 changes: 11 additions & 7 deletions packages/Webkul/Admin/src/Resources/lang/fa/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1119,13 +1119,17 @@
'marketing' => [
'events' => [
'index' => [
'create-btn' => 'ایجاد رویداد',
'title' => 'رویدادها',
'create-success' => 'رویداد با موفقیت ایجاد شد.',
'update-success' => 'رویداد با موفقیت به‌روزرسانی شد.',
'delete-success' => 'رویداد با موفقیت حذف شد.',
'delete-failed' => 'رویداد قابل حذف نیست.',
'mass-delete-success' => 'رویدادها با موفقیت حذف شدند',
'create-btn' => 'ایجاد رویداد',
'title' => 'رویدادها',
'create-success' => 'رویداد با موفقیت ایجاد شد.',
'update-success' => 'رویداد با موفقیت به‌روزرسانی شد.',
'delete-success' => 'رویداد با موفقیت حذف شد.',
'delete-failed' => 'امکان حذف رویداد وجود ندارد.',
'delete-failed-associated-campaigns' => 'رویداد قابل حذف نیست، زیرا با کمپین‌هایی در ارتباط است.',
'mass-delete-success' => 'رویدادها با موفقیت حذف شدند.',
'partial-delete-warning' => 'برخی از رویدادها به دلیل وابستگی به کمپین‌ها قابل حذف نیستند.',
'none-delete-warning' => 'هیچ‌یک از رویدادهای انتخاب شده به دلیل وابستگی به کمپین‌ها قابل حذف نیستند.',
'no-selection' => 'هیچ رویدادی برای حذف انتخاب نشده است.',

'datagrid' => [
'delete' => 'حذف',
Expand Down
18 changes: 11 additions & 7 deletions packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1111,13 +1111,17 @@
'marketing' => [
'events' => [
'index' => [
'create-btn' => 'Adicionar Evento',
'title' => 'Eventos',
'create-success' => 'Evento adicionado com sucesso.',
'update-success' => 'Evento atualizado com sucesso.',
'delete-success' => 'Evento excluído com sucesso.',
'delete-failed' => 'Não é possível excluir o evento.',
'mass-delete-success' => 'Eventos excluídos com sucesso',
'create-btn' => 'Criar Evento',
'title' => 'Eventos',
'create-success' => 'Evento criado com sucesso.',
'update-success' => 'Evento atualizado com sucesso.',
'delete-success' => 'Evento excluído com sucesso.',
'delete-failed' => 'Não foi possível excluir o evento.',
'delete-failed-associated-campaigns' => 'Não foi possível excluir o evento, pois está associado a campanhas.',
'mass-delete-success' => 'Eventos excluídos com sucesso.',
'partial-delete-warning' => 'Alguns eventos não puderam ser excluídos por estarem associados a campanhas.',
'none-delete-warning' => 'Nenhum dos eventos selecionados pôde ser excluído por estarem associados a campanhas.',
'no-selection' => 'Nenhum evento foi selecionado para exclusão.',

'datagrid' => [
'delete' => 'Excluir',
Expand Down
18 changes: 11 additions & 7 deletions packages/Webkul/Admin/src/Resources/lang/tr/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,13 +1118,17 @@
'marketing' => [
'events' => [
'index' => [
'create-btn' => 'Etkinlik Oluştur',
'title' => 'Etkinlikler',
'create-success' => 'Etkinlik başarıyla oluşturuldu.',
'update-success' => 'Etkinlik başarıyla güncellendi.',
'delete-success' => 'Etkinlik başarıyla silindi.',
'delete-failed' => 'Etkinlik silinemedi.',
'mass-delete-success' => 'Etkinlikler başarıyla silindi',
'create-btn' => 'Etkinlik Oluştur',
'title' => 'Etkinlikler',
'create-success' => 'Etkinlik başarıyla oluşturuldu.',
'update-success' => 'Etkinlik başarıyla güncellendi.',
'delete-success' => 'Etkinlik başarıyla silindi.',
'delete-failed' => 'Etkinlik silinemedi.',
'delete-failed-associated-campaigns' => 'Etkinlik, kampanyalarla ilişkili olduğu için silinemiyor.',
'mass-delete-success' => 'Etkinlikler başarıyla silindi.',
'partial-delete-warning' => 'Bazı etkinlikler kampanyalarla ilişkili olduğu için silinemedi.',
'none-delete-warning' => 'Seçilen etkinliklerin hiçbiri kampanyalarla ilişkili olduğu için silinemedi.',
'no-selection' => 'Silmek için herhangi bir etkinlik seçilmedi.',

'datagrid' => [
'delete' => 'Sil',
Expand Down
18 changes: 11 additions & 7 deletions packages/Webkul/Admin/src/Resources/lang/vi/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,13 +1114,17 @@
'marketing' => [
'events' => [
'index' => [
'create-btn' => 'Tạo Sự kiện',
'title' => 'Sự kiện',
'create-success' => 'Sự kiện đã được tạo thành công.',
'update-success' => 'Sự kiện đã được cập nhật thành công.',
'delete-success' => 'Sự kiện đã được xóa thành công.',
'delete-failed' => 'Không thể xóa sự kiện.',
'mass-delete-success' => 'Các sự kiện đã được xóa thành công',
'create-btn' => 'Tạo Sự kiện',
'title' => 'Sự kiện',
'create-success' => 'Tạo sự kiện thành công.',
'update-success' => 'Cập nhật sự kiện thành công.',
'delete-success' => 'Xóa sự kiện thành công.',
'delete-failed' => 'Không thể xóa sự kiện.',
'delete-failed-associated-campaigns' => 'Không thể xóa sự kiện vì có liên kết với chiến dịch.',
'mass-delete-success' => 'Đã xóa sự kiện thành công.',
'partial-delete-warning' => 'Một số sự kiện không thể xóa vì có liên kết với chiến dịch.',
'none-delete-warning' => 'Không sự kiện nào trong số đã chọn được xóa vì có liên kết với chiến dịch.',
'no-selection' => 'Không có sự kiện nào được chọn để xóa.',

'datagrid' => [
'delete' => 'Xóa',
Expand Down
Loading
Loading