You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 Final fix delete storage link to fix news_images and logs 🆙
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\GuestbookFormRequest;
|
||||
use App\Models\User;
|
||||
use App\Models\User\WebsiteUserGuestbook;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class GuestbookController extends Controller
|
||||
{
|
||||
public function store(User $user, GuestbookFormRequest $request)
|
||||
{
|
||||
$this->validateGuestbookPost($user, $request);
|
||||
|
||||
$user->profileGuestbook()->create([
|
||||
'user_id' => Auth::id(),
|
||||
'message' => $request->input('message'),
|
||||
]);
|
||||
|
||||
return back()->with('success', __('Your message has been posted.'));
|
||||
}
|
||||
|
||||
public function destroy(User $user, WebsiteUserGuestbook $guestbook)
|
||||
{
|
||||
if ($guestbook->user_id !== Auth::id() && $guestbook->profile_id !== $user->id && Auth::user()->rank < (int) setting('min_staff_rank')) {
|
||||
return back()->withErrors([
|
||||
'message' => __('Do do not have permission to delete this message'),
|
||||
]);
|
||||
}
|
||||
|
||||
$guestbook->delete();
|
||||
|
||||
return back()->with('success', __('Your message has been deleted.'));
|
||||
}
|
||||
|
||||
private function validateGuestbookPost(User $user, GuestbookFormRequest $request)
|
||||
{
|
||||
if ($user->id === $request->user()->id) {
|
||||
return $this->redirectWithError(__('You cannot post a message on your own profile.'));
|
||||
}
|
||||
|
||||
$maxAllowedPostCount = in_array(setting('max_guestbook_posts_per_profile'), ['', '0'], true) ? 3 : (int) setting('max_guestbook_posts_per_profile');
|
||||
if ($user->profileGuestbook()->where('user_id', $request->user()->id)->count() >= $maxAllowedPostCount) {
|
||||
return $this->redirectWithError(__('You have already posted :count messages on this profile.', ['count' => $maxAllowedPostCount]));
|
||||
}
|
||||
}
|
||||
|
||||
private function redirectWithError($message)
|
||||
{
|
||||
return back()->withErrors(['message' => $message]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user