-
Notifications
You must be signed in to change notification settings - Fork 0
/
laravel-eloquent.php
49 lines (39 loc) · 1003 Bytes
/
laravel-eloquent.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Note: This is a basic model showing simple
* relationships between an Employer (child to a user)
* and it's jobs (an Employer can have many job openings.
*/
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
class Employers extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'user_id', 'contact_email', 'company', 'logo', 'website', 'about_us'
];
public function user ()
{
return $this->belongsTo('App\Users');
}
public function jobs ()
{
return $this->hasMany('App\Jobs');
}
/**
* Checks to ensure the employer profile is complete
*/
public function isProfileComplete () {
$employer = Employers::where('user_id', Auth::id())->first();
if (!$employer->logo || !$employer->company) {
return false;
} else {
return true;
}
}
}