0

I am receiving this error while trying to create pagination in laravel.

ErrorException in 1e886a45102a3e4898f23b52cd7ca771 line 396: Call to a member function links() on array (View: C:\xampp\htdocs\soulfy_repo\framework\resources\views\soulfy\setting.blade.php)

line 396:  <?php echo e($themes->links()); ?>

HomeController.php

public function getBackgroundTheme()
{

    $query = DB::table('theme_background');

    if (request()->has('menu')) {
        $theme = DB::table('kategori_name')->where('kategori_theme', request('menu'))->first();

        $query = $query->where('kategori_id', $theme->kategori_id);
    }

    //$model = $query->get();
    $theme = $query->paginate(4);

    return view('soulfy.setting', [
        'themes'=>$theme,
        'user' => auth()->user(),
    ]);


    // return redirect('/home/setting' . 
}

setting.blade.php

        <table>

    @if(isset($themes))
        @foreach($themes as $m)

            <tr>
                <td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
                <td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
                <td><img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}.jpg"/></td>
            </tr>

            <tr>
                <td><div class="box"><input type="checkbox" name="pic" value=""></div></td>
                <td><input type="checkbox" name="pic" value=""></td>
                <td><input type="checkbox" name="pic" value=""></td>
            </tr>

        @endforeach

        {{ $themes->links() }}
    @endif


</table>
2
  • try to comment the if block : this one if (request()->has('menu')) { $theme = DB::table('kategori_name')->where('kategori_theme', request('menu'))->first(); $query = $query->where('kategori_id', $theme->kategori_id); } and see if it will work Commented Jul 17, 2017 at 8:33
  • Still having the same error message Commented Jul 17, 2017 at 9:01

1 Answer 1

1
 $theme = DB::table('kategori_name')->where('kategori_theme', request('menu'))->paginate(PAGELIMIT);

Use This In Your Home Controller. Instead Of first(); And Define This In Your Routes : define('PAGELIMIT','4');

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.