polishing
This commit is contained in:
@@ -13,6 +13,10 @@ class DynamicResource extends BaseResource
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return parent::toArray($request);
|
||||
$result = parent::toArray($request);
|
||||
if($this->ledgers){
|
||||
$result['ledgers'] = LedgerResource::collection($this->ledgers);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,8 @@ class Chat extends Model
|
||||
{
|
||||
return $this->hasMany(Message::class);
|
||||
}
|
||||
|
||||
public function getSubjectUrlAttribute(): string {
|
||||
return $this->chatable?->url ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,8 @@ class Dynamic extends Model
|
||||
{
|
||||
return 'uuid';
|
||||
}
|
||||
|
||||
public function getUrlAttribute(): string {
|
||||
return route('dynamics.show', $this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,4 +55,8 @@ class Ledger extends Model
|
||||
{
|
||||
return 'uuid';
|
||||
}
|
||||
|
||||
public function getUrlAttribute(): string {
|
||||
return route('dynamics.ledgers.show', $this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,4 +41,8 @@ class Message extends Model
|
||||
{
|
||||
return $this->morphMany(Media::class, 'mediable');
|
||||
}
|
||||
|
||||
public function getSubjectUrlAttribute(): string {
|
||||
return $this->subject->url ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Chat;
|
||||
use App\Models\Message;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\WebPush\WebPushChannel;
|
||||
@@ -36,12 +38,24 @@ class NewActivityNotification extends Notification
|
||||
*/
|
||||
public function toWebPush(object $notifiable): WebPushMessage
|
||||
{
|
||||
return (new WebPushMessage)
|
||||
|
||||
$result = (new WebPushMessage)
|
||||
->title('New Activity')
|
||||
->icon('/apple-touch-icon.png')
|
||||
->body($this->activity['content'])
|
||||
->action('View', 'view')
|
||||
->data(['url' => $this->activity['url']]);
|
||||
|
||||
switch (get_class($this->activity)) {
|
||||
case Message::class:
|
||||
/** @var Chat $chat */
|
||||
$chat = $this->activity->chat;
|
||||
|
||||
$result->data(['url' => $chat->subjectUrl]);
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user