Я реагирую на эти данные по таблице отделов, к которой я присоединяюсь к таблице администрирования и таблице отделов по HasMany Relationship. Я хочу просмотреть это уведомление. на дано это ниже.
<table id="order-listing" class="table table-striped" style="width:100%;">
<thead>
<tr>
<th>Sl No</th>
<th>Notice Name</th>
<th>Teacher Name</th>
<th>Message</th>
<th>Notice</th>
<th>View Notice</th>
</tr>
</thead>
@foreach ($student->department as $key=>$students)
<tr>
<td>{{$key+1}}</td>
<td>{{$students->name}}</td>
<td>{{$students->message}}</td>
<td>{{$students->message}}</td>
<td><img src="{{ asset('images/department/'.$students->image) }}" alt="Notice" width="150" height="150"></td>
<td>
<a href="{{ route('view.student.department.notice',$students->id) }}" class="btn btn-primary">View This Notice</a>
</td>
</tr>
@endforeach
</table>
Маршрут этого представления
Route::get('/student/notice/view/{id}','AdministrationController@departmentviewnotice')->name('view.student.department.notice');
Функция этих данных ..
public function departmentviewnotice($id){
$this->AdminAuthCheck();
$student=Administration::find($id);
//dd($student);
return view('Student.departmentnotice',compact('student'));
}
Я хочу взять данные из таблицы отдела
с учетом этого отношения ниже
public function department()
{
return $this->hasMany('App\CseDepartment','dept','dept');
}
Взаимосвязь таблицы отдела
public function administration()
{
return $this->belongsTo('App\Administration','dept','dept');
}
С учетом этого представления таблица
<div class="content-wrapper">
<div class="card">
<div class="card-body">
<div class="row">
<div class="card">
<div class="card-header">
<h2>Name:{{$student->department->name}}</h2>
</div>
<img class="card-img-top" src="{{ asset('images/department/'.$student->image) }}" width="1000" height="620" alt="">
</div>
</div>
<div class="card">
<div class="card-body">
<h2>Message</h2>
<p>{{$student->department->message}}</p>
</div>
</div>
</div>
</div>
Но я не могу получить доступ к отделу данные таблицы.