2016-02-29 15:59:36 +00:00
|
|
|
<?php namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Str;
|
|
|
|
|
|
|
|
|
|
class Organiser extends MyBaseModel {
|
|
|
|
|
|
|
|
|
|
protected $rules = array(
|
|
|
|
|
'name' => array('required'),
|
|
|
|
|
'email' => array('required', 'email'),
|
|
|
|
|
'organiser_logo' => ['mimes:jpeg,jpg,png', 'max:10000']
|
|
|
|
|
);
|
|
|
|
|
protected $messages = array(
|
|
|
|
|
'name.required' => 'You must at least give a name for the event organiser.',
|
|
|
|
|
'organiser_logo.max' => 'Please upload an image smaller than 10Mb',
|
|
|
|
|
'organiser_logo.size' => 'Please upload an image smaller than 10Mb',
|
|
|
|
|
'organiser_logo.mimes' => 'Please select a valid image type (jpeg, jpg, png)'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
public function events() {
|
|
|
|
|
return $this->hasMany('\App\Models\Event');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function attendees() {
|
|
|
|
|
return $this->hasManyThrough('\App\Models\Attendee', '\App\Models\Event');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getFullLogoPathAttribute() {
|
2016-03-04 23:27:13 +00:00
|
|
|
if($this->logo_path && (file_exists(config('attendize.cdn_url_user_assets').'/'.$this->logo_path) || file_exists(public_path($this->logo_path)))) {
|
|
|
|
|
return config('attendize.cdn_url_user_assets').'/'.$this->logo_path;
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-04 23:27:13 +00:00
|
|
|
return config('attendize.fallback_organiser_logo_url');
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getOrganiserUrlAttribute() {
|
|
|
|
|
return route('showOrganiserHome', [
|
|
|
|
|
'organiser_id' => $this->id,
|
|
|
|
|
'organiser_slug' => Str::slug($this->oraganiser_name)
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getOrganiserSalesVolumeAttribute() {
|
|
|
|
|
return $this->events->sum('sales_volume');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDailyStats() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|