Search code examples
phplaravellaravel-5composer-phpslug

Laravel 5.3 on shared hosting; Page::findBySlug() returns null


I just pushed a Laravel website onto a shared hosting. Copied the public folder to the /www, changed the index.php to reflect the path change and configured my .htaccess, etc.

At first I was simply getting an error, telling me that Page::findBySlug() returned null. Checked again with dd(), was and still is null.

FrontendController@index is looking like this

public function index($slug)
{
    $page = Page::findBySlug($slug);
    $pageTemplate = $page->templates->first();
    return view('frontend.pages.index', compact('page','pageTemplate'));
}

and after toying with dd() for a while, it now sends me to the custom 500 unless it's supposed to pull the slug from db, in which case I get a custom 404.

EDIT: I pulled the same version of the app but with it being already installed (instead of rolling with composer instal) from the testing platform and it simply works so I doubt it has anything to do with the hosting. I'd still appreciate an answer given that I'd like to do it the correct way. Is there anything I should setup slugs-wise after running a fresh install?

What am I missing here? Thanks.


Solution

  • Fixed by php artisan route:clear. Apparently route:cache wasn't the way to go.