fix: update account comment handling
This commit is contained in:
@@ -1,13 +1,47 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
|
||||
use App\Http\Requests\CommentStoreRequest;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Flight;
|
||||
use App\Models\Tour;
|
||||
|
||||
class CommentController extends Controller
|
||||
{
|
||||
public function index()
|
||||
//ثبت نظر برای تور
|
||||
public function storeTour(CommentStoreRequest $request, Tour $tour)
|
||||
{
|
||||
return view('account.comments');
|
||||
$tour->comments()->create([
|
||||
'user_id' => auth()->id(),
|
||||
'body' => $request->validated('body'),
|
||||
'status' => 1, // در انتظار تایید (طبق قرارداد: 1 = پیشنویس/فعال، 2 = منتشرشده)
|
||||
]);
|
||||
|
||||
return back()->with('success', 'نظر شما با موفقیت ثبت شد.');
|
||||
}
|
||||
|
||||
//ثبت نظر برای پرواز
|
||||
public function storeFlight(CommentStoreRequest $request, Flight $flight)
|
||||
{
|
||||
$flight->comments()->create([
|
||||
'user_id' => auth()->id(),
|
||||
'body' => $request->validated('body'),
|
||||
'status' => 1,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'نظر شما با موفقیت ثبت شد.');
|
||||
}
|
||||
|
||||
public function myComments()
|
||||
{
|
||||
$comments = auth()->user()->comments()
|
||||
->with('commentable')
|
||||
->latest()
|
||||
->paginate(10);
|
||||
|
||||
return view('account.comments', compact('comments'));
|
||||
}
|
||||
}
|
||||
|
||||
+5
-10
@@ -5,15 +5,14 @@ namespace App\Http\Requests;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UserPasswordUpdateRequest extends FormRequest
|
||||
class CommentStoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
// return true;
|
||||
return auth('admin')->user()->can('users.change-password');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -24,16 +23,12 @@ class UserPasswordUpdateRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'password' =>
|
||||
'body' =>
|
||||
[
|
||||
'required',
|
||||
'string',
|
||||
'min:8',
|
||||
'confirmed'
|
||||
],
|
||||
'password_confirmation' =>
|
||||
[
|
||||
'required'
|
||||
'min:3',
|
||||
'max:1000'
|
||||
],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user