/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $versions = AssetVersion::whereNull('extension')->get();
     foreach ($versions as $v) {
         $v->extension = File::extensionFromMimetype($v->mimetype);
         $v->save();
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::update('alter table asset_versions add extension varchar(10)');
     $versions = AssetVersion::all();
     foreach ($versions as $v) {
         preg_match('|\\.([a-z]+)$|', $v->filename, $matches);
         if (isset($matches[1])) {
             $v->extension = $matches[1];
             $v->save();
         }
     }
 }
Esempio n. 3
0
 public function boot()
 {
     parent::boot();
     Models\Asset::observe(CreationLogObserver::class);
     Models\AssetVersion::observe(CreationLogObserver::class);
     Models\Page::observe(CreationLogObserver::class);
     Models\PageVersion::observe(CreationLogObserver::class);
     Models\Asset::observe(SetSiteObserver::class);
     Models\Group::observe(SetSiteObserver::class);
     Models\Page::observe(SetSiteObserver::class);
     Models\Tag::observe(SetSiteObserver::class);
     Models\URL::observe(SetSiteObserver::class);
     Models\Page::observe(DeletionLogObserver::class);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::statement('alter table asset_versions add mimetype varchar(255)');
     $versions = AssetVersion::all();
     $directory = storage_path('boomcms/assets');
     foreach ($versions as $v) {
         $path = realpath($directory . DIRECTORY_SEPARATOR . $v->id);
         if ($path) {
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
             $mime = finfo_file($finfo, $path);
             finfo_close($finfo);
             if ($mime) {
                 $v->mimetype = $mime;
                 $v->save();
             }
         }
     }
 }
 public function testGetAssetId()
 {
     $v = new V([V::ATTR_ASSET => 1]);
     $this->assertEquals($v->{V::ATTR_ASSET}, $v->getAssetId());
     $this->assertInternalType('int', $v->getAssetId());
 }