Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/HE-Arc/Timeliner into main
Browse files Browse the repository at this point in the history
  • Loading branch information
theory-of-evrth committed Dec 18, 2024
2 parents a2ca903 + 8196bd3 commit f2bfb05
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
14 changes: 13 additions & 1 deletion timeliner/app/Http/Controllers/TimelineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@

class TimelineController extends Controller
{
public function timelinesWithOwnership()
{
$timelines = Timeline::all();

return $timelines->filter(function ($timeline) {
return Auth::check() && Ownership::find($timeline->id . Auth::user()->id);
});
}

public function index()
{
$timelines = Timeline::all();
return view('index', ['timelines' => $timelines]);

$timelinesWithOwnership = $this->timelinesWithOwnership();

return view('index', ['timelines' => $timelines, 'timelinesWithOwnership' => $timelinesWithOwnership]);
}

public function show($id)
Expand Down
3 changes: 3 additions & 0 deletions timeliner/resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<div class="p-6 text-gray-900 dark:text-gray-100">
{{ __("You're logged in!") }}
</div>
<div class="p-6 text-gray-900 dark:text-gray-100">
@include("timeline.partials.timelinelist", $timelines)
</div>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p class="card-text" style="white-space: pre-wrap">{{ $comment->comment }}</p>

@auth
@if ($comment->user_id == Auth::id())
@if ($comment->user_id == Auth::id() || $isOwner)
<button class="btn btn-primary bi bi-pencil toggle-button" data-target="editComment{{ $comment->id }}"> Edit Comment</button>
<form id="editComment{{ $comment->id }}" class="hidden" action="{{ route('comment.update', $comment->id) }}" method="POST">
@csrf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@php
use App\Models\Ownership;
@endphp
<div class="timeline-for-list-template">
<div class="row align-items-stretch d-flex">
<div class="col-11 p-0">
Expand All @@ -18,7 +15,7 @@
</div>

@auth
@if (Ownership::find($timeline->id . Auth::user()->id))
@if($timelinesWithOwnership->contains($timeline->id))
<form class="d-flex align-items-stretch mb-4" action="{{ route('timeline.destroy', $timeline->id) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete this timeline?');">
@csrf
@method('DELETE')
Expand Down

0 comments on commit f2bfb05

Please sign in to comment.