PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.3.13
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.3.13
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / modules / hrm / includes / models / leave-request.php

leave-request.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.3.13, at modules/hrm/includes/models/leave-request.php

78 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WeDevs\ERP\HRM\Models;
3
4 use WeDevs\ERP\Framework\Model;
5
6 /**
7 * Class Leave_request
8 *
9 * @package WeDevs\ERP\HRM\Models
10 */
11 class Leave_request extends Model {
12 /**
13 * Custom created_at field
14 *
15 * @since 1.2.0
16 */
17 const CREATED_AT = 'created_on';
18
19 /**
20 * Custom updated_at field
21 *
22 * @since 1.2.0
23 */
24 const UPDATED_AT = 'updated_on';
25 protected $primaryKey = 'id';
26
27 protected $table = 'erp_hr_leave_requests';
28 protected $fillable = [
29 'user_id', 'policy_id', 'days', 'start_date',
30 'end_date', 'comments', 'reason', 'status'
31 ];
32
33 /**
34 * Relation to Leave model
35 *
36 * @since 1.2.0
37 *
38 * @return object
39 */
40 public function leave() {
41 return $this->hasOne( 'WeDevs\ERP\HRM\Models\Leave', 'request_id' );
42 }
43
44 /**
45 * Relation to Leave_Policies model
46 *
47 * @since 1.2.0
48 *
49 * @return object
50 */
51 public function policy() {
52 return $this->belongsTo( 'WeDevs\ERP\HRM\Models\Leave_Policies', 'policy_id' );
53 }
54
55 /**
56 * Relation to Leave model
57 *
58 * @since 1.2.0
59 *
60 * @return object
61 */
62 public function employee() {
63 return $this->belongsTo( 'WeDevs\ERP\HRM\Models\Employee', 'user_id', 'user_id' );
64 }
65
66 public function scopeJoinWithPolicy( $query ) {
67 global $wpdb;
68 return $query->leftJoin( "{$wpdb->prefix}erp_hr_leave_policies", "{$wpdb->prefix}erp_hr_leave_policies.id", "=", "{$wpdb->prefix}erp_hr_leave_requests.policy_id" );
69 }
70
71 public function scopeJoinWithEn( $query ) {
72 global $wpdb;
73 return $query->leftJoin( "{$wpdb->prefix}erp_hr_leave_entitlements", "{$wpdb->prefix}erp_hr_leave_entitlements.policy_id", "=", "{$wpdb->prefix}erp_hr_leave_requests.policy_id" );
74 }
75
76
77 }
78