Fix missing enums and dashboard variables
- Add RoleEnum::MANAGER case - Add OrderStatusEnum with all statuses and getLabel() method - Fix HomeController::index() to pass all required view variables Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@@ -13,7 +14,48 @@ class HomeController extends Controller
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('index');
|
||||
$summaryPrice = DB::table('auto_orders')
|
||||
->whereNotNull('cost')
|
||||
->sum('cost')
|
||||
+ DB::table('estate_orders')
|
||||
->whereNotNull('cost')
|
||||
->sum('cost');
|
||||
|
||||
$autoOrders = DB::table('auto_orders')->count();
|
||||
$estateOrders = DB::table('estate_orders')->count();
|
||||
|
||||
$recentOrders = collect(
|
||||
DB::table('auto_orders')->latest()->limit(5)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'auto_']))
|
||||
)->merge(
|
||||
DB::table('estate_orders')->latest()->limit(5)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'estate_']))
|
||||
)->sortByDesc('created_at')->take(10)->values();
|
||||
|
||||
$forModerate = collect(
|
||||
DB::table('auto_orders')->where('status', 'moderated')->latest()->limit(10)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'auto_']))
|
||||
)->merge(
|
||||
DB::table('estate_orders')->where('status', 'moderated')->latest()->limit(10)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'estate_']))
|
||||
)->sortByDesc('updated_at')->take(10)->values();
|
||||
|
||||
$actions = DB::table('tracking_actions')->latest()->limit(20)->get();
|
||||
|
||||
$appraiserChart = [[], []];
|
||||
$appraisers = DB::table('users')->where('role', 'appraiser')->get();
|
||||
foreach ($appraisers as $appraiser) {
|
||||
$appraiserChart[0][] = $appraiser->name;
|
||||
$count = DB::table('auto_orders')->where('appraiser_id', $appraiser->id)->count()
|
||||
+ DB::table('estate_orders')->where('appraiser_id', $appraiser->id)->count();
|
||||
$appraiserChart[1][] = $count;
|
||||
}
|
||||
|
||||
return view('index', compact(
|
||||
'summaryPrice',
|
||||
'autoOrders',
|
||||
'estateOrders',
|
||||
'recentOrders',
|
||||
'forModerate',
|
||||
'actions',
|
||||
'appraiserChart'
|
||||
));
|
||||
}
|
||||
|
||||
public function lang($locale)
|
||||
|
||||
Reference in New Issue
Block a user