forked from peter-tharwat/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0aebd4
commit 160317d
Showing
18 changed files
with
425 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,10 +49,15 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" | |
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" | ||
|
||
|
||
|
||
DEFAULT_IMAGE= | ||
DEFAULT_FAVICON= | ||
DEFAULT_AVATAR= | ||
DEFAULT_LOGO= | ||
DEFAULT_WIDE_LOGO= | ||
DEFAULT_COVER= | ||
######### | ||
|
||
DEFAULT_IMAGE="${APP_URL}/images/default/image.jpg" | ||
DEFAULT_IMAGE_FAVICON="${APP_URL}/images/default/favicon.png" | ||
DEFAULT_IMAGE_AVATAR="${APP_URL}/images/default/avatar.png" | ||
DEFAULT_IMAGE_LOGO="${APP_URL}/images/default/logo.png" | ||
DEFAULT_IMAGE_WIDELOGO="${APP_URL}/images/default/wide-logo.png" | ||
DEFAULT_IMAGE_COVER="${APP_URL}/images/default/cover.png" | ||
DEFAULT_IMAGE_NOTIFICATION="${APP_URL}/images/default/notification.png" | ||
|
||
DEFAULT_EMAIL=[email protected] | ||
DEFAULT_PASSWORD=password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
// This class file to define all general functions | ||
namespace App\Helpers; | ||
|
||
class MainHelper { | ||
|
||
|
||
public function notify_user( | ||
$options=[] | ||
){ | ||
$options = array_merge([ | ||
'user_id'=>1, | ||
'message'=>"", | ||
'url'=>"", | ||
'methods'=>['database'], | ||
'image'=>"", | ||
'btn_text'=>"عرض الإشعار" | ||
],$options); | ||
$user = \App\Models\User::where('id',$options['user_id'])->first(); | ||
if($user!=null){ | ||
\App\Models\User::where('email', $user->email )->first()->notify( | ||
new \App\Notifications\GeneralNotification([ | ||
'content'=>[$options['message']], | ||
'url'=>$options['url'], | ||
'btn_text'=>$options['btn_text'], | ||
'methods'=>$options['methods'], | ||
'image'=>$options['image'] | ||
]) | ||
); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
class HelperController extends Controller | ||
{ | ||
public function upload_image(Request $request){ | ||
|
||
$file = $this->store_file([ | ||
'source'=>$request->upload, | ||
'validation'=>"image", | ||
'path_to_save'=>'/uploads/images/', | ||
'type'=>'IMAGE', | ||
'user_id'=>\Auth::user()->id, | ||
'resize'=>[500,1000], | ||
'small_path'=>'small/', | ||
'visibility'=>'PUBLIC', | ||
'file_system_type'=>env('FILESYSTEM_DRIVER'), | ||
/*'watermark'=>true,*/ | ||
'compress'=>'auto' | ||
]); | ||
return [ | ||
'fileName'=>$file['filename'], | ||
'uploaded'=>1, | ||
'url'=>env('STORAGE_URL')."/uploads/images/".$file['filename'] ]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\View\Components\Notifications as NotificationComponent; | ||
class NotificationsController extends Controller | ||
{ | ||
public function notifications_see(Request $request){ | ||
session(['seen_notifications'=>0]); | ||
auth()->user()->unreadNotifications->markAsRead(); | ||
} | ||
|
||
public function notifications_ajax(Request $request){ | ||
|
||
$notifications = \Auth::user()->notifications()->limit(15)->get(); | ||
$not_response = array( | ||
'response' => (new NotificationComponent($notifications))->render(1), | ||
'count_unseen_notifications' => intval($notifications->whereNull('read_at')->count()), | ||
); | ||
$data = [ | ||
'notifications' => [ | ||
'response' => $not_response, | ||
'counter_session' => intval(session('seen_notifications')), | ||
], | ||
'alert' => false, | ||
]; | ||
|
||
if ($data['notifications']['counter_session'] < $not_response['count_unseen_notifications']) | ||
$data['alert'] = true; | ||
|
||
session(['seen_notifications' => $not_response['count_unseen_notifications']]); | ||
return $data; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
class TestController extends Controller | ||
{ | ||
public function index(Request $request) | ||
{ | ||
(new \MainHelper)->notify_user([ | ||
'user_id'=>1, | ||
'message'=>"هذا النص هو مثال لنص يمكن أن يستبدل في نفس المساحة، لقد تم توليد هذا النص من مولد النص العربى، حيث يمكنك أن تولد مثل هذا النص أو العديد من النصوص الأخرى إضافة إلى زيادة عدد الحروف التى يولدها التطبيق.", | ||
'url'=>env("APP_URL"), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Illuminate\Notifications\Notification; | ||
|
||
use NotificationChannels\Telegram\TelegramChannel; | ||
use NotificationChannels\Telegram\TelegramMessage; | ||
|
||
class GeneralNotification extends Notification implements ShouldQueue | ||
{ | ||
use Queueable; | ||
public $tries = 2; | ||
public $timeout = 10; | ||
|
||
public $inline_content; | ||
public $action_url; | ||
public $btn_text; | ||
public $methods; | ||
public $image; | ||
|
||
|
||
|
||
|
||
public function __construct($options=[]){ | ||
|
||
$this->inline_content= implode("\n",$options['content']); | ||
$this->action_url=$options['url']; | ||
$this->btn_text=$options['btn_text']; | ||
$this->methods=$options['methods']; | ||
$this->image=$options['image']; | ||
} | ||
|
||
public function via($notifiable){ | ||
|
||
return $this->methods; | ||
|
||
} | ||
|
||
public function toMail($notifiable){ | ||
|
||
return (new MailMessage) | ||
//->level($this->level) | ||
->subject("لديك إشعار جديد") | ||
->greeting("مرحباً") | ||
->line($this->inline_content) | ||
->action($this->btn_text, $this->action_url); | ||
|
||
} | ||
public function toDatabase($notifiable){ | ||
|
||
$content=$this->inline_content; | ||
return [ | ||
'message'=>'<a href="'.$this->action_url.'">'.$content.'</a>', | ||
'image'=>$this->image, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Illuminate\View\Component; | ||
|
||
class Notifications extends Component | ||
{ | ||
/** | ||
* Create a new component instance. | ||
* | ||
* @return void | ||
*/ | ||
public $notifications; | ||
public function __construct($notifications) | ||
{ | ||
$this->notifications=$notifications; | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
* | ||
* @return \Illuminate\Contracts\View\View|\Closure|string | ||
*/ | ||
public function render($render=null) | ||
{ | ||
$notifications=$this->notifications; | ||
return (null!==$render)?view('components.notifications',compact('notifications'))->render():view('components.notifications'); | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.