public function editStore(request $request) { $store_id = Auth::user()->stores->id; $store = MerchantStore::find($store_id); foreach ($request->only('store_name', 'cost_two', 'status', 'landline', 'veg', 'description') as $key => $value) { $store->{$key} = $value; } if ($request->hasFile('logo')) { $image = $request->file('logo'); $imageName = strtotime(Carbon::now()) . md5($store_id) . '.' . $image->getClientOriginalExtension(); $path = public_path('assets/img/stores/' . $imageName); Image::make($image->getRealPath())->resize(280, null, function ($constraint) { $constraint->aspectRatio(); })->save($path); $store->logoUrl = $imageName; } $store->save(); $store->tags()->detach(); $tags = $request->only('tags'); $tagStore = explode(',', $tags['tags']); $store->tags()->attach($tagStore); $matchThese = ['store_id' => $store_id]; $address = MerchantStoreAddress::where($matchThese)->first(); foreach ($request->only('street', 'area_id', 'city_id', 'state_id', 'country_id', 'pincode', 'latitude', 'longitude') as $key => $value) { $address->{$key} = $value; } $address->save(); $output = ['store' => $store, 'address' => $address]; return response()->json(['response_code' => 'RES_SU', 'messages' => 'Store Upadated', 'data' => $output]); }
public function updateStore(request $request) { $validator = Validator::make($request->all(), ['store_id' => 'required', 'store_name' => 'required|max:255', 'landline' => 'required', 'cost_two' => 'required', 'veg' => 'required', 'status' => 'required', 'street' => 'required|max:200', 'area_id' => 'required', 'city_id' => 'required', 'state_id' => 'required', 'country_id' => 'required', 'pincode' => 'required', 'latitude' => 'required', 'longitude' => 'required']); $input = $request->only('store_id'); if ($validator->fails()) { return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator); } $store = MerchantStore::find($input['store_id']); foreach ($request->only('store_name', 'cost_two', 'veg', 'landline', 'status') as $key => $value) { $store->{$key} = $value; } if ($request->hasFile('logo')) { $image = $request->file('logo'); $imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension(); $path = public_path('assets/img/stores/' . $imageName); Image::make($image->getRealPath())->resize(280, null, function ($constraint) { $constraint->aspectRatio(); })->save($path); $store->logoUrl = $imageName; } $store->save(); $store->tags()->detach(); $tags = $request->only('tags'); $tagStore = explode(',', $tags['tags']); $store->tags()->attach($tagStore); $matchThese = ['store_id' => $input['store_id']]; $address = MerchantStoreAddress::where($matchThese)->first(); foreach ($request->only('street', 'area_id', 'city_id', 'state_id', 'country_id', 'pincode', 'latitude', 'longitude') as $key => $value) { $address->{$key} = $value; } $address->save(); return redirect('admin/store/' . $input['store_id']); }
public function editStoreAddress(request $request) { $input = $request->only('store_id', 'address_id'); if (!$this->checkUserHasStore($input['store_id'], false)) { return response()->json(['response_code' => 'ERR_UNA', 'messages' => 'User Not Authorized'], 403); } $matchThese = ['id' => $input['address_id'], 'store_id' => $input['store_id']]; $address = MerchantStoreAddress::where($matchThese)->first(); foreach ($request->except('store_id', 'address_id', 'api_key') as $key => $value) { $address->{$key} = $value; } $address->save(); return response()->json(['response_code' => 'RES_SAU', 'messages' => 'Store Address Upadated', 'data' => $address]); }