Passed
Push — master ( d58bf8...6af014 )
by Faiq
04:49
created

Hospital   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A city() 0 3 1
A doctor() 0 2 1
A trimStr() 0 6 2
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Hospital extends Model
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $table = 'hospitals';
13
14
    /**
15
     * @var string
16
     */
17
    protected $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
    /**
33
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
34
     */
35
    public function city()
36
    {
37
        return $this->belongsTo('App\City','city_id');
38
    }
39
40
    /**
41
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
42
     */
43
    public function doctor() {
44
        return $this->belongsToMany('App\Doctor', 'doctor_details', 'hospital_id', 'doctor_id');
45
    }
46
47
    /**
48
     * @param $str
49
     * @return string
50
     */
51
    public function trimStr($str)
52
    {
53
        if(strlen($str) > 10) {
54
            return substr($str, 0, 10)."...";
55
        }
56
        return $str;
57
    }
58
}
59