// +---------------------------------------------------------------------- namespace App\Services\Common; use App\Services\BaseService; use Illuminate\Support\Facades\File; /** * 会员管理-服务类 * @author laravel开发员 * @since 2020/11/11 * Class MemberService * @package App\Services\Common */ class UploadService extends BaseService { /** * 构造函数 * @author laravel开发员 * @since 2020/11/11 * MemberService constructor. */ public function __construct() { // $this->model = new UploadModel(); } public function save($file_path, $ext, $channel) { $data = [ 'group_id' => 0, 'channel' => $channel, 'storage' => 0, 'domain' => 0, 'file_type' => 0, 'file_name' => 0, 'file_path' => $file_path, 'file_size' => File::size(public_path() . "/uploads/" . $file_path), 'file_ext' => $ext, 'cover' => $file_path, 'uploader_id' => session('userId') ?? 0, 'is_recycle' => 0, 'status' => 1, ]; // 如果 model 存在才保存到数据库 // if ($this->model) { // $error = ''; // $rowId = $this->model->edit($data, $error, false); // return $rowId; // } // 如果没有 model,直接返回 true(文件已经保存到磁盘) return true; } }