I try to build my own project which is job online website.
I have two tables company
and job
.Table company
can have many jobs relationship
Here is relationship
//company.php
public function jobs(){
return $this->hasMany(Job::class);
}
//job.php
public function company(){
return $this->belongsTo(Company::class);
}
My tables
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');
...
I want to display all jobs and every job has its own company like
- +in every list of the job must have
- jobTitle,
- deadline,..and
- companyName, logo
what is the code in controller and in the view would be? please help!