fix: prevents self approval
This commit is contained in:
parent
b14a77762d
commit
e83f51885b
@ -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();
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user