/** * Execute the job. */ public function handle() { /** * Create Extra * @var Extra $extra */ $this->extra->update($this->data); $aspectDir = @$this->data['aspect_ratio'] ?: '16x9'; /** * Move Extra Content to folder */ $path = '/image/products-extras/'; $productCode = $this->product->getAttribute('code'); if ($this->image) { $imageName = $productCode . '-extra-image-' . $this->extra->id . '.' . $this->image->guessExtension(); $this->image->move(base_path() . $path, $imageName); $this->extra->setAttribute('image', $path . $imageName); } if ($this->video) { $videoName = $productCode . '-extra-video-' . $this->extra->id . '.' . $this->video->guessExtension(); $this->video->move(base_path() . $path . $aspectDir . '/', $videoName); $this->extra->setAttribute('video', $videoName); } $this->extra->save(); /** * Announce ExtraWasUpdated */ event(new ExtraWasUpdated($this->extra)); }
/** * Execute the job. */ public function handle() { $path = '/image/products-extras/16x9/'; unlink(base_path() . $path . $this->extra->video); unlink(base_path() . $this->extra->image); $this->extra->delete(); /** * Announce ExtraWasUpdated */ event(new ExtraWasUpdated($this->extra)); }
private function getVideoPath($extra_id, $aspect = '16x9') { $extra = Extra::find($extra_id); if (!is_dir(base_path("/image/products-extras/{$aspect}"))) { $aspect = '16x9'; } return base_path("/image/products-extras/{$aspect}/{$extra->video}"); }
/** * Delete package. * @param [int] $package_id [description] * @return [type] [description] */ public function deletePackage($package_id) { $extras = Extra::where('package_id', $package_id)->get(); foreach ($extras as $key => $value) { Extrafile::where('extra_id', $value->id)->where('is_attached', 1)->delete(); Extra::find($value->id)->delete(); } Package::find($package_id)->delete(); }
/** * @param $extraId * @param string $errorType * @param string $aspect * @return \Illuminate\Http\JsonResponse */ protected function getProductVideoPath($extraId, $errorType = '', $aspect = '') { $aspect = $aspect ?: '16x9'; if (!is_dir($this->publicpath . $this->extra_path . $aspect)) { $aspect = '16x9'; } $codes = $this->getUserCodes($extraId, $errorType); $extra = Extra::find($extraId); $this->filepath = $this->extra_path . $aspect . '/' . @$extra->video; return $codes; }