-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSalary.php
63 lines (54 loc) · 1.24 KB
/
Salary.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Salary extends Model
{
public $dates = [
'paid_for',
];
protected $fillable = [
'user_id', 'base_salary', 'paid_amount', 'paid_for', 'pf', 'tds', 'bonus', 'penalty', 'payment_method',
'paid_note', 'general_note',
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}
/**
* Get records salary paid for month.
*
* @param $query
* @param null $month
* @return mixed
*/
public function scopePaidForMonth($query, $date = null)
{
if ($date == null) {
$date = today()->format('Y-m-d');
}
return $query->where('paid_for', $date);
}
/**
* Suggested name of PDF file.
*
* @return string
*/
public function paySlipFileName()
{
return "payslip{$this->user_id}-{$this->paid_for->format('F-Y')}.pdf";
}
/**
* Get binary of PDF.
*
* @return \Barryvdh\DomPDF\PDF
*/
public function paySlipPDF()
{
return \PDF::loadView('letter.payslip', [
'salary' => $this,
]);
}
}