lundi 8 août 2016

Laravel Route not working. Did not get The id

I have now working on a project called Hospital & Doctor Information. Here I have different Division in Bangladesh & in each division there are districts in which there are certain types of hospital according to their ownership. But when I get the value of different hospital from it shows me some error.It did not find the specific id. My route file

Route::get('/district/{id}', array('as' =>'district' ,'uses' => 'UserController@district'));

Route::get('/district/hospital/{id}', array('as' =>'hospital' ,'uses' => 'UserController@hospital'));

Route::get('/district/hospital/hospital_info/{id}', array('as' =>'hospital_info' ,'uses' => 'UserController@hospital_info'));

My Hospital Info Blade file is

<?php $active="hospital"; ?>
@extends('layouts.dashboard')
@section('content') 

    <section id="blog" class="container">
        <div class="center">
            <h2>Hospital Information</h2>
            <h3 class="lead">The government approved a renowned hospital and improved quality of service address , doctor , patient viewing time, bed , pathological tests in various subjects including costs and find the information here .<br> The bed and cabin bookings online , pathological tests , the doctor can be a serial for the meeting from the app .</h3>
        </div>

        <div class="blog">
            <div class="row">
                 <div class="col-md-12">
                    <div class="blog-item">
                        <div class="row">

                            <div class="col-xs-12 col-sm-4 blog-content">

                                <a href="#"><img class="img-responsive img-blog" src="images/2.jpg" width="100%" alt="" /></a>
                            </div>
                            @foreach($division->districts as $district)
                                @foreach($district->cats as $category)
                                    @foreach($category->hospitals as $hospital)
                                    <div class="col-xs-12 col-sm-6 blog-content">
                                        <h2></h2>
                                    </div>
                                    @endforeach
                                @endforeach
                            @endforeach
                            <div class="col-xs-12 col-sm-2 blog-content">
                                <h2><a href="#">Share</a></h2>
                                <ul class="social-share">
                                        <li><a href="#"><i class="fa fa-google-plus"></i></a></li>
                                        <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                                        <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                                        <li><a href="#"><i class="fa fa-skype"></i></a></li>
                                    </ul>
                                    <br><br>

                                <a class="btn btn-success readmore" href="#">Booking</a>
                            </div>
                        </div>    
                    </div><!--/.blog-item-->\
                </div><!--/.col-md-8-->

            </div><!--/.row-->
        </div>
    </section><!--/#blog-->
@stop

My Controller Is

public function district($id)
    {

        $divisions = Division::all();

        $division=Division::find($id); 

        $district=District::find($id); 

        // $districts=District::where('division_id', '=', $divisions->id)->get();

        if (!$division)
        {
            throw new NotFoundHttpException;
        }
        return view('users.district')
                    ->with('divisions',  $divisions)
                    ->with('division', $division)
                    ->with('district', $district);
    }


    public function hospital($id)
    {

         $divisions = Division::all();
         $division=Division::find($id); 

         $district=District::find($id); 

         $categories=Category::all();

        // $districts=District::where('division_id', '=', $divisions->id)->get();

        // if (!$district)
        // {
        //     throw new NotFoundHttpException;
        // }
        return view('users.hospital')
                    ->with('divisions',  $divisions)
                    ->with('division', $division)
                    ->with('district', $district)
                    ->with('categories',$categories);
    }


    public function hospital_info($id)
    {
        $divisions = Division::all();
         $division=Division::find($id); 

         $district=District::find($id); 

         $categories=Category::all();
         $cats=Category::find($id); 
         $hospitals=Hospital::find($id); 

        // $districts=District::where('division_id', '=', $divisions->id)->get();

        // if (!$district)
        // {
        //     throw new NotFoundHttpException;
        // }
        return view('users.hospital_info')
                    ->with('divisions',  $divisions)
                    ->with('division', $division)
                    ->with('district', $district)
                    ->with('categories',$categories)
                    ->with('cats',$cats)
                    ->with('hospitals',$hospitals);
    }

The error is enter image description here

I have asked the question a few days earlier but did not find the answer. Plz help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire