Passed
Push — master ( be1785...591f13 )
by Ajit
07:10
created

Followup::enquiry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Model;
7
8
class Followup extends Model
9
{
10
    use createdByUser, updatedByUser;
11
12
    protected $table = 'trn_enquiry_followups';
13
14
    protected $fillable = [
15
        'enquiry_id',
16
        'followup_by',
17
        'due_date',
18
        'status',
19
        'outcome',
20
        'created_by',
21
        'updated_by',
22
    ];
23
24
    protected $dates = ['created_at', 'updated_at', 'due_date'];
25
26
    public function enquiry()
27
    {
28
        return $this->belongsTo('App\Enquiry', 'enquiry_id');
29
    }
30
31
    public function scopeReminders($query)
32
    {
33
        return $query->leftJoin('mst_enquiries', 'trn_enquiry_followups.enquiry_id', '=', 'mst_enquiries.id')->select('trn_enquiry_followups.*', 'mst_enquiries.status')->where('trn_enquiry_followups.due_date', '<=', Carbon::today())->where('trn_enquiry_followups.status', '=', \constFollowUpStatus::Pending)->where('mst_enquiries.status', '=', \constEnquiryStatus::Lead);
34
    }
35
}
36