PHP Schema::hasCollection Examples

PHP Schema::hasCollection - 3 examples found. These are the top rated real world PHP examples of Schema::hasCollection extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #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();
     });
 }
Example #2
0
 public static function boot()
 {
     parent::boot();
     static::saving(function ($template) {
         if (!Schema::hasCollection('templates')) {
             static::createSchema();
         }
         static::validateTemplate($template);
     });
 }
 public function testDrop()
 {
     Schema::create('newcollection');
     Schema::drop('newcollection');
     $this->assertFalse(Schema::hasCollection('newcollection'));
 }