I`m building a CRM when i fetch data from mysql db and show this data on a table. Now i need to create a view for each row. I have tryed to get this view on another page but i have a problem, no value is shown on table. Anyone can help? I am using quick admin panel
This is controller:
public function showdtl(Snd $snd){
abort_if(Gate::denies('user_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
$snd->load('roles');
return view('showdtl', compact('snd'));}
This is migration
public function up() {
Schema::create('snds', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable();
$table->string('surname')->nullable();
$table->string('email')->nullable();
$table->timestamps();
$table->string('notes')->nullable();
});}
this is role table
public function up(){
Schema::create('role_snd', function (Blueprint $table) {
$table->unsignedInteger('snd_id');
$table->foreign('snd_id', 'snd_id_fk_6892')->references('id')->on('snd')->onDelete('cascade');
$table->unsignedInteger('role_id');
$table->foreign('role_id', 'role_id_fk_6892')->references('id')->on('roles')->onDelete('cascade');
});}
this is model
public $table = 'snds';
protected $fillable = [
'name',
'surname',
'email',
'notes',];
this is blade
<div class="mT-30">
<div class="mb-2">
<table class="table table-bordered table-striped">
<tbody>
@foreach($snds as $key => $snd)
<tr>
<th>
ID
</th>
<td>
{{ $snd->id ?? '' }}
</td>
</tr>
<tr>
<th>
name
</th>
<td>
{{ $snd->name?? '' }}
</td>
</tr>
<tr>
<th>
surname
</th>
<td>
{{ $snd->surname?? '' }}
</td>
</tr>
<tr>
<th>
email
</th>
<td>
{{ $snd->email?? '' }}
</td>
</tr>
@endforeach
</tbody>
</table>
<a style="margin-top:20px;" class="btn btn-info" href="{{ url()->previous() }}">
{{ trans('global.back_to_list') }}
</a>
When i make this "dd(request)" i see db connection is null
public function showdtl(Snd $snd) { abort_if(Gate::denies('user_show'), Response::HTTP_FORBIDDEN,
'403 Forbidden');
$snd->load('roles');
dd($snd);
return view('showdtl', compact('snd'));}