Followup   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A Enquiry() 0 3 1
A updatedBy() 0 3 1
A scopeReminders() 0 7 1
A createdBy() 0 3 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Carbon\Carbon;
7
use App\Enquiry;
8
9
class Followup extends Model
10
{
11
	protected $table = 'trn_enquiry_followups';
12
13
	protected $fillable = [
14
		'enquiry_id',
15
		'followup_by',
16
		'due_date',
17
		'status',
18
		'outcome',
19
		'created_by',
20
    	'updated_by',
21
	];
22
23
	protected $dates  = ['created_at', 'updated_at', 'due_date'];
24
25
	public function Enquiry()
26
	{
27
		return $this->belongsTo('App\Enquiry','enquiry_id');
28
	}
29
30
	public function scopeReminders($query)
31
	{
32
		return $query->leftJoin('mst_enquiries','trn_enquiry_followups.enquiry_id','=','mst_enquiries.id')
33
					 ->select('trn_enquiry_followups.*','mst_enquiries.status')
34
					 ->where('trn_enquiry_followups.due_date','<=',Carbon::today())
35
					 ->where('trn_enquiry_followups.status','=',\constFollowUpStatus::Pending)
36
					 ->where('mst_enquiries.status','=',\constEnquiryStatus::Lead);
37
	}
38
39
	public function createdBy()
40
    {
41
        return $this->belongsTo('App\User','created_by');
42
    }
43
44
    public function updatedBy()
45
    {
46
        return $this->belongsTo('App\User','updated_by');
47
    }
48
}