jeudi 19 mai 2016

Show data details from 2 table in laravel 5.1

I wanted to make a detail view. but here I have a problem is by using two tables. here I would like to make a detail which when I click Data Patrols with id "2" (from table log_patrols) I want to bring up all of the data with id_log_patrols "2"(from table log_patrol_details).

my tables log_patrols : this for my tables log_patrols

and here my tables log_patrol_details :

my tables log_patrol_details

here my Patrolscontroller :

public function getDetail($id)
    {
        $data['row'] = log_patrols::find($id);
        return view('detail_details',$data);
    }

and here my view :

<form method='post' action='' enctype="multipart/form-data">
                <input type="hidden" name="_token" value="">
                <div class="box-body">
                    <div class="box-body">
                    <div class='form-group col-sm-6'>
                        <label>Date Start</label>
                        <input class='form-control' value='' readonly />
                    </div>
                    <div class='form-group col-sm-6'>
                        <label>Date End</label>
                        <input  class='form-control' value='' readonly />
                    </div>

            </div><!-- /.box -->
            </form>
            @include('deta')

and here for my include deta.blade.php :

@foreach ($dota as $row)
                    <div class='form-group col-sm-4'>
                        <label>gambar</label><br>
                        <img src="../../uploads/" class="images-edit"><br>
                    </div>
                    <div class='form-group col-sm-4'>
                        <label>gambar</label><br>
                        <img src="../../uploads/" class="images-edit"><br>
                    </div>
                    <div class='form-group col-sm-4'>
                        <label>gambar</label><br>
                        <img src="../../uploads/" class="images-edit"><br>
                    </div>
                    <div class='form-group col-sm-12'>
                        <label>Description</label>
                        <input type='text' class='form-control' name='description' value="" readonly/>
                    </div>
@endforeach

and here for my 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]);
    }

i have try to use include the view but its cant work. so i did someone have idea ? and have solution for me ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire