Skip to content

Commit

Permalink
new class
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Jul 19, 2022
1 parent ec430eb commit 671522d
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 9 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Modules/Menu/Resources/MenuGroupsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MenuGroupsResource extends Resource
{
public $model = MenusGroups::class;
public $icon = "bx bx-bookmarks";
public $group = "Settings";
public $group = "Menus";

public function rows()
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Menu/Resources/MenuResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MenuResource extends Resource
{
public $model = Menus::class;
public $icon = "bx bx-menu";
public $group = "Settings";
public $group = "Menus";

public function rows()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class NotificationsServiceProvider extends ServiceProvider
*/
public function boot()
{
Core::registerResource(NotificationsResource::class);
Core::registerResource(TemplatesResource::class);
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));

Core::loadResources($this->moduleName);
}

/**
Expand Down
81 changes: 81 additions & 0 deletions Modules/Notifications/Resources/NotificationsLogsResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace Modules\Notifications\Resources;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;
use Modules\Base\Helpers\Resources\Alert;
use Modules\Base\Helpers\Resources\Row;
use Modules\Base\Helpers\Resources\Resource;
use Modules\Notifications\Entities\NotificationsLogs;
use Modules\Notifications\Helpers\SendNotification;
use Modules\Notifications\Entities\UserNotification;

class NotificationsLogsResource extends Resource
{
public $model = NotificationsLogs::class;
public $icon = "bx bx-history";
public $group = "Notifications";

public function rows()
{
$this->canCreate = false;
$this->canEdit = false;
return [
Row::make('id')->label(__('Id '))->create(false)->edit(false)->get(),

Row::make('model_type')->list(false)->view(false)->label(__('Model Type '))->get(),

Row::make('model_id')->type('hasOne')->options([])->label(__('User'))->get(),

Row::make('title')->label(__('Title '))->get(),

Row::make('description')->list(false)->label(__('Description '))->get(),

Row::make('type')->list(false)->label(__('Type '))->get(),
Row::make('provider')->label(__('Provider'))->get(),
Row::make('created_at')->label(__('Date'))->type('datetime')->get(),
];
}

public function afterLoad($data)
{
foreach ($data['data'] as $item) {
if ($item['model_id'] && $item['model_type']) {
$item['model_id'] = $item['model_type']::find($item['model_id']);
} else {
$item['model_id'] = "";
}
$item['template_id'] = NotifiactionsTemplates::find($item['template_id']);
}

return $data;
}

public function beforeStore(Request $request)
{
$local = Cookie::get('lang');
if (empty($local)) {
$local = "en";
}
$getRequest = $request->all();
$getRequest['model_type'] = $getRequest['model_type']['id'];
if ($getRequest['model_id']) {
$getRequest['model_id'] = $getRequest['model_id']['id'];
} else {
$getRequest['model_id'] = null;
}

SendNotification::make($getRequest['template_id']['title'][$local])
->template($getRequest['template_id']['key'])
->database(true)
->privacy($getRequest['privacy'])
->model($getRequest['model_type'])
->model_id($getRequest['model_id'])
->provider([$request->get('provider')])
->lang($local)
->send();

return Alert::make(__());
}
}
4 changes: 2 additions & 2 deletions Modules/Notifications/Resources/NotificationsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
class NotificationsResource extends Resource
{
public $model = UserNotification::class;
public $icon = "bx bx-menu";
public $group = "Settings";
public $icon = "bx bxs-bell";
public $group = "Notifications";

public function rows()
{
Expand Down
4 changes: 2 additions & 2 deletions Modules/Notifications/Resources/TemplatesResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
class TemplatesResource extends Resource
{
public $model = NotifiactionsTemplates::class;
public $icon = "bx bx-menu";
public $group = "Settings";
public $icon = "bx bxs-notification";
public $group = "Notifications";

public function rows()
{
Expand Down
1 change: 0 additions & 1 deletion Modules/Settings/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public function settingsSave(Request $request)
"site_location" => "required|string",
"site_currency" => "required|string",
"site_language" => "required|string",
"sap_functionality" => "required",
];
$validator = Validator::make($request->all(), $rules);
$validator->validate();
Expand Down
Binary file added public/placeholder.webp
Binary file not shown.
2 changes: 2 additions & 0 deletions resources/js/Components/Themes/Main/Aside.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@
<span class="ml-1 rtl:mr-1" v-if="!menu.lang">{{ menu.title }}</span>
<span class="ml-1 rtl:mr-1" v-else>{{ trans(menu.lang) }}</span>
</a>

</li>
<div
class="mt-6 border-b dark:border-gray-700"
v-if="key !== $page.props.data.menu.length - 1"
></div>
<br>
</ul>
</div>
</aside>
Expand Down

0 comments on commit 671522d

Please sign in to comment.