disk)->delete($file->getRawOriginal('path')); }); } /** * Get the user that uploaded the file. * * @return void */ public function uploader() { return $this->belongsTo(User::class); } /** * Get the file's path. * * @param string $path * @return string|null */ public function getPathAttribute($path) { if (! is_null($path)) { return Storage::disk($this->disk)->url($path); } } /** * Get file's real path. * * @return void */ public function realPath() { if (! is_null($this->attributes['path'])) { return Storage::disk($this->disk)->path($this->attributes['path']); } } /** * Determine if the file type is image. * * @return bool */ public function isImage() { return strtok($this->mime, '/') === 'image'; } /** * Get the file's icon. * * @return string */ public function icon() { return IconResolver::resolve($this->mime); } /** * Get table data for the resource * * @return \Illuminate\Http\JsonResponse */ public function table($request) { $query = $this->newQuery() ->when(! is_null($request->type) && $request->type !== 'null', function ($query) use ($request) { $query->where('mime', 'LIKE', "{$request->type}/%"); }); return new MediaTable($query); } }