/** * Handle the command. * * @param Repository $config * @return int|null|string */ public function handle(Repository $config) { foreach ($config->get('anomaly.module.files::mimes.types') as $type => $extensions) { if (in_array($this->file->getExtension(), $extensions)) { return $type; } } return null; }
/** * Return a file preview. * * @param int $width * @param int $height * @return string */ public function preview($width = 48, $height = 48) { if (in_array($this->object->getExtension(), $this->config->get('anomaly.module.files::mimes.thumbnails'))) { return $this->object->image()->fit($width, $height)->class('img-rounded'); } $type = $this->dispatch(new GetType($this->object)) ?: 'document'; return $this->image->make('anomaly.module.files::img/types/' . $type . '.png')->height($height)->image(); }
/** * Return the type of the mime. * * @return int|null|string */ public function type() { foreach ($this->config->get('anomaly.module.files::mimes.types') as $type => $extensions) { if (in_array($this->object->getExtension(), $extensions)) { return $type; } } return null; }