Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

sorting - Laravel collections order and sort works locally but not on server

I’ve 2 collections in which first one has order by receipt number and merged this with transactions collection. And applied sortBy transaction date for the whole new collection. This works perfectly in my local but doesn’t work in prod server. Anyone ideas please?

$payments = [];
$transactions = Transaction::whereBetween('transaction_date', $date_range)
    ->forBranch($this->user->branch);
if ($transaction_type != 'both') {
    $transactions->where('transaction_type', $transaction_type);
}
if ($transaction_type != 'expense') {
    $payments = StudentPayment::whereBetween('receipt_date', $date_range)
        ->forBranch($this->user->branch)
        ->orderBy('receipt_number')
        ->get()
        ->map(function ($payment) {
            return [
                'id'                => $payment->id,
                'transaction_type'  => 'income',
                'amount'            => $payment->paid_amount,
                'purpose'           => 'Receipt #' . $payment->receipt_number,
                'transaction_date'  => $payment->receipt_date,
                'tag'               => 'all'
            ];
        });
}
$transactions = collect($payments)
    ->merge(collect($transactions->get()))
    ->sortBy('transaction_date')      // If I remove this, it sorts perfectly in server also but I need to sort by transaction date
    ->values();
question from:https://stackoverflow.com/questions/65899151/laravel-collections-order-and-sort-works-locally-but-not-on-server

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...