Actualizacuion de Rama Kquiroz
This commit is contained in:
@@ -89,7 +89,7 @@ class AddressController extends Controller
|
||||
$address->delete();
|
||||
return back();
|
||||
}
|
||||
flash(translate('Default address can not be deleted'))->warning();
|
||||
flash(translate('Default address cannot be deleted'))->warning();
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,22 @@ namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductStock;
|
||||
use App\Models\Category;
|
||||
use App\Models\ProductStock;
|
||||
use App\Models\ProductTax;
|
||||
use App\Models\ProductTranslation;
|
||||
use App\Models\Upload;
|
||||
use Artisan;
|
||||
use App\Models\User;
|
||||
use App\Services\ProductTaxService;
|
||||
use App\Notifications\ShopProductNotification;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Auth;
|
||||
|
||||
use App\Services\ProductService;
|
||||
|
||||
use App\Services\ProductStockService;
|
||||
|
||||
class DigitalProductController extends Controller
|
||||
{
|
||||
/**
|
||||
@@ -60,33 +68,34 @@ class DigitalProductController extends Controller
|
||||
return redirect()->route('seller.digitalproducts');
|
||||
}
|
||||
}
|
||||
|
||||
// Product Store
|
||||
$product = (new ProductService)->store($request->except([
|
||||
'_token', 'tax_id', 'tax', 'tax_type'
|
||||
]));
|
||||
|
||||
$product = new Product;
|
||||
$product->name = $request->name;
|
||||
$product->added_by = 'seller';
|
||||
$product->user_id = Auth::user()->id;
|
||||
$product->category_id = $request->category_id;
|
||||
$product->digital = 1;
|
||||
$product->photos = $request->photos;
|
||||
$product->thumbnail_img = $request->thumbnail_img;
|
||||
$request->merge(['product_id' => $product->id, 'current_stock' => 0]);
|
||||
|
||||
$tags = array();
|
||||
if($request->tags[0] != null){
|
||||
foreach (json_decode($request->tags[0]) as $key => $tag) {
|
||||
array_push($tags, $tag->value);
|
||||
}
|
||||
//Product Stock
|
||||
(new ProductStockService)->store($request->only([
|
||||
'unit_price', 'current_stock', 'product_id'
|
||||
]), $product);
|
||||
|
||||
//VAT & Tax
|
||||
if ($request->tax_id) {
|
||||
(new ProductTaxService)->store($request->only([
|
||||
'tax_id', 'tax', 'tax_type', 'product_id'
|
||||
]));
|
||||
}
|
||||
$product->tags = implode(',', $tags);
|
||||
|
||||
$product->description = $request->description;
|
||||
$product->unit_price = $request->unit_price;
|
||||
$product->purchase_price = $request->purchase_price;
|
||||
$product->discount = $request->discount;
|
||||
$product->discount_type = $request->discount_type;
|
||||
// Product Translations
|
||||
$request->merge(['lang' => env('DEFAULT_LANGUAGE')]);
|
||||
ProductTranslation::create($request->only([
|
||||
'lang', 'name', 'unit', 'description', 'product_id'
|
||||
]));
|
||||
|
||||
flash(translate('Product has been inserted successfully'))->success();
|
||||
|
||||
$product->meta_title = $request->meta_title;
|
||||
$product->meta_description = $request->meta_description;
|
||||
$product->meta_img = $request->meta_img;
|
||||
|
||||
$product->file_name = $request->file;
|
||||
|
||||
@@ -101,7 +110,7 @@ class DigitalProductController extends Controller
|
||||
]));
|
||||
}
|
||||
|
||||
$product_stock = new ProductStock;
|
||||
$product_stock = new ProductStock();
|
||||
$product_stock->product_id = $product->id;
|
||||
$product_stock->variant = '';
|
||||
$product_stock->price = $request->unit_price;
|
||||
@@ -115,13 +124,21 @@ class DigitalProductController extends Controller
|
||||
$product_translation->description = $request->description;
|
||||
$product_translation->save();
|
||||
|
||||
if(get_setting('product_approve_by_admin') == 1){
|
||||
$users = User::findMany([auth()->user()->id, User::where('user_type', 'admin')->first()->id]);
|
||||
Notification::send($users, new ShopProductNotification('digital', $product));
|
||||
}
|
||||
|
||||
flash(translate('Digital Product has been inserted successfully'))->success();
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('cache:clear');
|
||||
return redirect()->route('seller.digitalproducts');
|
||||
}
|
||||
else{
|
||||
flash(translate('Something went wrong'))->error();
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,84 +162,44 @@ class DigitalProductController extends Controller
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(Request $request, Product $product)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
if($request->lang == env("DEFAULT_LANGUAGE")){
|
||||
$product->name = $request->name;
|
||||
$product->description = $request->description;
|
||||
}
|
||||
//Product Update
|
||||
$product = (new ProductService)->update($request->except([
|
||||
'_token', 'tax_id', 'tax', 'tax_type'
|
||||
]), $product);
|
||||
|
||||
$product->category_id = $request->category_id;
|
||||
$product->photos = $request->photos;
|
||||
$product->thumbnail_img = $request->thumbnail_img;
|
||||
|
||||
$tags = array();
|
||||
if($request->tags[0] != null){
|
||||
foreach (json_decode($request->tags[0]) as $key => $tag) {
|
||||
array_push($tags, $tag->value);
|
||||
}
|
||||
}
|
||||
$product->tags = implode(',', $tags);
|
||||
|
||||
$product->unit_price = $request->unit_price;
|
||||
$product->purchase_price = $request->purchase_price;
|
||||
$product->discount = $request->discount;
|
||||
$product->discount_type = $request->discount_type;
|
||||
|
||||
$product->meta_title = $request->meta_title;
|
||||
$product->meta_description = $request->meta_description;
|
||||
$product->meta_img = $request->meta_img;
|
||||
$product->slug = strtolower($request->slug);
|
||||
|
||||
// if($request->hasFile('file')){
|
||||
// $product->file_name = $request->file('file')->getClientOriginalName();
|
||||
// $product->file_path = $request->file('file')->store('uploads/products/digital');
|
||||
// }
|
||||
|
||||
$product->file_name = $request->file;
|
||||
|
||||
// Delete From Product Stock
|
||||
//Product Stock
|
||||
foreach ($product->stocks as $key => $stock) {
|
||||
$stock->delete();
|
||||
}
|
||||
|
||||
if($product->save()){
|
||||
$request->merge(['product_id' => $product->id]);
|
||||
//VAT & Tax
|
||||
if ($request->tax_id) {
|
||||
ProductTax::where('product_id', $product->id)->delete();
|
||||
(new ProductTaxService)->store($request->only([
|
||||
'tax_id', 'tax', 'tax_type', 'product_id'
|
||||
]));
|
||||
}
|
||||
// Insert Into Product Stock
|
||||
$product_stock = new ProductStock;
|
||||
$product_stock->product_id = $product->id;
|
||||
$product_stock->variant = '';
|
||||
$product_stock->price = $request->unit_price;
|
||||
$product_stock->sku = '';
|
||||
$product_stock->qty = 0;
|
||||
$product_stock->save();
|
||||
|
||||
// Product Translations
|
||||
$product_translation = ProductTranslation::firstOrNew(['lang' => $request->lang, 'product_id' => $product->id]);
|
||||
$product_translation->name = $request->name;
|
||||
$product_translation->description = $request->description;
|
||||
$product_translation->save();
|
||||
|
||||
flash(translate('Digital Product has been updated successfully'))->success();
|
||||
if(Auth::user()->user_type == 'admin' || Auth::user()->user_type == 'staff'){
|
||||
return back();
|
||||
}
|
||||
else{
|
||||
return back();
|
||||
}
|
||||
}
|
||||
else{
|
||||
flash(translate('Something went wrong'))->error();
|
||||
return back();
|
||||
$request->merge(['product_id' => $product->id,'current_stock' => 0]);
|
||||
|
||||
(new ProductStockService)->store($request->only([
|
||||
'unit_price', 'current_stock', 'product_id'
|
||||
]), $product);
|
||||
|
||||
//VAT & Tax
|
||||
if ($request->tax_id) {
|
||||
ProductTax::where('product_id', $product->id)->delete();
|
||||
(new ProductTaxService)->store($request->only([
|
||||
'tax_id', 'tax', 'tax_type', 'product_id'
|
||||
]));
|
||||
}
|
||||
|
||||
// Product Translations
|
||||
ProductTranslation::updateOrCreate(
|
||||
$request->only(['lang', 'product_id']),
|
||||
$request->only(['name', 'description'])
|
||||
);
|
||||
|
||||
flash(translate('Product has been updated successfully'))->success();
|
||||
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,15 +210,16 @@ class DigitalProductController extends Controller
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
|
||||
$product->product_translations()->delete();
|
||||
$product->stocks()->delete();
|
||||
|
||||
Product::destroy($id);
|
||||
|
||||
flash(translate('Product has been deleted successfully'))->success();
|
||||
return redirect()->route('seller.digitalproducts');
|
||||
$product_destroy = (new ProductService)->destroy($id);
|
||||
|
||||
if ($product_destroy) {
|
||||
flash(translate('Product has been deleted successfully'))->success();
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('cache:clear');
|
||||
} else {
|
||||
flash(translate('Something went wrong'))->error();
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductTax;
|
||||
use App\Models\ProductTranslation;
|
||||
use App\Models\Wishlist;
|
||||
use App\Models\User;
|
||||
use App\Notifications\ShopProductNotification;
|
||||
use Carbon\Carbon;
|
||||
use Combinations;
|
||||
use Artisan;
|
||||
@@ -21,6 +24,7 @@ use App\Services\ProductService;
|
||||
use App\Services\ProductTaxService;
|
||||
use App\Services\ProductFlashDealService;
|
||||
use App\Services\ProductStockService;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
@@ -55,15 +59,8 @@ class ProductController extends Controller
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
|
||||
if (addon_is_activated('seller_subscription')) {
|
||||
if (seller_package_validity_check()) {
|
||||
$categories = Category::where('parent_id', 0)
|
||||
->where('digital', 0)
|
||||
->with('childrenCategories')
|
||||
->get();
|
||||
return view('seller.product.products.create', compact('categories'));
|
||||
} else {
|
||||
if (!seller_package_validity_check()) {
|
||||
flash(translate('Please upgrade your package.'))->warning();
|
||||
return back();
|
||||
}
|
||||
@@ -107,6 +104,11 @@ class ProductController extends Controller
|
||||
'lang', 'name', 'unit', 'description', 'product_id'
|
||||
]));
|
||||
|
||||
if(get_setting('product_approve_by_admin') == 1){
|
||||
$users = User::findMany([auth()->user()->id, User::where('user_type', 'admin')->first()->id]);
|
||||
Notification::send($users, new ShopProductNotification('physical', $product));
|
||||
}
|
||||
|
||||
flash(translate('Product has been inserted successfully'))->success();
|
||||
|
||||
Artisan::call('view:clear');
|
||||
@@ -254,11 +256,7 @@ class ProductController extends Controller
|
||||
$product->published = $request->status;
|
||||
if (addon_is_activated('seller_subscription') && $request->status == 1) {
|
||||
$shop = $product->user->shop;
|
||||
if (
|
||||
$shop->package_invalid_at == null
|
||||
|| Carbon::now()->diffInDays(Carbon::parse($shop->package_invalid_at), false) < 0
|
||||
|| $shop->product_upload_limit <= $shop->user->products()->where('published', 1)->count()
|
||||
) {
|
||||
if (!seller_package_validity_check()) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -323,6 +321,7 @@ class ProductController extends Controller
|
||||
|
||||
if (Product::destroy($id)) {
|
||||
Cart::where('product_id', $id)->delete();
|
||||
Wishlist::where('product_id', $id)->delete();
|
||||
|
||||
flash(translate('Product has been deleted successfully'))->success();
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Notifications\PayoutNotification;
|
||||
use App\Models\SellerWithdrawRequest;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
|
||||
class SellerWithdrawRequestController extends Controller
|
||||
@@ -35,6 +38,10 @@ class SellerWithdrawRequestController extends Controller
|
||||
$seller_withdraw_request->status = '0';
|
||||
$seller_withdraw_request->viewed = '0';
|
||||
if ($seller_withdraw_request->save()) {
|
||||
|
||||
$users = User::findMany([auth()->user()->id, User::where('user_type', 'admin')->first()->id]);
|
||||
Notification::send($users, new PayoutNotification(Auth::user(), $request->amount, 'pending'));
|
||||
|
||||
flash(translate('Request has been sent successfully'))->success();
|
||||
return redirect()->route('seller.money_withdraw_requests.index');
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@ namespace App\Http\Controllers\Seller;
|
||||
use App\Models\BusinessSetting;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Shop;
|
||||
use App\Models\User;
|
||||
use App\Notifications\ShopVerificationNotification;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class ShopController extends Controller
|
||||
{
|
||||
@@ -51,9 +54,9 @@ class ShopController extends Controller
|
||||
$shop->youtube = $request->youtube;
|
||||
} elseif (
|
||||
$request->has('top_banner') ||
|
||||
$request->has('sliders') ||
|
||||
$request->has('banner_full_width_1') ||
|
||||
$request->has('banners_half_width') ||
|
||||
$request->has('sliders') ||
|
||||
$request->has('banner_full_width_1') ||
|
||||
$request->has('banners_half_width') ||
|
||||
$request->has('banner_full_width_2')
|
||||
) {
|
||||
$shop->top_banner = $request->top_banner;
|
||||
@@ -72,7 +75,7 @@ class ShopController extends Controller
|
||||
return back();
|
||||
}
|
||||
|
||||
public function verify_form ()
|
||||
public function verify_form()
|
||||
{
|
||||
if (Auth::user()->shop->verification_info == null) {
|
||||
$shop = Auth::user()->shop;
|
||||
@@ -112,6 +115,9 @@ class ShopController extends Controller
|
||||
$shop = Auth::user()->shop;
|
||||
$shop->verification_info = json_encode($data);
|
||||
if ($shop->save()) {
|
||||
$users = User::findMany([auth()->user()->id, User::where('user_type', 'admin')->first()->id]);
|
||||
Notification::send($users, new ShopVerificationNotification($shop));
|
||||
|
||||
flash(translate('Your shop verification request has been submitted successfully!'))->success();
|
||||
return redirect()->route('seller.dashboard');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user