Completed
Push — master ( 13dcb2...db0ae1 )
by Davide
13:57
created

EventVenue::getVenueName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace DavideCasiraghi\LaravelEventsCalendar\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class EventVenue extends Model
8
{
9
    /***************************************************************************/
10
    /**
11
     * The table associated with the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'event_venues';
16
17
    /***************************************************************************/
18
19
    protected $fillable = [
20
        'name', 'slug', 'continent_id', 'country_id', 'city', 'state_province', 'address', 'zip_code', 'description', 'website', 'created_by', 'created_at', 'updated_at',
21
    ];
22
23
    /***************************************************************************/
24
25
    /**
26
     * Return the venue name - used by - /http/resources/event.php.
27
     *
28
     * @param int $venueId
29
     * @return string
30
     */
31 1
    public static function getVenueName($venueId)
32
    {
33 1
        $ret = self::find($venueId)->name;
34
35 1
        return $ret;
36
    }
37
    
38
    /***************************************************************************/
39
40
    /**
41
     * Return true if the Venue contains any event
42
     *
43
     * @param int $venueId
44
     * @return string
45
     */
46 4
    public static function venueContainsEvents($venueId)
47
    {    
48 4
        $events = Event::where('venue_id', '=', $venueId)->first();
49 4
        if ($events === null) {
50 2
           $ret = false;
51
        }
52
        else{
53 2
            $ret = true;
54
        }
55
        
56 4
        return $ret;
57
    }
58
59
}
60