Passed
Pull Request — master (#60)
by Faiq
04:26
created

DoctorSpecialization   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A trimStr() 0 6 2
A doctor() 0 2 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class DoctorSpecialization extends Model
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $table = 'doctor_specializations';
13
14
    /**
15
     * @var string
16
     */
17
    public $primaryKey = 'id';
18
19
    /**
20
     * @var bool
21
     */
22
    public $timestamps = true;
23
24
    /**
25
     * @var array
26
     */
27
    protected $dates = [
28
        'created_at',
29
        'updated_at'
30
    ];
31
32
    public function doctor() {
33
        return $this->hasOne('App\Doctor', 'specialization_id');
34
    }
35
36
    /**
37
     * @param $str
38
     * @return string
39
     */
40
    public function trimStr($str)
41
    {
42
        if(strlen($str) > 15) {
43
            return substr($str, 0, 15)."...";
44
        }
45
        return $str;
46
    }
47
}
48