Show user's avatar on notifications' index view
MODIFY
app/Notification.php
app/Notification.php
@@ -5,9 +5,13 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
class Notification extends Model {
- protected $fillable = ['space_id', 'action'];
+ protected $fillable = ['space_id', 'user_id', 'action'];
public function space() {
return $this->belongsTo(Space::class);
}
+
+ public function user() {
+ return $this->belongsTo(User::class);
+ }
}

MODIFY
resources/views/notifications/index.blade.php
resources/views/notifications/index.blade.php
<div class="box mt-3">
@foreach ($notifications as $notification)
<div class="box__section row">
- <div class="row__column">{{ __('notifications.' . $notification->action) }}</div>
- <div class="row__column">{{ $notification->created_at->diffForHumans() }}</div>
+ <div class="row__column row__column--compact mr-2" style="width: 25px;">
+ @if ($notification->user)
+ <img class="avatar" src="{{ $notification->user->avatar }}" />
+ @endif
+ </div>
+ <div class="row__column row__column--middle">{{ __('notifications.' . $notification->action) }}</div>
+ <div class="row__column row__column--middle">{{ $notification->created_at->diffForHumans() }}</div>
</div>
@endforeach
</div>

Show user's avatar on notifications' index view