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', 'region_id', 'city', 'state_province', 'address', 'zip_code', 'extra_info', ' lat', 'lng', 'description', 'website', 'created_by', 'created_at', 'updated_at', |
21
|
|
|
]; |
22
|
|
|
|
23
|
|
|
/***************************************************************************/ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Get the user that owns the event. eg. $eventVenue->user |
27
|
|
|
*/ |
28
|
|
|
public function user() |
29
|
|
|
{ |
30
|
|
|
return $this->belongsTo('\Illuminate\Foundation\Auth\User', 'created_by'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/***************************************************************************/ |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Return the venue name - used by - /http/resources/event.php. |
37
|
|
|
* |
38
|
|
|
* @param int $venueId |
39
|
|
|
* @return string |
40
|
|
|
*/ |
41
|
1 |
|
public static function getVenueName($venueId) |
42
|
|
|
{ |
43
|
1 |
|
$ret = self::find($venueId)->name; |
44
|
|
|
|
45
|
1 |
|
return $ret; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/***************************************************************************/ |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Return true if the Venue contains any event. |
52
|
|
|
* |
53
|
|
|
* @param int $venueId |
54
|
|
|
* @return bool |
55
|
|
|
*/ |
56
|
4 |
|
public static function venueContainsEvents($venueId) |
57
|
|
|
{ |
58
|
4 |
|
$events = Event::where('venue_id', '=', $venueId)->first(); |
59
|
4 |
|
if ($events === null) { |
60
|
2 |
|
$ret = false; |
61
|
|
|
} else { |
62
|
2 |
|
$ret = true; |
63
|
|
|
} |
64
|
|
|
|
65
|
4 |
|
return $ret; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|