我想檢索所有列值。以下是儀表板控制器代碼,其默認運行指數法Laravel不從數據庫檢索值
<?php
namespace App\Http\Controllers;
use App\questions;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests;
class Dashboard extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function fetchQuestions() {
return questions::where('people_id','=',Auth::id())->pluck('question');
}
public function index(){
$listQuestions=$this->fetchQuestions();
return view('forms.question',compact('listQuestions'));
}
}
查看文件
<ul>
@foreach ($listQuestions as $question)
<li>{{ $question }}</li>
@endforeach
</ul>
它不顯示任何錯誤或任何結果要麼
仍然沒有工作 –
當你DD($ listQuestions) –
我得到這個'數組你明白了什麼:1 [▼0 => 「確定上真」]'它的工作原理,但值未通過或顯示在頁面 –