【问题标题】:Multiple select query in same Laravel view同一个 Laravel 视图中的多选查询
【发布时间】:2017-05-22 15:48:17
【问题描述】:

当我想从同一个表中显示我的数据时遇到问题,但我只需要该表中的一个字段.. 通过控制器,有函数index()setID()

这是我的控制器

public function index(){
    $wo = DB::select('select max(nowo)+1 as nowo, CURRENT_DATE as tgl from workorder');
    return view('entri_wo')->with(['workorder'=>$wo]);
}

public function setID()
{
    $wo = DB::select('select idmontir from workorder');
    return view('entri_wo',['wo'=>$wo]);
}

这是我的看法

另外,我想展示一下

这是我的路线

Route::get('/entri_wo', 'WoController@index')->name('entri_wo');

【问题讨论】:

    标签: php laravel model-view-controller


    【解决方案1】:

    在您的控制器中:

    public function index(){
      $wo = DB::select('select idmontir from workorder');
      $wo2 = DB::select('select max(nowo)+1 as nowo, CURRENT_DATE as tgl from workorder');
      return view('entri_wo',['wo'=>$wo,'workorder'=>$wo2]);
    }
    

    在你看来:

    @foreach($wo as $item)
      <option value="{{ $item->idmontir }}" >{{ $item->idmontir }}</option>
    @endforeach
    

    和:

    @foreach($workorder as $item)
      <tr>
        <td>{{ $item->nowo }}</td>
        <td>{{ $item->tgl }}</td>
      </tr>
    @endforeach
    

    【讨论】:

    • 你是最好的兄弟。谢谢你的回答。它对我有用!太好了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-25
    • 2014-08-15
    • 1970-01-01
    • 2016-10-30
    • 2018-11-25
    • 2019-12-08
    相关资源
    最近更新 更多