| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace serwin35\AuthenticationLog\Notifications; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Bus\Queueable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Illuminate\Contracts\Queue\ShouldQueue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Illuminate\Notifications\Messages\MailMessage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Illuminate\Notifications\Messages\NexmoMessage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Illuminate\Notifications\Messages\SlackMessage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Illuminate\Notifications\Notification; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use serwin35\AuthenticationLog\AuthenticationLog; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  | class NewDevice extends Notification implements ShouldQueue | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |     use Queueable; | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |      * The authentication log. | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |      * @var \serwin35\AuthenticationLog\AuthenticationLog | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     public $authenticationLog; | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |      * Create a new notification instance. | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |      * @param  \serwin35\AuthenticationLog\AuthenticationLog  $authenticationLog | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     public function __construct(AuthenticationLog $authenticationLog) | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         $this->authenticationLog = $authenticationLog; | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |      * Get the notification's delivery channels. | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |      * @param  mixed  $notifiable | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |     public function via($notifiable) | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |         return $notifiable->notifyAuthenticationLogVia(); | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |      * Get the mail representation of the notification. | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |      * @param  mixed  $notifiable | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |      * @return \Illuminate\Notifications\Messages\MailMessage | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |     public function toMail($notifiable) | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |         return (new MailMessage) | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |             ->subject(trans('authentication-log::messages.subject')) | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |             ->markdown('authentication-log::emails.new', [ | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |                 'account' => $notifiable, | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |                 'time' => $this->authenticationLog->login_at, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |                 'ipAddress' => $this->authenticationLog->ip_address, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |                 'browser' => $this->authenticationLog->user_agent, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |             ]); | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |      * Get the Slack representation of the notification. | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |      * @param  mixed  $notifiable | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |      * @return \Illuminate\Notifications\Messages\SlackMessage | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     public function toSlack($notifiable) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         return (new SlackMessage) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             ->from(config('app.name')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             ->warning() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             ->content(trans('authentication-log::messages.content', ['app' => config('app.name')])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             ->attachment(function ($attachment) use ($notifiable) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                 $attachment->fields([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                     'Account' => $notifiable->email, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                     'Time' => $this->authenticationLog->login_at->toCookieString(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |                     'IP Address' => $this->authenticationLog->ip_address, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 81 |  |  |                     'Browser' => $this->authenticationLog->user_agent, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                                                                
            
                                    
            
            
                | 82 |  |  |                 ]); | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |             }); | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |      * Get the Nexmo / SMS representation of the notification. | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |      * @param  mixed  $notifiable | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |      * @return \Illuminate\Notifications\Messages\NexmoMessage | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     public function toNexmo($notifiable) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         return (new NexmoMessage) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             ->content( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                 trans('authentication-log::messages.content', [ | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 97 |  |  |                     'app' => config('app.name') | 
            
                                                                        
                                                                
            
                                    
            
            
                | 98 |  |  |                 ]) | 
            
                                                                        
                                                                
            
                                    
            
            
                | 99 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 101 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 102 |  |  |  | 
            
                        
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.