我想制作详细视图。但这里我有一个问题是使用两个表。在这里我想详细说明当我点击ID为“2”的数据巡逻时(来自表log_patrols)我想用id_log_patrols“2”(来自表log_patrol_details)调出所有数据。
这里我的表是log_patrol_details:
这是我的Patrolscontroller:
public function getDetail($id)
{
$data['row'] = log_patrols::find($id);
return view('detail_details',$data);
}
在这里我的观点:
<form method='post' action='{{action("PatrolsController@postEditSave")."/$row->id"}}' enctype="multipart/form-data">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="box-body">
<div class="box-body">
<div class='form-group col-sm-6'>
<label>Date Start</label>
<input class='form-control' value='{{ @$row->date_start }}' readonly />
</div>
<div class='form-group col-sm-6'>
<label>Date End</label>
<input class='form-control' value='{{ @$row->date_end }}' readonly />
</div>
</div><!-- /.box -->
</form>
@include('deta')
这里是我的包括deta.blade.php:
@foreach ($dota as $row)
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo1 }}" class="images-edit"><br>
</div>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo2 }}" class="images-edit"><br>
</div>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo3 }}" class="images-edit"><br>
</div>
<div class='form-group col-sm-12'>
<label>Description</label>
<input type='text' class='form-control' name='description' value="{{ $row->description }}" readonly/>
</div>
@endforeach
这里是我的LogDetailsController:
public function getDetail($id_log_patrols) {
$dota = DB::table("log_patrol_details")
->orderBy('id', 'desc')
->where('id_log_patrols', $id_log_patrols)
->paginate(4);
return view('deta', ['dota'=>$dota]);
}
我尝试使用包含视图,但它无法正常工作。所以我有人有想法?并为我解决?
答案 0 :(得分:0)
试试这个:
我的观点中的代码:
<form method='post' action='{{action("PatrolsController@postEditSave")."/$row->id"}}' enctype="multipart/form-data">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="box-body">
<div class="box-body">
<div class='form-group col-sm-6'>
<label>Date Start</label>
<input class='form-control' value='{{ @$row->date_start }}' readonly />
</div>
<div class='form-group col-sm-6'>
<label>Date End</label>
<input class='form-control' value='{{ @$row->date_end }}' readonly />
</div>
</div><!-- /.box -->
</form>
@yield('content')
deta.blade.php
中的代码:
@extends('myview')
@section('content')
@foreach ($dota as $row)
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo1 }}" class="images-edit"><br>
</div>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo2 }}" class="images-edit"><br>
</div>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo3 }}" class="images-edit"><br>
</div>
<div class='form-group col-sm-12'>
<label>Description</label>
<input type='text' class='form-control' name='description' value="{{ $row->description }}" readonly/>
</div>
@endforeach
@endsection