78a3b1d63d
git commit "Add admin management search sort and permission structure preparation"
45 lines
927 B
PHP
45 lines
927 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Favorite;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FavoriteController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$withoutHero=true;
|
|
|
|
$favorites = Favorite::with('favoritable')
|
|
->where('user_id', auth()->id())
|
|
->latest()
|
|
->get();
|
|
|
|
return view('account.users.favorite.index',compact('withoutHero','favorites'));
|
|
} public function store(Request $request)
|
|
{
|
|
Favorite::firstOrCreate([
|
|
'user_id' => auth()->id(),
|
|
'favoritable_type' => $request->type,
|
|
'favoritable_id' => $request->id,
|
|
]);
|
|
|
|
|
|
return back();
|
|
}
|
|
|
|
|
|
public function destroy(Favorite $favorite)
|
|
{
|
|
|
|
$favorite->delete();
|
|
|
|
return back()->with(
|
|
'success',
|
|
'تور از علاقهمندیها حذف شد.'
|
|
);
|
|
|
|
}
|
|
}
|