This repository was archived by the owner on Feb 20, 2024. It is now read-only.
-
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
Showing
9 changed files
with
602 additions
and
283 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 |
---|---|---|
|
@@ -24,3 +24,6 @@ MAIL_PORT=2525 | |
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
|
||
# notify | ||
SLACK_WEBHOOK_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
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,52 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use App\Log; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Messages\SlackMessage; | ||
use Illuminate\Notifications\Notification; | ||
|
||
class LogCreated extends Notification | ||
{ | ||
use Queueable; | ||
protected $log = null; | ||
|
||
/** | ||
* Create a new notification instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Log $log) | ||
{ | ||
$this->log = $log; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return ['slack']; | ||
} | ||
|
||
public function toSlack($notifable) | ||
{ | ||
$log = $this->log; | ||
|
||
return (new SlackMessage) | ||
->success() | ||
->content(sprintf('%s 的工作日誌', $log->user->name)) | ||
->attachment(function ($attachment) use ($log) { | ||
$attachment | ||
->title($log->created_at->format('Y-m-d')) | ||
->fields([ | ||
'今天完成事項' => $log->done, | ||
'明日預計事項' => $log->future, | ||
]); | ||
}); | ||
} | ||
} |
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
Oops, something went wrong.