mardi 3 novembre 2015

How to fetch values and combine them using eloquent in Laravel 5

I want to display description of the values related to the id's in my list table. Example;

   id   crime_type_id   crime_name_id    crime_suspect_id    crime_victim_id
    1               1               1                   1                  1

Expected output:

   crime_type_des      crime_name_des    crime_suspect_name    victim_name
   against property    theft              Mcdonald             Hillary

How can I achieved this?

ReportController:

     public function index()
{   
   $display_crime = CrimeReport::all();


   return view('crimereports.index',compact('display_crime'));
}

report_table:

    public function up()
{
    Schema::create('crime_reports', function (Blueprint $table) {
        $table->increments('id');
        $table->string('crime_type_id');
        $table->string('crime_name_id');
        $table->string('suspect_id');
        $table->string('victim_id');
        $table->timestamps();
    });
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire