dealhub/app/Http/Controllers/Admin/DealController.php
kusowl 38d429e5d5 bugfix: improvemnets in UI, misc bugfixes
add tooltip to sidebar buttons
remove profile for admin
fix mobile menu not opening in home page
fix deal image input modal size in mobile view
make image scrollable in input modal
fix explore page filters are not clickable when recent search is maxed
out
change UI for the recent searches
add seeder for categories
improve deal card ui in broker dashboard
2026-01-29 14:02:39 +05:30

57 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Deal;
use Illuminate\Support\Facades\Log;
class DealController extends Controller
{
public function index()
{
return view('dashboards.admin.deals.index')
->with('pendingDeals', $this->pendingDeals())
->with('activeDeals', $this->activeDeals());
}
public function approve(Deal $deal)
{
try {
\DB::transaction(function () use ($deal) {
$deal->active = true;
$deal->save();
});
return back()->with('success', 'Deal activated successfully.');
} catch (\Throwable $e) {
Log::error('Deal activation Failed: ', [$e->getMessage(), $e->getTrace()]);
return back()->with('error', 'Something went wrong.');
}
}
public function reject(Deal $deal)
{
try {
$deal->delete();
return back()->with('success', 'Deal deleted successfully.');
} catch (\Throwable $e) {
Log::error('Deal deletion Failed: ', [$e->getMessage(), $e->getTrace()]);
return back()->with('error', 'Something went wrong.');
}
}
private function pendingDeals()
{
return Deal::where('active', false)->get();
}
private function activeDeals()
{
return Deal::where('active', true)->get();
}
}