displaying posts in a user's profile
This commit is contained in:
parent
59752e549f
commit
66da68f5c8
@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Note;
|
||||
|
||||
use App\Types\TypeActor;
|
||||
|
||||
@ -52,6 +53,11 @@ class Actor extends Model
|
||||
return $this->belongsTo (User::class);
|
||||
}
|
||||
|
||||
public function posts ()
|
||||
{
|
||||
return $this->hasMany (Note::class, "actor_id")->orderBy ("created_at", "desc");
|
||||
}
|
||||
|
||||
public function create_from_user (User $user)
|
||||
{
|
||||
$data = TypeActor::create_from_user ($user);
|
||||
|
33
resources/views/components/comment_block.blade.php
Normal file
33
resources/views/components/comment_block.blade.php
Normal file
@ -0,0 +1,33 @@
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route ('users.show', [ 'user_name' => $actor->local_actor_id ]) }}">
|
||||
<p>
|
||||
<b>{{ $actor->name }}</b>
|
||||
</p>
|
||||
</a>
|
||||
<a href="{{ route ('users.show', [ 'user_name' => $actor->local_actor_id ]) }}">
|
||||
<p>
|
||||
@if ($actor->user)
|
||||
<img loading="lazy" src="{{ $actor->user->avatar }}" class="pfp-fallback" width="50">
|
||||
@else
|
||||
<img loading="lazy" src="{{ $actor->icon }}" class="pfp-fallback" width="50">
|
||||
@endif
|
||||
</p>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<b>
|
||||
<time>{{ Carbon\Carbon::parse ($post->created_at)->diffForHumans () }}</time>
|
||||
</b>
|
||||
</p>
|
||||
<p>
|
||||
{!! $post->content !!}
|
||||
</p>
|
||||
<p>
|
||||
@foreach ($post->attachments as $attachment)
|
||||
<img loading="lazy" src="{{ $attachment->url }}" alt="{{ $attachment->name }}" width="100">
|
||||
@endforeach
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
@ -265,24 +265,24 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($user != null)
|
||||
<div id="comments" class="friends">
|
||||
<div class="heading">
|
||||
<h4>{{ $actor->preferredUsername }}'s Friends Comments</h4>
|
||||
</div>
|
||||
<div class="inner">
|
||||
<p>
|
||||
<b>
|
||||
Displaying <span class="count">0</span> of <span class="count">0</span> comments (<a href="#">View all</a> | <a href="#">Add Comment</a>)
|
||||
</b>
|
||||
</p>
|
||||
|
||||
<table class="comments-table" cellspacing="0" cellpadding="3" bordercollor="#ffffff" border="1">
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="comments" class="friends">
|
||||
<div class="heading">
|
||||
<h4>{{ $actor->preferredUsername }}'s Posts</h4>
|
||||
</div>
|
||||
@endif
|
||||
<div class="inner">
|
||||
<p>
|
||||
<b>{{ $actor->preferredUsername }} has <span class="count">{{ count ($actor->posts) }}</span> posts.</b>
|
||||
</p>
|
||||
|
||||
<table class="comments-table" cellspacing="0" cellpadding="3" bordercollor="#ffffff" border="1">
|
||||
<tbody>
|
||||
@foreach ($actor->posts as $post)
|
||||
<x-comment_block :actor="$actor" :post="$post" />
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user