PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, March 3, 2022

[FIXED] Laravel wild card problems

 March 03, 2022     laravel, laravel-5, laravel-5.2, wildcard     No comments   

Issue

I have master.blade.php as one of my layouts. When I load post.blade.php in browser without a wildcard like url:localhost8000/post it works and full required page is loaded but when I use a wild card url:localhost8000/post/1 the page is not completely loaded. Only the footer is displayed. Header and body appears white fire bug shows the data is present which is passed through the wildcard.

Both the pages should appear as same because the difference is only of wildcard in url.

My route file is

Route::get('post','PostsController@index');
Route::get('post/{post}','PostsController@show');

Here is my PostsController

class PostsController extends Controller{
public function index(){
    return view('posts.post');
}

public function show(Post $post){
    return view('posts.post',compact('post'));
}
}

Solution

When this kind of error happens, there is most likely a PHP variable error in your project.

A way to find out is to view source of the HTML and look at the first or last part of the page depending on where the error is occurring.

Also, I assume you have properly bound the keyword 'id' in your routes, in your Post model.



Answered By - Chibueze Opata
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing