芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/store.kwesioben.com/app/Http/Controllers/api/v2/seller/auth/RegisterController.php
all(), [ 'email' => 'required|unique:sellers', 'shop_address' => 'required', 'f_name' => 'required', 'l_name' => 'required', 'shop_name' => 'required', 'phone' => 'required', 'password' => 'required|min:8', 'image' => 'required|mimes: jpg,jpeg,png,,gif', 'logo' => 'required|mimes: jpg,jpeg,png,,gif', 'banner' => 'required|mimes: jpg,jpeg,png,,gif', ]); if ($validator->fails()) { return response()->json(['errors' => Helpers::error_processor($validator)], 403); } DB::beginTransaction(); try { $seller = new Seller(); $seller->f_name = $request->f_name; $seller->l_name = $request->l_name; $seller->phone = $request->phone; $seller->email = $request->email; $seller->image = ImageManager::upload('seller/', 'png', $request->file('image')); $seller->password = bcrypt($request->password); $seller->status = $request->status == 'approved'?'approved': "pending"; $seller->save(); $shop = new Shop(); $shop->seller_id = $seller->id; $shop->name = $request->shop_name; $shop->address = $request->shop_address; $shop->contact = $request->phone; $shop->image = ImageManager::upload('shop/', 'png', $request->file('logo')); $shop->banner = ImageManager::upload('shop/banner/', 'png', $request->file('banner')); $shop->save(); DB::table('seller_wallets')->insert([ 'seller_id' => $seller['id'], 'withdrawn' => 0, 'commission_given' => 0, 'total_earning' => 0, 'pending_withdraw' => 0, 'delivery_charge_earned' => 0, 'collected_cash' => 0, 'created_at' => now(), 'updated_at' => now(), ]); DB::commit(); return response()->json(['message' => translate('Shop apply successfully!')], 200); } catch (\Exception $e) { DB::rollback(); return response()->json(['message' => translate('Shop apply fail!')], 403); } } }