git add .
git commit "Implement authentication flow and initialize home page hero section"
This commit is contained in:
@@ -2,21 +2,49 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Favorite;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FavoriteController extends Controller
|
||||
{
|
||||
//
|
||||
public function create()
|
||||
public function index()
|
||||
{
|
||||
$favorites=Favorite::with('tour')
|
||||
->where('user_id',auth()->id())
|
||||
->latest()
|
||||
->get();
|
||||
return view('account.users.favorite.index',compact('favorites'));
|
||||
|
||||
}
|
||||
public function store()
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'tour_id'=>[
|
||||
'required',
|
||||
'exists:tours,id'
|
||||
],
|
||||
]);
|
||||
Favorite::firstOrCreate([
|
||||
'user_id' => auth()->id(),
|
||||
'tour_id' => $request->tour_id,
|
||||
]);
|
||||
|
||||
return back()->with(
|
||||
'success',
|
||||
'تور به علاقهمندیها اضافه شد.'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function destroy(Favorite $favorite)
|
||||
{
|
||||
|
||||
}
|
||||
public function destroy()
|
||||
{
|
||||
$favorite->delete();
|
||||
|
||||
return back()->with(
|
||||
'success',
|
||||
'تور از علاقهمندیها حذف شد.'
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user