lundi 2 mai 2016

how to ->paginate() on a inner join Laravel 5

Trying to paginate a inner join but it does not work.

This it my code

    $positions = DB::table('position')
    ->join('company', 'position.company_id', '=', 'company.id')
    ->select('position.*', 'company.name')
    ->paginate(15)
    ->get();

This is what the array looks like (without the paginate->())

Array(
[0] => stdClass Object
    (
        [id] => 1
        [company_id] => 1
        [title] => Software Developer
    )

[1] => stdClass Object
    (
        [id] => 2
        [company_id] => 2
        [title] => Accountant
    )

[2] => stdClass Object
    (
        [id] => 3
        [company_id] => 3
        [title] => Insurance salesman
    )

and this is what i use

use DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
use App\Http\Requests;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire