Пример #1
0
 protected static function boot()
 {
     parent::boot();
     static::creating(function ($entity) {
         if (!Schema::hasCollection('entities')) {
             static::createSchema();
         }
         if (empty($entity->project)) {
             throw new Exception("No project was given");
         }
         if (!empty($entity->hash) && !empty($entity->project)) {
             if (Entity::withTrashed()->where('hash', $entity->hash)->where('project', $entity->project)->first()) {
                 throw new Exception("Hash already exists for: " . $entity->title . " in project " . $entity->project);
             }
         }
         $entity->_id = static::generateIncrementedBaseURI($entity);
         if (Auth::check()) {
             $entity->user_id = Auth::user()->_id;
         } else {
             $entity->user_id = "crowdtruth";
         }
     });
     static::saved(function ($entity) {
         Temp::truncate();
         Cache::flush();
     });
     static::deleted(function ($entity) {
         Cache::flush();
     });
 }
Пример #2
0
 public function __construct($id = '', $label = '')
 {
     $attributes = [];
     parent::__construct($attributes);
     $this->_id = $id;
     $this->label = $label;
 }
Пример #3
0
 public static function boot()
 {
     parent::boot();
     static::saving(function ($template) {
         if (!Schema::hasCollection('templates')) {
             static::createSchema();
         }
         static::validateTemplate($template);
     });
 }
Пример #4
0
 public function __construct()
 {
     $this->filterResults();
     parent::__construct();
 }