I am learning Laravel 5.4. But I have stuck in one place.
I have two tables coursenames and branchnames.
branchnames table contains: id, branchname, course_id
coursenames table contains: id, coursename
coursename has a unique name, and course_id of branchnames has an id of coursename, which can be repeated.
My BranchNameController is:
public function index()
{
$branchname = branchname::all();
$coursename = coursename::all();
return view('admin.branchname',compact('branchname','coursename'));
}
branchname.blade.php is:
<tbody>
@foreach($branchname as $branchnames)
<tr>
<td>{{ $branchnames->branchname }}</td>
<td>{{ $branchnames->course_id }}</td>
</tr>
@endforeach
</tbody>
I want to show course name instead of {{ $branchnames->course_id }}. How it can be done?
model branchname.php is:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class branchname extends Model
{
//
}
model coursename.php is:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class coursename extends Model
{
//
}