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

Hospital::doctor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
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