我收到此错误。
SQLSTATE [42S22]:找不到列:1054未知列 'where子句'中的'schools.submit_application_id'(SQL:select * from
schools
schools
。submit_application_id
= 1和schools
submit_application_id
。public function index() { $inspectors_lists = SubmitApplication::latest()->where('approved', 1)->get(); return view('Admin.inspectors-list.all', compact('inspectors_lists')); }
不为空)(查看: C:\ XAMPP \ htdocs中\项目\ tvto \资源\视图\管理员\检查员列表\ all.blade.php)
InspectionListController.php
<td>{{ $inspectors_list->school_list->user->first_name }}</td>
all.blade.php
public function school_lists()
{
return $this->hasMany(SchoolsList::class);
}
SubmitApplication.php
public function user()
{
return $this->belongsTo(User::class);
}
public function submit_application()
{
return $this->belongsTo(SubmitApplication::class);
}
SchoolsList.php
public function school_lists()
{
return $this->hasMany(SchoolsList::class);
}
SubmitApplication.php
public function schools()
{
return $this->hasMany(SchoolsList::class);
}
user.php的
public function up()
{
Schema::create('submit_applications', function (Blueprint $table) {
$table->increments('id');
$table->integer('requisition_id')->nullable()->unsigned();
$table->integer('school_id')->nullable()->unsigned();
$table->integer('approved')->nullable(true);
$table->string('application')->nullable(true);
$table->timestamps();
$table->foreign('requisition_id')->references('id')->on('requisitions');
$table->foreign('school_id')->references('id')->on('schools');
});
}
对于SubmitApplication表:
public function up()
{
Schema::create('schools', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('province_name');
$table->string('center_name');
$table->string('national_number_founder');
$table->string('school_name');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
});
}
对于SchoolList表:
MultipleConfigFiles