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

EventVenue::venueContainsEvents()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
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