help me in this step
index.blade.php page
navbar code
<nav class="navigation">
<ul class="sf-menu">
<li><a href="{{ url('/') }}">Home</a>
</li>
<li><a href="{{ url('about') }}">About Us</a></li>
<li><a href="javascript:;">Category</a>
<ul class="dropdown">
<li><a href="{{ url('grid/1') }}">Buy and Sell</a></li>
<li><a href="agent-detail.html">Car and Vehicles</a></li>
<li><a href="my-properties.html">Real Estate</a></li>
<li><a href="submit.html">Pets</a></li>
<li><a href="pricing.html">Jobs</a></li>
<li><a href="login.html">Community</a></li>
<li><a href="404.html">Resumes</a></li>
</ul>
</li>
My Route code
Route::resource('/', 'BasicController');
Route::resource('about', 'BasicController@about');
Route::resource('contact', 'BasicController@contact');
Route::resource('grid', 'BasicController@grid');
This is my controller code
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class BasicController extends Controller
{
public function index(){
return view('index');
}
public function about(){
return view('about');
}
public function contact(){
return view('contact');
}
public function grid($id)
{
$id = $this->uri->segment(3);
if ($id == 1) {
return view('buy-and-sell/grid');
}
elseif ($id == 2) {
return view('car-and-vehicels/grid');
}
elseif ($id == 3) {
return view('country/grid');
}
else{
return view('other/grid');
}
}
}
public function grid($id) {
$id = $this->uri->segment(3); <!-- Line number 30-->
if ($id == 1) {
return view('buy-and-sell/grid');
}
elseif ($id == 2) {
return view('car-and-vehicels/grid');
}
elseif ($id == 3) {
return view('country/grid');
}
else{
return view('other/grid');
}
}
You have to apply the following changes:
1.) Your method signature is wrong. See below, Laravel will pass in the "number" automatically from your url in the variable $id (but as second(!) argument). Be ware you also have to import the Request in the header via an use Illuminate\Http\Request;
statement!
public function grid(Request $request, $id)
2.) Dont use $this->uri->segment
but rather use the passed $id directly (this is the slug that represents segement 3). You are using resource Controllers and Laravel does the mapping automatically for you.
So it should look likes this:
public function grid(Request $request, $id)
{
//$id = $this->uri->segment(3); //COMMENT THIS OUT!!!
if ($id == 1) {
return view('buy-and-sell/grid');
}
elseif ($id == 2) {
return view('car-and-vehicels/grid');
}
elseif ($id == 3) {
return view('country/grid');
}
else{
return view('other/grid');
}
3.) Regarding the CSS. You got your paths wrong, but this is extremely hard to debug/help without further information
Important: Its seems you are running laravel as a subfolder install. You will run into very strange problems (like this one, I suspecte this the subfolder install could be the reason). I have opened a bug at laravel some time ago, but it got closed. Subfolder Installs are not supported.
I really advise you to install laravel as described on their homepage as a dedicated virtual host, that the public
folder maps to the domain itself (like http://localhost) in other words "public" is your root folder that is served directly under http:://localhost.