douzou8074 2018-04-16 11:03
浏览 40

从laravel 5.5中的数据库返回所有表值

I am trying to get record against unique id from database but i am getting all the record i have 2 columns in my table and i am getting all the 2 but only want is to get 1 in my view.

My View in which i am using blade template:

<li><a href="{{url('Template'.($value->particulars1)->template)}}" class="viewpage" target="_blank"><i class="fa fa-eye"></i> View Page</a></li>

Here i am getting record based on template id as u can see $value->particulars1)->template but it is returning all 2 tables i somehow also want to get record against id(which is auto incrementing) but i am unable to get my records

My Controller:

public function Template1()
{
    $template1 = Sale::all();
    return view('Template-1',compact('template1'));
}

and my router:

$router->get('/Template1', 'AjaxController@Template1');

Any help will be highly appreciated!

  • 写回答

1条回答 默认 最新

  • donglu8334 2018-04-16 11:17
    关注

    Change your link,

    <li><a href="{{url('template/'.($value->particulars1)->template)}}" class="viewpage" target="_blank"><i class="fa fa-eye"></i> View Page</a></li>
    

    Change this function,

    public function Template1($id)
      {
        $template1 = Sale::find($id);
        return view('Template-1',compact('template1'));
      }
    

    Change this route,

    $router->get('/template/{id}', 'AjaxController@Template1');
    
    评论

报告相同问题?