Fix customer property: add ordered_customer as customer alias in queries
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ class AutoController extends Controller
|
|||||||
$filters = $request->only(['search', 'period', 'status', 'appraiser', 'diller', 'purpose']);
|
$filters = $request->only(['search', 'period', 'status', 'appraiser', 'diller', 'purpose']);
|
||||||
$size = $request->get('size', 20);
|
$size = $request->get('size', 20);
|
||||||
|
|
||||||
$query = DB::table('auto_orders')->orderByDesc('id');
|
$query = DB::table('auto_orders')->selectRaw('*, ordered_customer as customer')->orderByDesc('id');
|
||||||
|
|
||||||
if (!empty($filters['search'])) {
|
if (!empty($filters['search'])) {
|
||||||
$s = '%' . $filters['search'] . '%';
|
$s = '%' . $filters['search'] . '%';
|
||||||
@@ -71,7 +71,7 @@ class AutoController extends Controller
|
|||||||
|
|
||||||
public function show($order)
|
public function show($order)
|
||||||
{
|
{
|
||||||
$order = DB::table('auto_orders')->find($order);
|
$order = DB::table('auto_orders')->selectRaw('*, ordered_customer as customer')->find($order);
|
||||||
$members = DB::table('order_members')->where('order_id', $order->id ?? 0)->where('order_type', 'auto_')->get();
|
$members = DB::table('order_members')->where('order_id', $order->id ?? 0)->where('order_type', 'auto_')->get();
|
||||||
$appraisers = DB::table('users')->where('role', 'appraiser')->where('status', 'active')->get();
|
$appraisers = DB::table('users')->where('role', 'appraiser')->where('status', 'active')->get();
|
||||||
$isAppraisers = $members->where('user_id', auth()->id())->count() > 0;
|
$isAppraisers = $members->where('user_id', auth()->id())->count() > 0;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class EstateController extends Controller
|
|||||||
$filters = $request->only(['search', 'period', 'status', 'appraiser', 'diller', 'purpose']);
|
$filters = $request->only(['search', 'period', 'status', 'appraiser', 'diller', 'purpose']);
|
||||||
$size = $request->get('size', 20);
|
$size = $request->get('size', 20);
|
||||||
|
|
||||||
$query = DB::table('estate_orders')->orderByDesc('id');
|
$query = DB::table('estate_orders')->selectRaw('*, ordered_customer as customer')->orderByDesc('id');
|
||||||
|
|
||||||
if (!empty($filters['search'])) {
|
if (!empty($filters['search'])) {
|
||||||
$s = '%' . $filters['search'] . '%';
|
$s = '%' . $filters['search'] . '%';
|
||||||
@@ -70,7 +70,7 @@ class EstateController extends Controller
|
|||||||
|
|
||||||
public function show($order)
|
public function show($order)
|
||||||
{
|
{
|
||||||
$order = DB::table('estate_orders')->find($order);
|
$order = DB::table('estate_orders')->selectRaw('*, ordered_customer as customer')->find($order);
|
||||||
$members = DB::table('order_members')->where('order_id', $order->id ?? 0)->where('order_type', 'estate_')->get();
|
$members = DB::table('order_members')->where('order_id', $order->id ?? 0)->where('order_type', 'estate_')->get();
|
||||||
$appraisers = DB::table('users')->where('role', 'appraiser')->where('status', 'active')->get();
|
$appraisers = DB::table('users')->where('role', 'appraiser')->where('status', 'active')->get();
|
||||||
$isAppraisers = $members->where('user_id', auth()->id())->count() > 0;
|
$isAppraisers = $members->where('user_id', auth()->id())->count() > 0;
|
||||||
|
|||||||
@@ -25,15 +25,15 @@ class HomeController extends Controller
|
|||||||
$estateOrders = DB::table('estate_orders')->count();
|
$estateOrders = DB::table('estate_orders')->count();
|
||||||
|
|
||||||
$recentOrders = collect(
|
$recentOrders = collect(
|
||||||
DB::table('auto_orders')->latest()->limit(5)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'auto_']))
|
DB::table('auto_orders')->selectRaw('*, ordered_customer as customer')->latest()->limit(5)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'auto_']))
|
||||||
)->merge(
|
)->merge(
|
||||||
DB::table('estate_orders')->latest()->limit(5)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'estate_']))
|
DB::table('estate_orders')->selectRaw('*, ordered_customer as customer')->latest()->limit(5)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'estate_']))
|
||||||
)->sortByDesc('created_at')->take(10)->values();
|
)->sortByDesc('created_at')->take(10)->values();
|
||||||
|
|
||||||
$forModerate = collect(
|
$forModerate = collect(
|
||||||
DB::table('auto_orders')->where('status', 'moderated')->latest()->limit(10)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'auto_']))
|
DB::table('auto_orders')->selectRaw('*, ordered_customer as customer')->where('status', 'moderated')->latest()->limit(10)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'auto_']))
|
||||||
)->merge(
|
)->merge(
|
||||||
DB::table('estate_orders')->where('status', 'moderated')->latest()->limit(10)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'estate_']))
|
DB::table('estate_orders')->selectRaw('*, ordered_customer as customer')->where('status', 'moderated')->latest()->limit(10)->get()->map(fn($o) => (object)array_merge((array)$o, ['type' => 'estate_']))
|
||||||
)->sortByDesc('updated_at')->take(10)->values();
|
)->sortByDesc('updated_at')->take(10)->values();
|
||||||
|
|
||||||
$actions = DB::table('tracking_actions')->latest()->limit(20)->get();
|
$actions = DB::table('tracking_actions')->latest()->limit(20)->get();
|
||||||
|
|||||||
Reference in New Issue
Block a user