New notification page..
This commit is contained in:
87
app/Http/Livewire/Common/Notifications/Exports.php
Normal file
87
app/Http/Livewire/Common/Notifications/Exports.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Common\Notifications;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Notifications\DatabaseNotification;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Exports extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
protected $listeners = [
|
||||
'refreshParent' => '$notifications',
|
||||
];
|
||||
|
||||
public function markRead($notification_id)
|
||||
{
|
||||
$notification = DatabaseNotification::find($notification_id);
|
||||
$data = $notification->getAttribute('data');
|
||||
|
||||
$notification->markAsRead();
|
||||
|
||||
$this->dispatchBrowserEvent('mark-read', [
|
||||
'type' => 'export',
|
||||
'message' => trans('notifications.messages.mark_read', ['type' => $data['file_name']]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function markReadAll()
|
||||
{
|
||||
$notifications = $this->getNotifications();
|
||||
|
||||
foreach ($notifications as $notification) {
|
||||
$notification->markAsRead();
|
||||
}
|
||||
|
||||
$this->dispatchBrowserEvent('mark-read-all', [
|
||||
'type' => 'export',
|
||||
'message' => trans('notifications.messages.mark_read_all', ['type' => trans('general.export')]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$limit = 5;
|
||||
|
||||
$notifications = $this->getNotifications($limit);
|
||||
|
||||
return view('livewire.common.notifications.exports', compact('notifications'));
|
||||
}
|
||||
|
||||
protected function getNotifications($limit = false)
|
||||
{
|
||||
$query = user()->notifications()->unread()
|
||||
->where('type', 'App\Notifications\Common\ExportCompleted')
|
||||
->orWhere('type', 'App\Notifications\Common\ExportFailed');
|
||||
|
||||
if ($limit) {
|
||||
$notifications = $query->paginate($limit);
|
||||
} else {
|
||||
$notifications = $query->get();
|
||||
}
|
||||
|
||||
if ($notifications->items()) {
|
||||
$items = [];
|
||||
|
||||
foreach ($notifications->items() as $key => $notification) {
|
||||
$data = (object) $notification->getAttribute('data');
|
||||
$data->notification_id = $notification->getAttribute('id');
|
||||
|
||||
$items[] = $data;
|
||||
}
|
||||
|
||||
$notifications->setCollection(Collection::make($items));
|
||||
}
|
||||
|
||||
return $notifications;
|
||||
}
|
||||
|
||||
public function paginationView()
|
||||
{
|
||||
return 'vendor.livewire.default';
|
||||
}
|
||||
}
|
28
app/Http/Livewire/Common/Notifications/Imports.php
Normal file
28
app/Http/Livewire/Common/Notifications/Imports.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Common\Notifications;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class Imports extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public function render()
|
||||
{
|
||||
$limit = 5;
|
||||
|
||||
$notifications = user()->notifications()->unread()
|
||||
->where('type', 'App\Notifications\Common\ImportCompleted')
|
||||
->orWhere('type', 'App\Notifications\Common\ImportFailed')
|
||||
->paginate($limit);
|
||||
|
||||
return view('livewire.common.notifications.imports', compact('notifications'));
|
||||
}
|
||||
|
||||
public function paginationView()
|
||||
{
|
||||
return 'vendor.livewire.default';
|
||||
}
|
||||
}
|
13
app/Http/Livewire/Common/Notifications/NewApps.php
Normal file
13
app/Http/Livewire/Common/Notifications/NewApps.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Common\Notifications;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class NewApps extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.common.notifications.new-apps');
|
||||
}
|
||||
}
|
27
app/Http/Livewire/Common/Notifications/Recurring.php
Normal file
27
app/Http/Livewire/Common/Notifications/Recurring.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Common\Notifications;
|
||||
|
||||
use App\Abstracts\Livewire\Document as Component;
|
||||
use Livewire\WithPagination;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Recurring extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public function render()
|
||||
{
|
||||
$limit = 5;
|
||||
$documents = user()->notifications()->unread()->where('type', 'App\Notifications\Sale\Invoice')->paginate($limit);
|
||||
|
||||
$documents->setCollection(Collection::make([]));
|
||||
|
||||
return view('livewire.common.notifications.recurring', compact('documents'));
|
||||
}
|
||||
|
||||
public function paginationView()
|
||||
{
|
||||
return 'vendor.livewire.default';
|
||||
}
|
||||
}
|
78
app/Http/Livewire/Common/Notifications/Reminder.php
Normal file
78
app/Http/Livewire/Common/Notifications/Reminder.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Common\Notifications;
|
||||
|
||||
use App\Abstracts\Livewire\Document as Component;
|
||||
use App\Models\Document\Document;
|
||||
use Livewire\WithPagination;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Notifications\DatabaseNotification;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Reminder extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public function markRead($notification_id)
|
||||
{
|
||||
$notification = DatabaseNotification::find($notification_id);
|
||||
$data = $notification->getAttribute('data');
|
||||
|
||||
$notification->markAsRead();
|
||||
|
||||
$this->dispatchBrowserEvent('mark-read', [
|
||||
'type' => $this->type,
|
||||
'message' => trans('notifications.messages.mark_read', ['type' => $data[$this->type . '_number']]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function markReadAll()
|
||||
{
|
||||
$type = config('type.' . $this->type . '.notification.class');
|
||||
|
||||
$notifications = user()->notifications()->unread()
|
||||
->where('type', $type)
|
||||
->get();
|
||||
|
||||
foreach ($notifications as $notification) {
|
||||
$notification->markAsRead();
|
||||
}
|
||||
|
||||
$this->dispatchBrowserEvent('mark-read-all', [
|
||||
'type' => $this->type,
|
||||
'message' => trans('notifications.messages.mark_read', ['type' => trans_choice('general.' . Str::plural($this->type) , 2)]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$limit = 10;
|
||||
|
||||
$type = config('type.' . $this->type . '.notification.class');
|
||||
|
||||
$documents = user()->notifications()->unread()
|
||||
->where('type', $type)
|
||||
->paginate($limit);
|
||||
|
||||
$items = [];
|
||||
|
||||
foreach ($documents->items() as $key => $document) {
|
||||
$data = $document->getAttribute('data');
|
||||
|
||||
$item = Document::invoice()->where('id', $data['invoice_id'])->first();
|
||||
|
||||
$item->notification_id = $document->getAttribute('id');
|
||||
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
$documents->setCollection(Collection::make($items));
|
||||
|
||||
return view('livewire.common.notifications.reminder', compact('documents'));
|
||||
}
|
||||
|
||||
public function paginationView()
|
||||
{
|
||||
return 'vendor.livewire.default';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user