fix: prevents self approval #8

Merged
pcouture merged 1 commits from fix/prevent_self_approval into master 2024-01-14 12:22:16 -05:00
2 changed files with 7 additions and 0 deletions

View File

@ -90,6 +90,9 @@ public function approve(Request $request)
'artwork_id' => 'required|exists:artworks,id'
]);
$artwork = Artwork::find($request->artwork_id);
if ($artwork->artist_id == $user->artists->first()->id) {
return redirect('/approve-artwork');
}
if (is_null($artwork->approved_by)) {
$artwork->approved_by = $user->artists->first()->id;
$artwork->save();

View File

@ -68,11 +68,15 @@ class="avatar" data-bs-toggle="tooltip"
</div>
{{-- End .product-owner --}}
<div class="action-wrapper py-5 d-flex align-items-center justify-content-center">
@if (auth()->user()->artists->first()->id != $thisArtwork->artist_id)
<form action="/approve-artworks" method="POST" class="approve-artwork-form" name="approve-artwork-{{ $thisArtwork->id}}" enctype="multipart/form-data">
@csrf
<input name="artwork_id" type="hidden" value="{{ $thisArtwork->id }}">
<button type="submit" class="btn btn-gradient btn-medium justify-content-center"><span>Approve and Publish</span></button>
</form>
@else
<p>You cannot approve your own</p>
@endif
</div>
</div>
</div>