php - how can I display data from database to sb-admin template?
Get the solution ↓↓↓Solution:
Try this
public function index()
{
$kras=Kra::all();
return view('admin.AIPcreate',compact('kras'));
}
Answer
Solution:
try sending the data like below:
public function index()
{
$kras=Kras::all();
return view('admin.AIPcreate',['kras'=>$kras]);
}
and in foreach loop :
@foreach($kras as $kra)
<option value="{{$kra->id}}">{{$kra->KRADetail}}</option>
@endforeach
Answer
Solution:
Try with this
Kra model code namespace App;
use Illuminate\Database\Eloquent\Model;
class Kra extends Model
{
protected $fillable =['id',`KRADetail`];
protected $table = 'table_name;
}
Krascontroller
public function index()
{
$kras=Kra::all();
return view('admin.AIPcreate',compact('kras'));
}
admin/AIPcreate.blade.php
<th colspan="6"> Key Result Areas:
<select class="btn btn-block btn-default">
<option class="dropdown-header">Select Key Result Area</option>
@foreach($kras as $kra)
<option value="{{$kra->id}}">{{$kra->KRADetail}}</option>
@endforeach
</select>
</th>
Because your both variable name is same so it consider it as multiple values.
Here you are mistakenly takeKras
instead ofKra
. Check your model class name.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: unable to determine current zabbix database version: the table "dbversion" was not found.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.