Support the ongoing development of Laravel.io →
posted 10 years ago
Views

hi, i want use paginate function and this is my code in view ..

    <?php foreach ($some as $user): ?>
        <?php echo $user->title; ?>
    <?php endforeach; ?>


<?php echo $some->links(); ?>

and this is my code in Route ( or controller for next time) :

Route::get('/pagination',function()
{
    $some = Education::paginate(5);
	return View::make('pagination')->with('some',$some);
});

but i have an error !!!

Method Illuminate\View\View::__toString() must not throw an exception 

how to i can fix this?

Last updated 3 years ago.
0

It probably means your echo $some->links() is returning an object or array, but your trying to output it as a string

do this in your view:

<?php dd($some->links) ?> 

and it will show you what type of data it is.

Last updated 3 years ago.
0

after this code ...


object(Illuminate\View\View)#185 (5) { ["factory":protected]=> object(Illuminate\View\Factory)#99 (12) { ["engines":protected]=> object(Illuminate\View\Engines\EngineResolver)#91 (2) { ["resolvers":protected]=> array(2) { ["php"]=> object(Closure)#94 (1) { ["this"]=> object(Illuminate\View\ViewServiceProvider)#67 (2) { ["app":protected]=> object(Illuminate\Foundation\Application)#2 (16) { ["booted":protected]=> bool(true) ["bootingCallbacks":protected]=> array(0) { } ["bootedCallbacks":protected]=> array(2) { [0]=> object(Closure)#74 (2) { ["static"]=> array(2) { ["app"]=> *RECURSION* ["me"]=> *RECURSION* } ["this"]=> *RECURSION* } [1]=> object(Closure)#46 (1) { ["static"]=> array(2) { ["app"]=> *RECURSION* ["env"]=> string(10) "production" } } } ["finishCallbacks":protected]=> array(0) { } ["shutdownCallbacks":protected]=> array(0) { } ["middlewares":protected]=> array(0) { } ["serviceProviders":protected]=> array(13) { [0]=> object(Illuminate\Events\EventServiceProvider)#11 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [1]=> object(Illuminate\Exception\ExceptionServiceProvider)#15 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [2]=> object(Illuminate\Routing\RoutingServiceProvider)#26 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [3]=> object(Illuminate\Cookie\CookieServiceProvider)#48 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [4]=> object(Illuminate\Database\DatabaseServiceProvider)#51 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [5]=> object(Illuminate\Encryption\EncryptionServiceProvider)#56 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [6]=> object(Illuminate\Filesystem\FilesystemServiceProvider)#59 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [7]=> object(Illuminate\Session\SessionServiceProvider)#62 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [8]=> *RECURSION* [9]=> object(Illuminate\Workbench\WorkbenchServiceProvider)#75 (2) { ["defer":protected]=> bool(false) ["app":protected]=> *RECURSION* } [10]=> object(Illuminate\Log\LogServiceProvider)#101 (2) { ["defer":protected]=> bool(true) ["app":protected]=> *RECURSION* } [11]=> object(Illuminate\Pagination\PaginationServiceProvider)#173 (2) { ["defer":protected]=> bool(true) ["app":protected]=> *RECURSION* } [12]=> object(Illuminate\Translation\TranslationServiceProvider)#177 (2) { ["defer":protected]=> bool(true) ["app":protected]=> *RECURSION* } } ["loadedProviders":protected]=> array(13) { ["Illuminate\Events\EventServiceProvider"]=> bool(true) ["Illuminate\Exception\ExceptionServiceProvider"]=> bool(true) ["Illuminate\Routing\RoutingServiceProvider"]=> bool(true) ["Illuminate\Cookie\CookieServiceProvider"]=> bool(true) ["Illuminate\Database\DatabaseServiceProvider"]=> bool(true) ["Illuminate\Encryption\EncryptionServiceProvider"]=> bool(true) ["Illuminate\Filesystem\FilesystemServiceProvider"]=> bool(true) ["Illuminate\Session\SessionServiceProvider"]=> bool(true) ["Illuminate\View\ViewServiceProvider"]=> bool(true) ["Illuminate\Workbench\WorkbenchServiceProvider"]=> bool(true) ["Illuminate\Log\LogServiceProvider"]=> bool(true) ["Illuminate\Pagination\PaginationServiceProvider"]=> bool(true) ["Illuminate\Translation\TranslationServiceProvider"]=> bool(true) } ["deferredServices":protected]=> array(68) { ["artisan"]=> string(54) "Illuminate\Foundation\Providers\ArtisanServiceProvider" ["command.changes"]=> string(54) "Illuminate\Foundation\Providers\ArtisanServiceProvider" ["command.environment"]=> string(54) "Illuminate\Foundation\Providers\ArtisanServiceProvider" ["auth"]=> string(35) "Illuminate\Auth\AuthServiceProvider" ["cache"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["cache.store"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["memcached.connector"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["command.cache.clear"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["command.cache.table"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["command.session.database"]=> string(42) "Illuminate\Session\CommandsServiceProvider" ["command.command.make"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["composer"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.dump-autoload"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.key.generate"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.up"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.down"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.optimize"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.clear-compiled"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["asset.publisher"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.asset.publish"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["config.publisher"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.config.publish"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["view.publisher"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.view.publish"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["migration.publisher"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.migrate.publish"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.routes"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.serve"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.tinker"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.queue.failed"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.queue.retry"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.queue.forget"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.queue.flush"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.queue.failed-table"]=> string(61) "Illuminate\Foundation\Providers\ConsoleSupportServiceProvider" ["command.controller.make"]=> string(44) "Illuminate\Routing\ControllerServiceProvider" ["hash"]=> string(38) "Illuminate\Hashing\HashServiceProvider" ["html"]=> string(35) "Illuminate\Html\HtmlServiceProvider" ["form"]=> string(35) "Illuminate\Html\HtmlServiceProvider" ["mailer"]=> string(35) "Illuminate\Mail\MailServiceProvider" ["swift.mailer"]=> string(35) "Illuminate\Mail\MailServiceProvider" ["swift.transport"]=> string(35) "Illuminate\Mail\MailServiceProvider" ["migrator"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["migration.repository"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["command.migrate"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["command.migrate.rollback"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["command.migrate.reset"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["command.migrate.refresh"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["command.migrate.install"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["migration.creator"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["command.migrate.make"]=> string(44) "Illuminate\Database\MigrationServiceProvider" ["queue"]=> string(37) "Illuminate\Queue\QueueServiceProvider" ["queue.worker"]=> string(37) "Illuminate\Queue\QueueServiceProvider" ["queue.listener"]=> string(37) "Illuminate\Queue\QueueServiceProvider" ["queue.failer"]=> string(37) "Illuminate\Queue\QueueServiceProvider" ["command.queue.work"]=> string(37) "Illuminate\Queue\QueueServiceProvider" ["command.queue.listen"]=> string(37) "Illuminate\Queue\QueueServiceProvider" ["command.queue.restart"]=> string(37) "Illuminate\Queue\QueueServiceProvider" ["command.queue.subscribe"]=> string(37) "Illuminate\Queue\QueueServiceProvider" ["redis"]=> string(37) "Illuminate\Redis\RedisServiceProvider" ["remote"]=> string(39) "Illuminate\Remote\RemoteServiceProvider" ["auth.reminder"]=> string(49) "Illuminate\Auth\Reminders\ReminderServiceProvider" ["auth.reminder.repository"]=> string(49) "Illuminate\Auth\Reminders\ReminderServiceProvider" ["command.auth.reminders"]=> string(49) "Illuminate\Auth\Reminders\ReminderServiceProvider" ["seeder"]=> string(39) "Illuminate\Database\SeedServiceProvider" ["command.seed"]=> string(39) "Illuminate\Database\SeedServiceProvider" ["translation.loader"]=> string(49) "Illuminate\Translation\TranslationServiceProvider

and more text such az this ..my browser is hang :D

Last updated 3 years ago.
0

OK, so that look like a eloquent response...

Assuming that your 'links()' is a hasMany relationship you need somthing like this....

foreach($some->links() as $link)
{
    echo $link->column_name
}

(or the same in blade syntax)

Last updated 3 years ago.
0

this code not work.. any thing show in browser

Last updated 3 years ago.
0

Did you change

echo $link->column_name

To the column values in your db table?

If you did pate up on laravel bin the controller and view files

Last updated 3 years ago.
0

What you mean by this section :

column_name
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

itjoo itjoo Joined 13 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.