本文整理汇总了PHP中Schema::hasCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::hasCollection方法的具体用法?PHP Schema::hasCollection怎么用?PHP Schema::hasCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schema
的用法示例。
在下文中一共展示了Schema::hasCollection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
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: boot
public static function boot()
{
parent::boot();
static::saving(function ($template) {
if (!Schema::hasCollection('templates')) {
static::createSchema();
}
static::validateTemplate($template);
});
}
示例3: testDrop
public function testDrop()
{
Schema::create('newcollection');
Schema::drop('newcollection');
$this->assertFalse(Schema::hasCollection('newcollection'));
}