【发布时间】:2021-10-04 03:13:45
【问题描述】:
我正在尝试迁移我的外键并以公司形式显示员工列表。为此:
1.My CompaniesController
public function index(){
$cat = Company::all();
return view(view:'company/index')->with ('cat', $cat);
}
-
这是我的公司迁移节目:
public function up() { Schema::create('company', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('emp_id'); $table->foreign('emp_id')->references('id')->on('employeee')->onUpdate('cascade')->onDelete('cascade'); $table->string('companyname')->nullable(); $table->string('connumber')->nullable(); $table->string('addressline1')->nullable(); $table->string('addressline2')->nullable(); $table->string('contactnumber')->nullable(); $table->string('suburb')->nullable(); $table->string('state')->nullable(); $table->string('postcode')->nullable(); $table->string('image'); $table->timestamps(); });}
这是我的下拉菜单代码
`<div class="col-md-6">
<select name="">
@foreach ($cat as $row )
<option value="{{$row->id}}">{{$row->companyname}}</option>
@endforeach
</select>
</div>`
这是公司的管理员路线:
Route::resource('/admin/companies', 'Admin\CompaniesController',['as'=>'admin']);
`
请帮帮我
【问题讨论】:
-
请显示完整错误页面的截图并尝试向下回答
-
这能回答你的问题吗? How to pass data to view in Laravel?
标签: laravel undefined-variable