【发布时间】:2018-05-06 22:01:33
【问题描述】:
我尝试建立自己的项目,即在线求职网站。
我有两张表company和job。表company可以有很多工作关系
这是关系
//company.php
public function jobs(){
return $this->hasMany(Job::class);
}
//job.php
public function company(){
return $this->belongsTo(Company::class);
}
我的桌子
Schema::create('companies', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('companyName');
$table->string('logo')->nullable();
$table->string('contactPerson');
$table->string('employeeSize');
...
Schema::create('jobs', function (Blueprint $table) {
$table->increments('id');
$table->integer('company_id');
$table->string('jobTitle');
$table->longText('jobDescription');
$table->longText('jobRequirement');
$table->date('deadline');
...
我想显示所有工作,每个工作都有自己的公司,比如
- +在每个作业列表中必须有
- 职位,
- 截止日期,..和
- 公司名称、徽标
控制器和视图中的代码是什么? 请帮忙!
【问题讨论】:
标签: php laravel laravel-5 eloquent