fix: prevents self approval #8
@ -90,6 +90,9 @@ public function approve(Request $request)
|
|||||||
'artwork_id' => 'required|exists:artworks,id'
|
'artwork_id' => 'required|exists:artworks,id'
|
||||||
]);
|
]);
|
||||||
$artwork = Artwork::find($request->artwork_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)) {
|
if (is_null($artwork->approved_by)) {
|
||||||
$artwork->approved_by = $user->artists->first()->id;
|
$artwork->approved_by = $user->artists->first()->id;
|
||||||
$artwork->save();
|
$artwork->save();
|
||||||
|
@ -68,11 +68,15 @@ class="avatar" data-bs-toggle="tooltip"
|
|||||||
</div>
|
</div>
|
||||||
{{-- End .product-owner --}}
|
{{-- End .product-owner --}}
|
||||||
<div class="action-wrapper py-5 d-flex align-items-center justify-content-center">
|
<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">
|
<form action="/approve-artworks" method="POST" class="approve-artwork-form" name="approve-artwork-{{ $thisArtwork->id}}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
<input name="artwork_id" type="hidden" value="{{ $thisArtwork->id }}">
|
<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>
|
<button type="submit" class="btn btn-gradient btn-medium justify-content-center"><span>Approve and Publish</span></button>
|
||||||
</form>
|
</form>
|
||||||
|
@else
|
||||||
|
<p>You cannot approve your own</p>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user