如何在laravel上获得第一张图片

时间:2019-10-18 07:38:13

标签: laravel

我已经尝试过(Laravel 5.2 - show first image from database

但是我在photo_rumah上获得了“ rumahnya = n rumahnya = t rumahnya = I”的价值

controller
public function index()
    {
        //
        $data   = $this->dataRumah();
        // dd($data);
        return view('panelD.data_rumah',[
            'data' => $data,
        ]);
    }
    // get data
    public function dataRumah(){
        $data = DB::table('datarumah')->get();
        foreach($data as $keys => $value){
            $photoRumah = DB::table('photorumah')->where('id_rumah', '=', $value->id_rumah)->get();
            $value->DataPhoto   = $photoRumah;
        }
        return $data;
    }
blade

     <a href="#"><img src="{{asset('././././assets/PhotoRumah/'.$itemPhoto->photo_rumah[0])}}" alt=""></a>
       //when i echo i just got value "rumahnya= n  rumahnya= t  rumahnya= I" on photo_rumah 

0 个答案:

没有答案