Laravel Raw paginate request; unhandled eloquent object request
select '0000-00-00' as date, 'Opening Balance' as narration, (SELECT debit FROM `account_sub_journal` where id=1)as debit, (SELECT credit FROM `account_sub_journal` where id=1)as credit, '0' as transaction_entry_id,'0' as account_sub_journal_id UNION SELECT * FROM `ledgertransactions` where account_sub_journal_id = 1 and `date` BETWEEN '2014-04-01' and '2014-04-10'
I am currently doing this as a static function in the model. I couldnt paginate this as laravel says it is not an object
public static function ledgerbook_to($account_id,$date){
$book = DB::select( DB::raw("SELECT '0000-00-00' AS DATE, 'Opening Balance' AS narration, (SELECT debit FROM `account_sub_journal` WHERE id =1) AS debit, (SELECT credit FROM `account_sub_journal` WHERE id = :account_id) AS credit, '0' AS transaction_entry_id, '0' AS account_sub_journal_id UNION SELECT * FROM `ledgertransactions` WHERE account_sub_journal_id =:account_id_t and `date` <= :date_to "), array(
'account_id' => $account_id,'account_id_t' => $account_id,'date_to' => $date));
return $book;
}
I could combine this if at least solve the below query in an eloquent manner.
SELECT '0000-00-00' AS DATE, 'Opening Balance' AS narration, (SELECT debit FROM `account_sub_journal` WHERE id =1) AS debit, (SELECT credit FROM `account_sub_journal` WHERE id =1) AS credit, '0' AS transaction_entry_id, '0' AS account_sub_journal_id
Thank you for your support.
0
source to share
1 answer
You can create manual pagination links using something like this:
$pagination = Paginator::make($book, count($book), 5);
Then you can use something like this:
echo $pagination->links();
Or ( Blade
):
{{ $pagination->links() }}
Check out the documentation to learn more about creating manual pagination.
+3
source to share