jeudi 25 octobre 2018

Laravel problem with passing variables from controller to view

I am working on a laravel project and having a problem passing variables from the controller to the view:

this is the controller method:

public function index($id){
        $data = [];
        $company = DB::table('companies')->where('id',$id)->first();
        return view('searchResultAdmin.index',  ['company'=>$company, 'Data'=>$data]);
    }

and this is the view :


                            <div class="radio-buttons display-inline">
                                <fieldset class="display-inline group1">
                                    <label class="radio-inline">
                                        <input type="radio" name="SearchLocation" id="value1" value="Actuals" checked>Actuals
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="SearchLocation" id="value2" value="Forecasts">Forecasts
                                    </label>
                                </fieldset>
                                
                                <fieldset class="display-inline">
                                    <label class="radio-inline">
                                        <input type="radio" name="Order" id="value3" value="Ascending" checked>Ascending
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="Order" id="value4" value="Descending">Descending
                                    </label>
                                </fieldset>
                            </div>
                            <div class="dropdown-header-table display-inline">
                                <h5>Search By:
                                    <select name="SearchBy">
                                        <option value="Account">Account</option>
                                        <option value="Name">Name</option>
                                        <option value="Year">Year</option>
                                        <option value="Description">Description</option>
                                        <option value="Amount">Amount</option>
                                    </select>
                                </h5>
                            </div>
                            <div class="search-input display-inline">
                                <div class="table-form-header">
                                    <input type="text" class="form-control" name="SearchInputs" placeholder="Search...">
                                    <span class="input-group-btn">
                                        <button class="btn btn-default" type="submit">
                                            <i class="fa fa-search"></i>
                                        </button>
                                    </span>
                                </div>
                            </div>
                        

the error says: undefined variable company on view



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire