logo
down
shadow

Laravel-4 Pagination in Query Builder with form inputs


Laravel-4 Pagination in Query Builder with form inputs

By : Zoli02
Date : November 17 2020, 01:00 AM
like below fixes the issue Got a question if anyone can help out. , Yes, here's how I do it:
code :
$orderBy = Input::get('orderBy', 'created_at');
$order   = Input::get('order', 'DESC');
$limit   = Input::get('limit', 100);
$name    = Input::get('name', '');

$result = DB::table()
    ->where('name', 'LIKE', '%' . $name . '%')
    ->orderBy($orderBy, $order)
    ->paginate($limit);


Share : facebook icon twitter icon
Laravel-4 Pagination in Query Builder

Laravel-4 Pagination in Query Builder


By : Sarah McConville
Date : November 22 2020, 11:12 AM
hope this fix your issue How to enable pagination in laravel-4.1 when using query builder.
code :
public static function getTransactions( $accountCode ) {
        $accountId = Account::getAccountId( $accountCode );
        $object = DB::table('transactions')
            ->orderBy('transactionId', 'ASC')
            ->where('fkAccountId', $accountId)
            ->where('fkUserId', Auth::user()->userId);
            ->paginate(10);

        return $object;
    }
echo $object->links(); //links
Laravel 4 - Query Builder - not able to use pagination and where clausole

Laravel 4 - Query Builder - not able to use pagination and where clausole


By : Rajiv
Date : March 29 2020, 07:55 AM
this will help the problem is that assigning the values to the variable remove the ->get() and replace with paginate
code :
 $data['invoices'] = $invoice_query->paginate(1);
If using a query builder as to what in the form of its laravel?

If using a query builder as to what in the form of its laravel?


By : Shruti
Date : March 29 2020, 07:55 AM
like below fixes the issue Using this work. Finally, with the above query can be solved with the concept query to query in laravel.
code :
$users = $this->db->getTable('users')
            ->select('users.status_employee_id',
                     'users.id',
                     'users.username',
                     'users.email',
                     'users.created',
                     'users.modified',
                     'users.flag_delete',
                     'employee_attributes.unit_code',
                     'employee_attributes.position_code',
                     'employee_attributes.begin_date',
                     'employee_attributes.end_date',
                     'contactnumber.contact_id as phone_number',
                     'contactmobile.contact_id as cell_number',
                     'contactemail.contact_id as email'
                    )
            ->join('status_employees', 'users.status_employee_id', '=', 'status_employees.id')
            ->join('people', 'status_employees.person_id', '=', 'people.id')
            ->join('employee_attributes', 'users.status_employee_id', '=', 'employee_attributes.status_employee_id')
            ->leftJoin('contacts AS contactnumber', function($join)
                     {
                         $join->on('people.id', '=', 'contactnumber.person_id');
                         $join->on('contactnumber.contact_type','=', DB::raw("'Work Telephone'"));
                     })
             ->leftJoin('contacts AS contactmobile', function($join)
                     {
                          $join->on('people.id', '=', 'contactmobile.person_id');
                          $join->on('contactmobile.contact_type','=', DB::raw("'Mobile'"));
                     })
              ->leftJoin('contacts AS contactemail', function($join)
                     {
                         $join->on('people.id', '=', 'contactemail.person_id');
                         $join->on('contactemail.contact_type','=', DB::raw("'Email'"));
                     })

            ->where(function ($query) use ($begin_date, $end_date) {
                $query->where('employee_attributes.begin_date', $begin_date)
                      ->orWhere('employee_attributes.end_date', $end_date);
            })
            ->groupby('users.status_employee_id',
                      'users.id',
                      'users.username',
                      'users.email',
                      'users.created',
                      'users.modified',
                      'users.flag_delete',
                      'employee_attributes.unit_code',
                      'employee_attributes.position_code',
                      'employee_attributes.begin_date',
                      'employee_attributes.end_date',
                      'contactnumber.contact_id',
                      'contactmobile.contact_id',
                      'contactemail.contact_id'
                    )
            ->get();
I want to use pagination with laravel Raw query builder

I want to use pagination with laravel Raw query builder


By : Matt Mitchell
Date : November 22 2020, 04:01 AM
will be helpful for those in need Here is my Raw query , You should rewrite select query with DB methods.
code :
$searchData = DB::table('hostretreats')
    ->where(function($query) use ($typesearchkeyword){
        $query
            ->where('furnishing_type', $typesearchkeyword)
            ->orWhere('prop_type', $typesearchkeyword);
    })
    ->where('approved', 1)
    ->paginate(10);
Laravel 5 Pagination with Query Builder

Laravel 5 Pagination with Query Builder


By : Ravi
Date : March 29 2020, 07:55 AM
around this issue in the doc at this page: http://laravel.com/docs/5.1/pagination we can see that we are not forced to use eloquent.
Related Posts Related Posts :
  • How to use localization in Blade tag templates?
  • Illuminate\Validation\ValidationException : The given data was invalid. Called when trying to get the json from a respon
  • How to pass route values to controllers in Laravel 4?
  • Validation of array form fields in laravel 4 error
  • Second relation to same table returns null
  • Filter model, then join with many-to-many relation
  • Including CSS in Lavavel 5 or 4.3
  • How to add multiple route filters in Laravel 4.2 while using role:permission pattern?
  • Laravel - Pivot table - No join throws an error
  • laravel homestead the host path of shared folder missing error on windows 7
  • Filter collection without duplicates
  • Laravel Eloquent order Relation
  • Unable to install laravel through composer
  • Laravel Like Eloquent with array value?
  • How to configure Laravel model attributes in a trait?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org