Actualizacion de Diseño Logins y Parte de Registro Negocios
This commit is contained in:
129
desarrollo/app/Http/Controllers/Seller/AddressController.php
Normal file
129
desarrollo/app/Http/Controllers/Seller/AddressController.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Address;
|
||||
use App\Models\City;
|
||||
use App\Models\State;
|
||||
use Auth;
|
||||
|
||||
class AddressController extends Controller
|
||||
{
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$address = new Address;
|
||||
$address->user_id = Auth::user()->id;
|
||||
$address->address = $request->address;
|
||||
$address->country_id = $request->country_id;
|
||||
$address->state_id = $request->state_id;
|
||||
$address->city_id = $request->city_id;
|
||||
$address->longitude = $request->longitude;
|
||||
$address->latitude = $request->latitude;
|
||||
$address->postal_code = $request->postal_code;
|
||||
$address->phone = $request->phone;
|
||||
$address->save();
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['address_data'] = Address::findOrFail($id);
|
||||
$data['states'] = State::where('status', 1)->where('country_id', $data['address_data']->country_id)->get();
|
||||
$data['cities'] = City::where('status', 1)->where('state_id', $data['address_data']->state_id)->get();
|
||||
|
||||
$returnHTML = view('seller.profile.address_edit_modal', $data)->render();
|
||||
return response()->json(array('data' => $data, 'html'=>$returnHTML));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$address = Address::findOrFail($id);
|
||||
|
||||
$address->address = $request->address;
|
||||
$address->country_id = $request->country_id;
|
||||
$address->state_id = $request->state_id;
|
||||
$address->city_id = $request->city_id;
|
||||
$address->longitude = $request->longitude;
|
||||
$address->latitude = $request->latitude;
|
||||
$address->postal_code = $request->postal_code;
|
||||
$address->phone = $request->phone;
|
||||
|
||||
$address->save();
|
||||
|
||||
flash(translate('Address info updated successfully'))->success();
|
||||
return back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$address = Address::findOrFail($id);
|
||||
if(!$address->set_default){
|
||||
$address->delete();
|
||||
return back();
|
||||
}
|
||||
flash(translate('Default address can not be deleted'))->warning();
|
||||
return back();
|
||||
}
|
||||
|
||||
public function getStates(Request $request) {
|
||||
$states = State::where('status', 1)->where('country_id', $request->country_id)->get();
|
||||
$html = '<option value="">'.translate("Select State").'</option>';
|
||||
|
||||
foreach ($states as $state) {
|
||||
$html .= '<option value="' . $state->id . '">' . $state->name . '</option>';
|
||||
}
|
||||
|
||||
echo json_encode($html);
|
||||
}
|
||||
|
||||
public function getCities(Request $request) {
|
||||
$cities = City::where('status', 1)->where('state_id', $request->state_id)->get();
|
||||
$html = '<option value="">'.translate("Select City").'</option>';
|
||||
|
||||
foreach ($cities as $row) {
|
||||
$html .= '<option value="' . $row->id . '">' . $row->getTranslation('name') . '</option>';
|
||||
}
|
||||
|
||||
echo json_encode($html);
|
||||
}
|
||||
|
||||
public function set_default($id){
|
||||
foreach (Auth::user()->addresses as $key => $address) {
|
||||
$address->set_default = 0;
|
||||
$address->save();
|
||||
}
|
||||
$address = Address::findOrFail($id);
|
||||
$address->set_default = 1;
|
||||
$address->save();
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\CommissionHistory;
|
||||
use Auth;
|
||||
|
||||
class CommissionHistoryController extends Controller
|
||||
{
|
||||
public function index(Request $request) {
|
||||
$seller_id = null;
|
||||
$date_range = null;
|
||||
|
||||
$commission_history = CommissionHistory::where('seller_id', Auth::user()->id)->orderBy('created_at', 'desc');
|
||||
|
||||
if ($request->date_range) {
|
||||
$date_range = $request->date_range;
|
||||
$date_range1 = explode(" / ", $request->date_range);
|
||||
$commission_history = $commission_history->where('created_at', '>=', $date_range1[0]);
|
||||
$commission_history = $commission_history->where('created_at', '<=', $date_range1[1]);
|
||||
}
|
||||
|
||||
$commission_history = $commission_history->paginate(10);
|
||||
return view('seller.commission_history.index', compact('commission_history', 'seller_id', 'date_range'));
|
||||
}
|
||||
}
|
||||
13
desarrollo/app/Http/Controllers/Seller/Controller.php
Normal file
13
desarrollo/app/Http/Controllers/Seller/Controller.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Conversation;
|
||||
use App\Models\BusinessSetting;
|
||||
use App\Models\Message;
|
||||
use App\Models\ProductQuery;
|
||||
use Auth;
|
||||
|
||||
class ConversationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (BusinessSetting::where('type', 'conversation_system')->first()->value == 1) {
|
||||
$conversations = Conversation::where('sender_id', Auth::user()->id)->orWhere('receiver_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
|
||||
return view('seller.conversations.index', compact('conversations'));
|
||||
} else {
|
||||
flash(translate('Conversation is disabled at this moment'))->warning();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$conversation = Conversation::findOrFail(decrypt($id));
|
||||
if ($conversation->sender_id == Auth::user()->id) {
|
||||
$conversation->sender_viewed = 1;
|
||||
} elseif ($conversation->receiver_id == Auth::user()->id) {
|
||||
$conversation->receiver_viewed = 1;
|
||||
}
|
||||
$conversation->save();
|
||||
return view('seller.conversations.show', compact('conversation'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function refresh(Request $request)
|
||||
{
|
||||
$conversation = Conversation::findOrFail(decrypt($request->id));
|
||||
if ($conversation->sender_id == Auth::user()->id) {
|
||||
$conversation->sender_viewed = 1;
|
||||
$conversation->save();
|
||||
} else {
|
||||
$conversation->receiver_viewed = 1;
|
||||
$conversation->save();
|
||||
}
|
||||
return view('frontend.partials.messages', compact('conversation'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function message_store(Request $request)
|
||||
{
|
||||
$message = new Message;
|
||||
$message->conversation_id = $request->conversation_id;
|
||||
$message->user_id = Auth::user()->id;
|
||||
$message->message = $request->message;
|
||||
$message->save();
|
||||
$conversation = $message->conversation;
|
||||
if ($conversation->sender_id == Auth::user()->id) {
|
||||
$conversation->receiver_viewed = "1";
|
||||
} elseif ($conversation->receiver_id == Auth::user()->id) {
|
||||
$conversation->sender_viewed = "1";
|
||||
}
|
||||
$conversation->save();
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
126
desarrollo/app/Http/Controllers/Seller/CouponController.php
Normal file
126
desarrollo/app/Http/Controllers/Seller/CouponController.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\CouponRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Coupon;
|
||||
use Auth;
|
||||
|
||||
class CouponController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$coupons = Coupon::where('user_id', Auth::user()->id)->orderBy('id','desc')->get();
|
||||
return view('seller.coupons.index', compact('coupons'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('seller.coupons.create');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(CouponRequest $request)
|
||||
{
|
||||
$user_id = Auth::user()->id;
|
||||
Coupon::create($request->validated() + [
|
||||
'user_id' => $user_id,
|
||||
]);
|
||||
|
||||
flash(translate('Coupon has been saved successfully.'))->success();
|
||||
return redirect()->route('seller.coupon.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$coupon = Coupon::findOrFail(decrypt($id));
|
||||
return view('seller.coupons.edit', compact('coupon'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(CouponRequest $request, Coupon $coupon)
|
||||
{
|
||||
$coupon->update($request->validated());
|
||||
|
||||
flash(translate('Coupon has been updated successfully'))->success();
|
||||
return redirect()->route('seller.coupon.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
Coupon::destroy($id);
|
||||
flash(translate('Coupon has been deleted successfully'))->success();
|
||||
return redirect()->route('seller.coupon.index');
|
||||
}
|
||||
|
||||
public function get_coupon_form(Request $request)
|
||||
{
|
||||
if($request->coupon_type == "product_base") {
|
||||
$products = filter_products(\App\Models\Product::where('user_id', Auth::user()->id))->get();
|
||||
return view('partials.coupons.product_base_coupon', compact('products'));
|
||||
}
|
||||
elseif($request->coupon_type == "cart_base"){
|
||||
return view('partials.coupons.cart_base_coupon');
|
||||
}
|
||||
}
|
||||
|
||||
public function get_coupon_form_edit(Request $request)
|
||||
{
|
||||
if($request->coupon_type == "product_base") {
|
||||
$coupon = Coupon::findOrFail($request->id);
|
||||
$products = filter_products(\App\Models\Product::where('user_id', Auth::user()->id))->get();
|
||||
return view('partials.coupons.product_base_coupon_edit',compact('coupon', 'products'));
|
||||
}
|
||||
elseif($request->coupon_type == "cart_base"){
|
||||
$coupon = Coupon::findOrFail($request->id);
|
||||
return view('partials.coupons.cart_base_coupon_edit',compact('coupon'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\Product;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data['products'] = filter_products(Product::where('user_id', Auth::user()->id)->orderBy('num_of_sale', 'desc'))->limit(12)->get();
|
||||
$data['last_7_days_sales'] = Order::where('created_at', '>=', Carbon::now()->subDays(7))
|
||||
->where('seller_id', '=', Auth::user()->id)
|
||||
->where('delivery_status', '=', 'delivered')
|
||||
->select(DB::raw("sum(grand_total) as total, DATE_FORMAT(created_at, '%d %b') as date"))
|
||||
->groupBy(DB::raw("DATE_FORMAT(created_at, '%Y-%m-%d')"))
|
||||
->get()->pluck('total', 'date');
|
||||
|
||||
return view('seller.dashboard', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductStock;
|
||||
use App\Models\Category;
|
||||
use App\Models\ProductTax;
|
||||
use App\Models\ProductTranslation;
|
||||
use App\Models\Upload;
|
||||
use App\Services\ProductTaxService;
|
||||
use Auth;
|
||||
|
||||
class DigitalProductController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$products = Product::where('user_id', Auth::user()->id)->where('digital', 1)->orderBy('created_at', 'desc')->paginate(10);
|
||||
return view('seller.product.digitalproducts.index', compact('products'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
if(addon_is_activated('seller_subscription')){
|
||||
if(seller_package_validity_check()){
|
||||
$categories = Category::where('digital', 1)->get();
|
||||
return view('seller.product.digitalproducts.create', compact('categories'));
|
||||
}
|
||||
else {
|
||||
flash(translate('Please upgrade your package.'))->warning();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
$categories = Category::where('digital', 1)->get();
|
||||
return view('seller.product.digitalproducts.create', compact('categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
if(addon_is_activated('seller_subscription')){
|
||||
if(!seller_package_validity_check()){
|
||||
flash(translate('Please upgrade your package.'))->warning();
|
||||
return redirect()->route('seller.digitalproducts');
|
||||
}
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
$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->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->meta_title = $request->meta_title;
|
||||
$product->meta_description = $request->meta_description;
|
||||
$product->meta_img = $request->meta_img;
|
||||
|
||||
$product->file_name = $request->file;
|
||||
|
||||
$product->slug = preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $request->name)).'-'.rand(10000,99999);
|
||||
|
||||
if($product->save()){
|
||||
$request->merge(['product_id' => $product->id]);
|
||||
//VAT & Tax
|
||||
if ($request->tax_id) {
|
||||
(new ProductTaxService)->store($request->only([
|
||||
'tax_id', 'tax', 'tax_type', 'product_id'
|
||||
]));
|
||||
}
|
||||
|
||||
$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' => env('DEFAULT_LANGUAGE'), 'product_id' => $product->id]);
|
||||
$product_translation->name = $request->name;
|
||||
$product_translation->description = $request->description;
|
||||
$product_translation->save();
|
||||
|
||||
flash(translate('Digital Product has been inserted successfully'))->success();
|
||||
return redirect()->route('seller.digitalproducts');
|
||||
}
|
||||
else{
|
||||
flash(translate('Something went wrong'))->error();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$categories = Category::where('digital', 1)->get();
|
||||
$lang = $request->lang;
|
||||
$product = Product::find($id);
|
||||
return view('seller.product.digitalproducts.edit', compact('categories', 'product', 'lang'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
if($request->lang == env("DEFAULT_LANGUAGE")){
|
||||
$product->name = $request->name;
|
||||
$product->description = $request->description;
|
||||
}
|
||||
|
||||
$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
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
public function download(Request $request){
|
||||
$product = Product::findOrFail(decrypt($request->id));
|
||||
if(Auth::user()->id == $product->user_id){
|
||||
$upload = Upload::findOrFail($product->file_name);
|
||||
if (env('FILESYSTEM_DRIVER') == "s3") {
|
||||
return \Storage::disk('s3')->download($upload->file_name, $upload->file_original_name.".".$upload->extension);
|
||||
}
|
||||
else {
|
||||
if (file_exists(base_path('public/'.$upload->file_name))) {
|
||||
return response()->download(base_path('public/'.$upload->file_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
desarrollo/app/Http/Controllers/Seller/InvoiceController.php
Normal file
92
desarrollo/app/Http/Controllers/Seller/InvoiceController.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Models\Currency;
|
||||
use App\Models\Language;
|
||||
use App\Models\Order;
|
||||
use Session;
|
||||
use PDF;
|
||||
use Config;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
//download invoice
|
||||
public function invoice_download($id)
|
||||
{
|
||||
if(Session::has('currency_code')){
|
||||
$currency_code = Session::get('currency_code');
|
||||
}
|
||||
else{
|
||||
$currency_code = Currency::findOrFail(get_setting('system_default_currency'))->code;
|
||||
}
|
||||
$language_code = Session::get('locale', Config::get('app.locale'));
|
||||
|
||||
if(Language::where('code', $language_code)->first()->rtl == 1){
|
||||
$direction = 'rtl';
|
||||
$text_align = 'right';
|
||||
$not_text_align = 'left';
|
||||
}else{
|
||||
$direction = 'ltr';
|
||||
$text_align = 'left';
|
||||
$not_text_align = 'right';
|
||||
}
|
||||
|
||||
if($currency_code == 'BDT' || $language_code == 'bd'){
|
||||
// bengali font
|
||||
$font_family = "'Hind Siliguri','sans-serif'";
|
||||
}elseif($currency_code == 'KHR' || $language_code == 'kh'){
|
||||
// khmer font
|
||||
$font_family = "'Hanuman','sans-serif'";
|
||||
}elseif($currency_code == 'AMD'){
|
||||
// Armenia font
|
||||
$font_family = "'arnamu','sans-serif'";
|
||||
// }elseif($currency_code == 'ILS'){
|
||||
// // Israeli font
|
||||
// $font_family = "'Varela Round','sans-serif'";
|
||||
}elseif($currency_code == 'AED' || $currency_code == 'EGP' || $language_code == 'sa' || $currency_code == 'IQD' || $language_code == 'ir' || $language_code == 'om' || $currency_code == 'ROM' || $currency_code == 'SDG' || $currency_code == 'ILS'|| $language_code == 'jo'){
|
||||
// middle east/arabic/Israeli font
|
||||
$font_family = "'Baloo Bhaijaan 2','sans-serif'";
|
||||
}elseif($currency_code == 'THB'){
|
||||
// thai font
|
||||
$font_family = "'Kanit','sans-serif'";
|
||||
} elseif (
|
||||
$currency_code == 'CNY' ||
|
||||
$language_code == 'zh'
|
||||
) {
|
||||
// Chinese font
|
||||
$font_family = "'yahei','sans-serif'";
|
||||
} elseif (
|
||||
$currency_code == 'kyat' ||
|
||||
$language_code == 'mm'
|
||||
) {
|
||||
// Myanmar font
|
||||
$font_family = "'pyidaungsu','sans-serif'";
|
||||
} elseif (
|
||||
$currency_code == 'THB' ||
|
||||
$language_code == 'th'
|
||||
) {
|
||||
// Thai font
|
||||
$font_family = "'zawgyi-one','sans-serif'";
|
||||
}else{
|
||||
// general for all
|
||||
$font_family = "'Roboto','sans-serif'";
|
||||
}
|
||||
|
||||
// $config = ['instanceConfigurator' => function($mpdf) {
|
||||
// $mpdf->showImageErrors = true;
|
||||
// }];
|
||||
// mpdf config will be used in 4th params of loadview
|
||||
|
||||
$config = [];
|
||||
|
||||
$order = Order::findOrFail($id);
|
||||
return PDF::loadView('backend.invoices.invoice',[
|
||||
'order' => $order,
|
||||
'font_family' => $font_family,
|
||||
'direction' => $direction,
|
||||
'text_align' => $text_align,
|
||||
'not_text_align' => $not_text_align
|
||||
], [], $config)->download('order-'.$order->code.'.pdf');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Auth;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
$notifications = auth()->user()->notifications()->paginate(15);
|
||||
auth()->user()->unreadNotifications->markAsRead();
|
||||
|
||||
return view('seller.notification.index', compact('notifications'));
|
||||
}
|
||||
}
|
||||
192
desarrollo/app/Http/Controllers/Seller/OrderController.php
Normal file
192
desarrollo/app/Http/Controllers/Seller/OrderController.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\ProductStock;
|
||||
use App\Models\SmsTemplate;
|
||||
use App\Models\User;
|
||||
use App\Utility\NotificationUtility;
|
||||
use App\Utility\SmsUtility;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use DB;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource to seller.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$payment_status = null;
|
||||
$delivery_status = null;
|
||||
$sort_search = null;
|
||||
$orders = DB::table('orders')
|
||||
->orderBy('id', 'desc')
|
||||
->where('seller_id', Auth::user()->id)
|
||||
->select('orders.id')
|
||||
->distinct();
|
||||
|
||||
if ($request->payment_status != null) {
|
||||
$orders = $orders->where('payment_status', $request->payment_status);
|
||||
$payment_status = $request->payment_status;
|
||||
}
|
||||
if ($request->delivery_status != null) {
|
||||
$orders = $orders->where('delivery_status', $request->delivery_status);
|
||||
$delivery_status = $request->delivery_status;
|
||||
}
|
||||
if ($request->has('search')) {
|
||||
$sort_search = $request->search;
|
||||
$orders = $orders->where('code', 'like', '%' . $sort_search . '%');
|
||||
}
|
||||
|
||||
$orders = $orders->paginate(15);
|
||||
|
||||
foreach ($orders as $key => $value) {
|
||||
$order = Order::find($value->id);
|
||||
$order->viewed = 1;
|
||||
$order->save();
|
||||
}
|
||||
|
||||
return view('seller.orders.index', compact('orders', 'payment_status', 'delivery_status', 'sort_search'));
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$order = Order::findOrFail(decrypt($id));
|
||||
$order_shipping_address = json_decode($order->shipping_address);
|
||||
$delivery_boys = User::where('city', $order_shipping_address->city)
|
||||
->where('user_type', 'delivery_boy')
|
||||
->get();
|
||||
|
||||
$order->viewed = 1;
|
||||
$order->save();
|
||||
return view('seller.orders.show', compact('order', 'delivery_boys'));
|
||||
}
|
||||
|
||||
// Update Delivery Status
|
||||
public function update_delivery_status(Request $request)
|
||||
{
|
||||
$order = Order::findOrFail($request->order_id);
|
||||
$order->delivery_viewed = '0';
|
||||
$order->delivery_status = $request->status;
|
||||
$order->save();
|
||||
|
||||
if ($request->status == 'cancelled' && $order->payment_type == 'wallet') {
|
||||
$user = User::where('id', $order->user_id)->first();
|
||||
$user->balance += $order->grand_total;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
|
||||
foreach ($order->orderDetails->where('seller_id', Auth::user()->id) as $key => $orderDetail) {
|
||||
$orderDetail->delivery_status = $request->status;
|
||||
$orderDetail->save();
|
||||
|
||||
if ($request->status == 'cancelled') {
|
||||
$variant = $orderDetail->variation;
|
||||
if ($orderDetail->variation == null) {
|
||||
$variant = '';
|
||||
}
|
||||
|
||||
$product_stock = ProductStock::where('product_id', $orderDetail->product_id)
|
||||
->where('variant', $variant)
|
||||
->first();
|
||||
|
||||
if ($product_stock != null) {
|
||||
$product_stock->qty += $orderDetail->quantity;
|
||||
$product_stock->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addon_is_activated('otp_system') && SmsTemplate::where('identifier', 'delivery_status_change')->first()->status == 1) {
|
||||
try {
|
||||
SmsUtility::delivery_status_change(json_decode($order->shipping_address)->phone, $order);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//sends Notifications to user
|
||||
NotificationUtility::sendNotification($order, $request->status);
|
||||
if (get_setting('google_firebase') == 1 && $order->user->device_token != null) {
|
||||
$request->device_token = $order->user->device_token;
|
||||
$request->title = "Order updated !";
|
||||
$status = str_replace("_", "", $order->delivery_status);
|
||||
$request->text = " Your order {$order->code} has been {$status}";
|
||||
|
||||
$request->type = "order";
|
||||
$request->id = $order->id;
|
||||
$request->user_id = $order->user->id;
|
||||
|
||||
NotificationUtility::sendFirebaseNotification($request);
|
||||
}
|
||||
|
||||
|
||||
if (addon_is_activated('delivery_boy')) {
|
||||
if (Auth::user()->user_type == 'delivery_boy') {
|
||||
$deliveryBoyController = new DeliveryBoyController;
|
||||
$deliveryBoyController->store_delivery_history($order);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Update Payment Status
|
||||
public function update_payment_status(Request $request)
|
||||
{
|
||||
$order = Order::findOrFail($request->order_id);
|
||||
$order->payment_status_viewed = '0';
|
||||
$order->save();
|
||||
|
||||
foreach ($order->orderDetails->where('seller_id', Auth::user()->id) as $key => $orderDetail) {
|
||||
$orderDetail->payment_status = $request->status;
|
||||
$orderDetail->save();
|
||||
}
|
||||
|
||||
$status = 'paid';
|
||||
foreach ($order->orderDetails as $key => $orderDetail) {
|
||||
if ($orderDetail->payment_status != 'paid') {
|
||||
$status = 'unpaid';
|
||||
}
|
||||
}
|
||||
$order->payment_status = $status;
|
||||
$order->save();
|
||||
|
||||
|
||||
if ($order->payment_status == 'paid' && $order->commission_calculated == 0) {
|
||||
calculateCommissionAffilationClubPoint($order);
|
||||
}
|
||||
|
||||
//sends Notifications to user
|
||||
NotificationUtility::sendNotification($order, $request->status);
|
||||
if (get_setting('google_firebase') == 1 && $order->user->device_token != null) {
|
||||
$request->device_token = $order->user->device_token;
|
||||
$request->title = "Order updated !";
|
||||
$status = str_replace("_", "", $order->payment_status);
|
||||
$request->text = " Your order {$order->code} has been {$status}";
|
||||
|
||||
$request->type = "order";
|
||||
$request->id = $order->id;
|
||||
$request->user_id = $order->user->id;
|
||||
|
||||
NotificationUtility::sendFirebaseNotification($request);
|
||||
}
|
||||
|
||||
|
||||
if (addon_is_activated('otp_system') && SmsTemplate::where('identifier', 'payment_status_change')->first()->status == 1) {
|
||||
try {
|
||||
SmsUtility::payment_status_change(json_decode($order->shipping_address)->phone, $order);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
20
desarrollo/app/Http/Controllers/Seller/PaymentController.php
Normal file
20
desarrollo/app/Http/Controllers/Seller/PaymentController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Auth;
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$payments = Payment::where('seller_id', Auth::user()->id)->paginate(9);
|
||||
return view('seller.payment_history', compact('payments'));
|
||||
}
|
||||
}
|
||||
409
desarrollo/app/Http/Controllers/Seller/PosController.php
Normal file
409
desarrollo/app/Http/Controllers/Seller/PosController.php
Normal file
@@ -0,0 +1,409 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\OrderDetail;
|
||||
use App\Models\ProductStock;
|
||||
use App\Models\Product;
|
||||
use App\Models\Order;
|
||||
use App\Models\City;
|
||||
use App\Models\User;
|
||||
use App\Models\Address;
|
||||
use App\Models\Addon;
|
||||
use Session;
|
||||
use Auth;
|
||||
use Mail;
|
||||
use App\Mail\InvoiceEmailManager;
|
||||
use App\Http\Resources\PosProductCollection;
|
||||
use App\Models\Country;
|
||||
use App\Models\NfcVoucher;
|
||||
use App\Models\State;
|
||||
use App\Utility\CategoryUtility;
|
||||
use App\Utility\FontUtility;
|
||||
use App\Utility\PosUtility;
|
||||
use Mpdf\Mpdf;
|
||||
|
||||
class PosController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$customers = User::where('user_type', 'customer')->where('email_verified_at', '!=', null)->orderBy('created_at', 'desc')->get();
|
||||
if (get_setting('pos_activation_for_seller') == 1) {
|
||||
return view('seller.pos.index', compact('customers'));
|
||||
}
|
||||
else {
|
||||
flash(translate('POS is disable for Sellers!!!'))->error();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
$products = PosUtility::product_search($request->only('category', 'brand', 'keyword'));
|
||||
|
||||
$stocks = new PosProductCollection($products);
|
||||
$stocks->appends(['keyword' => $request->keyword, 'category' => $request->category, 'brand' => $request->brand]);
|
||||
return $stocks;
|
||||
}
|
||||
|
||||
public function addToCart(Request $request)
|
||||
{
|
||||
$stock = ProductStock::find($request->stock_id);
|
||||
$product = $stock->product;
|
||||
|
||||
$data = array();
|
||||
$data['stock_id'] = $request->stock_id;
|
||||
$data['id'] = $product->id;
|
||||
$data['variant'] = $stock->variant;
|
||||
$data['quantity'] = $product->min_qty;
|
||||
|
||||
if($stock->qty < $product->min_qty && $product->digital == 0){
|
||||
return array('success' => 0, 'message' => translate("This product doesn't have enough stock for minimum purchase quantity ").$product->min_qty, 'view' => view('backend.pos.cart')->render());
|
||||
}
|
||||
|
||||
$tax = 0;
|
||||
$price = $stock->price;
|
||||
|
||||
// discount calculation
|
||||
$discount_applicable = false;
|
||||
if ($product->discount_start_date == null) {
|
||||
$discount_applicable = true;
|
||||
}
|
||||
elseif (strtotime(date('d-m-Y H:i:s')) >= $product->discount_start_date &&
|
||||
strtotime(date('d-m-Y H:i:s')) <= $product->discount_end_date) {
|
||||
$discount_applicable = true;
|
||||
}
|
||||
if ($discount_applicable) {
|
||||
if($product->discount_type == 'percent'){
|
||||
$price -= ($price*$product->discount)/100;
|
||||
}
|
||||
elseif($product->discount_type == 'amount'){
|
||||
$price -= $product->discount;
|
||||
}
|
||||
}
|
||||
|
||||
//tax calculation
|
||||
foreach ($product->taxes as $product_tax) {
|
||||
if($product_tax->tax_type == 'percent'){
|
||||
$tax += ($price * $product_tax->tax) / 100;
|
||||
}
|
||||
elseif($product_tax->tax_type == 'amount'){
|
||||
$tax += $product_tax->tax;
|
||||
}
|
||||
}
|
||||
|
||||
$data['price'] = $price;
|
||||
$data['tax'] = $tax;
|
||||
|
||||
if($request->session()->has('pos.cart')){
|
||||
$foundInCart = false;
|
||||
$cart = collect();
|
||||
|
||||
foreach ($request->session()->get('pos.cart') as $key => $cartItem){
|
||||
|
||||
if($cartItem['id'] == $product->id && $cartItem['stock_id'] == $stock->id){
|
||||
$foundInCart = true;
|
||||
|
||||
if($product->digital == 0){
|
||||
$loop_product = Product::find($cartItem['id']);
|
||||
$product_stock = $loop_product->stocks->where('variant', $cartItem['variant'])->first();
|
||||
|
||||
if($product->digital == 1 || $product_stock->qty >= ($cartItem['quantity'] + 1)){
|
||||
$cartItem['quantity'] += 1;
|
||||
}else{
|
||||
return array('success' => 0, 'message' => translate("This product doesn't have more stock."), 'view' => view('backend.pos.cart')->render());
|
||||
}
|
||||
}
|
||||
else{
|
||||
return array('success' => 0, 'message' => translate("This product is alreday in the cart"), 'view' => view('backend.pos.cart')->render());
|
||||
}
|
||||
|
||||
}
|
||||
$cart->push($cartItem);
|
||||
}
|
||||
|
||||
if (!$foundInCart) {
|
||||
$cart->push($data);
|
||||
}
|
||||
$request->session()->put('pos.cart', $cart);
|
||||
}
|
||||
else{
|
||||
$cart = collect([$data]);
|
||||
$request->session()->put('pos.cart', $cart);
|
||||
}
|
||||
|
||||
$request->session()->put('pos.cart', $cart);
|
||||
|
||||
return array('success' => 1, 'message' => '', 'view' => view('backend.pos.cart')->render());
|
||||
}
|
||||
|
||||
//updated the quantity for a cart item
|
||||
public function updateQuantity(Request $request)
|
||||
{
|
||||
$cart = $request->session()->get('pos.cart', collect([]));
|
||||
$cart = $cart->map(function ($object, $key) use ($request) {
|
||||
if($key == $request->key){
|
||||
$product = Product::find($object['id']);
|
||||
$product_stock = $product->stocks->where('id', $object['stock_id'])->first();
|
||||
|
||||
if($product_stock->qty >= $request->quantity){
|
||||
$object['quantity'] = $request->quantity;
|
||||
}else{
|
||||
return array('success' => 0, 'message' => translate("This product doesn't have more stock."), 'view' => view('backend.pos.cart')->render());
|
||||
}
|
||||
}
|
||||
return $object;
|
||||
});
|
||||
$request->session()->put('pos.cart', $cart);
|
||||
|
||||
return array('success' => 1, 'message' => '', 'view' => view('backend.pos.cart')->render());
|
||||
}
|
||||
|
||||
//removes from Cart
|
||||
public function removeFromCart(Request $request)
|
||||
{
|
||||
if(Session::has('pos.cart')){
|
||||
$cart = Session::get('pos.cart', collect([]));
|
||||
$cart->forget($request->key);
|
||||
Session::put('pos.cart', $cart);
|
||||
|
||||
$request->session()->put('pos.cart', $cart);
|
||||
}
|
||||
|
||||
return view('backend.pos.cart');
|
||||
}
|
||||
|
||||
//Shipping Address for seller
|
||||
public function getShippingAddressForSeller(Request $request)
|
||||
{
|
||||
$user_id = $request->id;
|
||||
return ($user_id == '') ?
|
||||
view('seller.pos.guest_shipping_address') :
|
||||
view('seller.pos.shipping_address', compact('user_id'));
|
||||
}
|
||||
|
||||
public function set_shipping_address(Request $request)
|
||||
{
|
||||
$data = PosUtility::get_shipping_address($request);
|
||||
|
||||
$shipping_info = $data;
|
||||
$request->session()->put('pos.shipping_info', $shipping_info);
|
||||
}
|
||||
|
||||
//set Discount
|
||||
public function setDiscount(Request $request){
|
||||
if($request->discount >= 0){
|
||||
Session::put('pos.discount', $request->discount);
|
||||
}
|
||||
return view('backend.pos.cart');
|
||||
}
|
||||
|
||||
//set Shipping Cost
|
||||
public function setShipping(Request $request){
|
||||
if($request->shipping != null){
|
||||
Session::put('pos.shipping', $request->shipping);
|
||||
}
|
||||
return view('backend.pos.cart');
|
||||
}
|
||||
|
||||
//order summary
|
||||
public function get_order_summary(Request $request){
|
||||
return view('backend.pos.order_summary');
|
||||
}
|
||||
|
||||
//order place
|
||||
public function order_store(Request $request){
|
||||
if(Session::get('pos.shipping_info') == null || Session::get('pos.shipping_info')['name'] == null || Session::get('pos.shipping_info')['phone'] == null || Session::get('pos.shipping_info')['address'] == null){
|
||||
return array('success' => 0, 'message' => translate("Please Add Shipping Information."));
|
||||
}
|
||||
|
||||
if(Session::has('pos.cart') && count(Session::get('pos.cart')) > 0){
|
||||
$order = new Order;
|
||||
|
||||
if ($request->user_id == null) {
|
||||
$order->guest_id = mt_rand(100000, 999999);
|
||||
}
|
||||
else {
|
||||
$order->user_id = $request->user_id;
|
||||
}
|
||||
|
||||
$order->shipping_address = json_encode(Session::get('pos.shipping_info'));
|
||||
|
||||
$order->payment_type = $request->payment_type;
|
||||
$order->delivery_viewed = '0';
|
||||
$order->payment_status_viewed = '0';
|
||||
$order->code = date('Ymd-His').rand(10,99);
|
||||
$order->date = strtotime('now');
|
||||
$order->payment_status = $request->payment_type != 'cash_on_delivery' ? 'paid' : 'unpaid';
|
||||
$order->payment_details = $request->payment_type;
|
||||
$order->order_from = 'pos';
|
||||
|
||||
if($request->payment_type == 'offline_payment'){
|
||||
if($request->offline_trx_id == null){
|
||||
return array('success' => 0, 'message' => translate("Transaction ID can not be null."));
|
||||
}
|
||||
$data['name'] = $request->offline_payment_method;
|
||||
$data['amount'] = $request->offline_payment_amount;
|
||||
$data['trx_id'] = $request->offline_trx_id;
|
||||
$data['photo'] = $request->offline_payment_proof;
|
||||
$order->manual_payment_data = json_encode($data);
|
||||
$order->manual_payment = 1;
|
||||
}
|
||||
|
||||
if($order->save()){
|
||||
$subtotal = 0;
|
||||
$tax = 0;
|
||||
foreach (Session::get('pos.cart') as $key => $cartItem){
|
||||
$product_stock = ProductStock::find($cartItem['stock_id']);
|
||||
$product = $product_stock->product;
|
||||
$product_variation = $product_stock->variant;
|
||||
|
||||
$subtotal += $cartItem['price']*$cartItem['quantity'];
|
||||
$tax += $cartItem['tax']*$cartItem['quantity'];
|
||||
|
||||
if($product->digital == 0){
|
||||
if($cartItem['quantity'] > $product_stock->qty){
|
||||
$order->delete();
|
||||
return array('success' => 0, 'message' => $product->name.' ('.$product_variation.') '.translate(" just stock outs."));
|
||||
}
|
||||
else {
|
||||
$product_stock->qty -= $cartItem['quantity'];
|
||||
$product_stock->save();
|
||||
}
|
||||
}
|
||||
|
||||
$order_detail = new OrderDetail;
|
||||
$order_detail->order_id =$order->id;
|
||||
$order_detail->seller_id = $product->user_id;
|
||||
$order_detail->product_id = $product->id;
|
||||
$order_detail->payment_status = $request->payment_type != 'cash_on_delivery' ? 'paid' : 'unpaid';
|
||||
$order_detail->variation = $product_variation;
|
||||
$order_detail->price = $cartItem['price'] * $cartItem['quantity'];
|
||||
$order_detail->tax = $cartItem['tax'] * $cartItem['quantity'];
|
||||
$order_detail->quantity = $cartItem['quantity'];
|
||||
$order_detail->shipping_type = null;
|
||||
|
||||
if (Session::get('pos.shipping', 0) >= 0){
|
||||
$order_detail->shipping_cost = Session::get('pos.shipping', 0)/count(Session::get('pos.cart'));
|
||||
}
|
||||
else {
|
||||
$order_detail->shipping_cost = 0;
|
||||
}
|
||||
|
||||
$order_detail->save();
|
||||
|
||||
$product->num_of_sale++;
|
||||
$product->save();
|
||||
}
|
||||
|
||||
$order->grand_total = $subtotal + $tax + Session::get('pos.shipping', 0);
|
||||
|
||||
if(Session::has('pos.discount')){
|
||||
$order->grand_total -= Session::get('pos.discount');
|
||||
$order->coupon_discount = Session::get('pos.discount');
|
||||
}
|
||||
|
||||
$order->seller_id = $product->user_id;
|
||||
$order->save();
|
||||
|
||||
$array['view'] = 'emails.invoice';
|
||||
$array['subject'] = 'Your order has been placed - '.$order->code;
|
||||
$array['from'] = env('MAIL_USERNAME');
|
||||
$array['order'] = $order;
|
||||
|
||||
$admin_products = array();
|
||||
$seller_products = array();
|
||||
|
||||
foreach ($order->orderDetails as $key => $orderDetail){
|
||||
if($orderDetail->product->added_by == 'admin'){
|
||||
array_push($admin_products, $orderDetail->product->id);
|
||||
}
|
||||
else{
|
||||
$product_ids = array();
|
||||
if(array_key_exists($orderDetail->product->user_id, $seller_products)){
|
||||
$product_ids = $seller_products[$orderDetail->product->user_id];
|
||||
}
|
||||
array_push($product_ids, $orderDetail->product->id);
|
||||
$seller_products[$orderDetail->product->user_id] = $product_ids;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($seller_products as $key => $seller_product){
|
||||
try {
|
||||
Mail::to(User::find($key)->email)->queue(new InvoiceEmailManager($array));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//sends email to customer with the invoice pdf attached
|
||||
if(env('MAIL_USERNAME') != null){
|
||||
try {
|
||||
Mail::to($request->session()->get('pos.shipping_info')['email'])->queue(new InvoiceEmailManager($array));
|
||||
Mail::to(User::where('user_type', 'admin')->first()->email)->queue(new InvoiceEmailManager($array));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($request->user_id != NULL && $order->payment_status == 'paid') {
|
||||
calculateCommissionAffilationClubPoint($order);
|
||||
}
|
||||
|
||||
Session::forget('pos.shipping_info');
|
||||
Session::forget('pos.shipping');
|
||||
Session::forget('pos.discount');
|
||||
Session::forget('pos.cart');
|
||||
return array('success' => 1, 'message' => translate('Order Completed Successfully.'));
|
||||
}
|
||||
else {
|
||||
return array('success' => 0, 'message' => translate('Please input customer information.'));
|
||||
}
|
||||
}
|
||||
return array('success' => 0, 'message' => translate("Please select a product."));
|
||||
}
|
||||
|
||||
public function configuration()
|
||||
{
|
||||
|
||||
//AQUI AGREGO LA CONSULTA donde traigo los comprobantes desde el ultimo que agrego que se muestre primero
|
||||
$nfc_vouchers = $nfc_vouchers = NfcVoucher::latest()->get();
|
||||
|
||||
|
||||
return view('seller.pos.pos_activation', compact('nfc_vouchers'));
|
||||
}
|
||||
|
||||
public function invoice($id)
|
||||
{
|
||||
$order = Order::findOrFail($id);
|
||||
if(auth()->user()->id != $order->seller_id) {
|
||||
return back();
|
||||
}
|
||||
$print_width = get_setting('print_width_seller_pos');
|
||||
if ($print_width == null) {
|
||||
flash(translate('Print Size does not set for thermal printer from POS configuration'))->warning();
|
||||
return back();
|
||||
}
|
||||
|
||||
$pdf_style_data = FontUtility::get_font_family();
|
||||
|
||||
$html = view('backend.pos.thermal_invoice', compact('order', 'pdf_style_data'));
|
||||
|
||||
$mpdf = new Mpdf(['mode' => 'utf-8', 'format' => [$print_width, 1000]]);
|
||||
$mpdf->WriteHTML($html);
|
||||
// $mpdf->WriteHTML('<h1>Hello world!</h1>');
|
||||
$mpdf->page = 0;
|
||||
$mpdf->state = 0;
|
||||
unset($mpdf->pages[0]);
|
||||
// The $p needs to be passed by reference
|
||||
$p = 'P';
|
||||
// dd($mpdf->y);
|
||||
$mpdf->_setPageSize(array($print_width, $mpdf->y), $p);
|
||||
|
||||
$mpdf->addPage();
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
$mpdf->Output('order-' . $order->code . '.pdf', 'I');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Category;
|
||||
use App\Models\Brand;
|
||||
use Auth;
|
||||
use App\Models\ProductsImport;
|
||||
use PDF;
|
||||
use Excel;
|
||||
|
||||
class ProductBulkUploadController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if(Auth::user()->shop->verification_status){
|
||||
return view('seller.product.product_bulk_upload.index');
|
||||
}
|
||||
else{
|
||||
flash(translate('Your shop is not verified yet!'))->warning();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
public function pdf_download_category()
|
||||
{
|
||||
$categories = Category::all();
|
||||
|
||||
return PDF::loadView('backend.downloads.category',[
|
||||
'categories' => $categories,
|
||||
], [], [])->download('category.pdf');
|
||||
}
|
||||
|
||||
public function pdf_download_brand()
|
||||
{
|
||||
$brands = Brand::all();
|
||||
|
||||
return PDF::loadView('backend.downloads.brand',[
|
||||
'brands' => $brands,
|
||||
], [], [])->download('brands.pdf');
|
||||
}
|
||||
|
||||
public function bulk_upload(Request $request)
|
||||
{
|
||||
if($request->hasFile('bulk_file')){
|
||||
$import = new ProductsImport;
|
||||
Excel::import($import, request()->file('bulk_file'));
|
||||
}
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
349
desarrollo/app/Http/Controllers/Seller/ProductController.php
Normal file
349
desarrollo/app/Http/Controllers/Seller/ProductController.php
Normal file
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use AizPackages\CombinationGenerate\Services\CombinationService;
|
||||
use App\Http\Requests\ProductRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\AttributeValue;
|
||||
use App\Models\Cart;
|
||||
use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductTax;
|
||||
use App\Models\ProductTranslation;
|
||||
use Carbon\Carbon;
|
||||
use Combinations;
|
||||
use Artisan;
|
||||
use Auth;
|
||||
use Str;
|
||||
|
||||
use App\Services\ProductService;
|
||||
use App\Services\ProductTaxService;
|
||||
use App\Services\ProductFlashDealService;
|
||||
use App\Services\ProductStockService;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
protected $productService;
|
||||
protected $productTaxService;
|
||||
protected $productFlashDealService;
|
||||
protected $productStockService;
|
||||
|
||||
public function __construct(
|
||||
ProductService $productService,
|
||||
ProductTaxService $productTaxService,
|
||||
ProductFlashDealService $productFlashDealService,
|
||||
ProductStockService $productStockService
|
||||
) {
|
||||
$this->productService = $productService;
|
||||
$this->productTaxService = $productTaxService;
|
||||
$this->productFlashDealService = $productFlashDealService;
|
||||
$this->productStockService = $productStockService;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$search = null;
|
||||
$products = Product::where('user_id', Auth::user()->id)->where('digital', 0)->where('auction_product', 0)->where('wholesale_product', 0)->orderBy('created_at', 'desc');
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$products = $products->where('name', 'like', '%' . $search . '%');
|
||||
}
|
||||
$products = $products->paginate(10);
|
||||
return view('seller.product.products.index', compact('products', 'search'));
|
||||
}
|
||||
|
||||
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 {
|
||||
flash(translate('Please upgrade your package.'))->warning();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
$categories = Category::where('parent_id', 0)
|
||||
->where('digital', 0)
|
||||
->with('childrenCategories')
|
||||
->get();
|
||||
return view('seller.product.products.create', compact('categories'));
|
||||
}
|
||||
|
||||
public function store(ProductRequest $request)
|
||||
{
|
||||
if (addon_is_activated('seller_subscription')) {
|
||||
if (!seller_package_validity_check()) {
|
||||
flash(translate('Please upgrade your package.'))->warning();
|
||||
return redirect()->route('seller.products');
|
||||
}
|
||||
}
|
||||
|
||||
$product = $this->productService->store($request->except([
|
||||
'_token', 'sku', 'choice', 'tax_id', 'tax', 'tax_type', 'flash_deal_id', 'flash_discount', 'flash_discount_type'
|
||||
]));
|
||||
$request->merge(['product_id' => $product->id]);
|
||||
|
||||
//VAT & Tax
|
||||
if ($request->tax_id) {
|
||||
$this->productTaxService->store($request->only([
|
||||
'tax_id', 'tax', 'tax_type', 'product_id'
|
||||
]));
|
||||
}
|
||||
|
||||
//Product Stock
|
||||
$this->productStockService->store($request->only([
|
||||
'colors_active', 'colors', 'choice_no', 'unit_price', 'sku', 'current_stock', 'product_id'
|
||||
]), $product);
|
||||
|
||||
// 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();
|
||||
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return redirect()->route('seller.products');
|
||||
}
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
|
||||
if (Auth::user()->id != $product->user_id) {
|
||||
flash(translate('This product is not yours.'))->warning();
|
||||
return back();
|
||||
}
|
||||
|
||||
$lang = $request->lang;
|
||||
$tags = json_decode($product->tags);
|
||||
$categories = Category::where('parent_id', 0)
|
||||
->where('digital', 0)
|
||||
->with('childrenCategories')
|
||||
->get();
|
||||
return view('seller.product.products.edit', compact('product', 'categories', 'tags', 'lang'));
|
||||
}
|
||||
|
||||
public function update(ProductRequest $request, Product $product)
|
||||
{
|
||||
//Product
|
||||
$product = $this->productService->update($request->except([
|
||||
'_token', 'sku', 'choice', 'tax_id', 'tax', 'tax_type', 'flash_deal_id', 'flash_discount', 'flash_discount_type'
|
||||
]), $product);
|
||||
|
||||
//Product Stock
|
||||
foreach ($product->stocks as $key => $stock) {
|
||||
$stock->delete();
|
||||
}
|
||||
$request->merge(['product_id' => $product->id]);
|
||||
$this->productStockService->store($request->only([
|
||||
'colors_active', 'colors', 'choice_no', 'unit_price', 'sku', 'current_stock', 'product_id'
|
||||
]), $product);
|
||||
|
||||
//VAT & Tax
|
||||
if ($request->tax_id) {
|
||||
ProductTax::where('product_id', $product->id)->delete();
|
||||
$request->merge(['product_id' => $product->id]);
|
||||
$this->productTaxService->store($request->only([
|
||||
'tax_id', 'tax', 'tax_type', 'product_id'
|
||||
]));
|
||||
}
|
||||
|
||||
// Product Translations
|
||||
ProductTranslation::updateOrCreate(
|
||||
$request->only([
|
||||
'lang', 'product_id'
|
||||
]),
|
||||
$request->only([
|
||||
'name', 'unit', 'description'
|
||||
])
|
||||
);
|
||||
|
||||
|
||||
flash(translate('Product has been updated successfully'))->success();
|
||||
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function sku_combination(Request $request)
|
||||
{
|
||||
$options = array();
|
||||
if ($request->has('colors_active') && $request->has('colors') && count($request->colors) > 0) {
|
||||
$colors_active = 1;
|
||||
array_push($options, $request->colors);
|
||||
} else {
|
||||
$colors_active = 0;
|
||||
}
|
||||
|
||||
$unit_price = $request->unit_price;
|
||||
$product_name = $request->name;
|
||||
|
||||
if ($request->has('choice_no')) {
|
||||
foreach ($request->choice_no as $key => $no) {
|
||||
$name = 'choice_options_' . $no;
|
||||
$data = array();
|
||||
foreach ($request[$name] as $key => $item) {
|
||||
array_push($data, $item);
|
||||
}
|
||||
array_push($options, $data);
|
||||
}
|
||||
}
|
||||
|
||||
$combinations = (new CombinationService())->generate_combination($options);
|
||||
return view('backend.product.products.sku_combinations', compact('combinations', 'unit_price', 'colors_active', 'product_name'));
|
||||
}
|
||||
|
||||
public function sku_combination_edit(Request $request)
|
||||
{
|
||||
$product = Product::findOrFail($request->id);
|
||||
|
||||
$options = array();
|
||||
if ($request->has('colors_active') && $request->has('colors') && count($request->colors) > 0) {
|
||||
$colors_active = 1;
|
||||
array_push($options, $request->colors);
|
||||
} else {
|
||||
$colors_active = 0;
|
||||
}
|
||||
|
||||
$product_name = $request->name;
|
||||
$unit_price = $request->unit_price;
|
||||
|
||||
if ($request->has('choice_no')) {
|
||||
foreach ($request->choice_no as $key => $no) {
|
||||
$name = 'choice_options_' . $no;
|
||||
$data = array();
|
||||
foreach ($request[$name] as $key => $item) {
|
||||
array_push($data, $item);
|
||||
}
|
||||
array_push($options, $data);
|
||||
}
|
||||
}
|
||||
|
||||
$combinations = (new CombinationService())->generate_combination($options);
|
||||
return view('backend.product.products.sku_combinations_edit', compact('combinations', 'unit_price', 'colors_active', 'product_name', 'product'));
|
||||
}
|
||||
|
||||
public function add_more_choice_option(Request $request)
|
||||
{
|
||||
$all_attribute_values = AttributeValue::with('attribute')->where('attribute_id', $request->attribute_id)->get();
|
||||
|
||||
$html = '';
|
||||
|
||||
foreach ($all_attribute_values as $row) {
|
||||
$html .= '<option value="' . $row->value . '">' . $row->value . '</option>';
|
||||
}
|
||||
|
||||
echo json_encode($html);
|
||||
}
|
||||
|
||||
public function updatePublished(Request $request)
|
||||
{
|
||||
$product = Product::findOrFail($request->id);
|
||||
$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()
|
||||
) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
$product->save();
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function updateFeatured(Request $request)
|
||||
{
|
||||
$product = Product::findOrFail($request->id);
|
||||
$product->seller_featured = $request->status;
|
||||
if ($product->save()) {
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('cache:clear');
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function duplicate($id)
|
||||
{
|
||||
$product = Product::find($id);
|
||||
|
||||
if (Auth::user()->id != $product->user_id) {
|
||||
flash(translate('This product is not yours.'))->warning();
|
||||
return back();
|
||||
}
|
||||
|
||||
if (addon_is_activated('seller_subscription')) {
|
||||
if (!seller_package_validity_check()) {
|
||||
flash(translate('Please upgrade your package.'))->warning();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
//Product
|
||||
$product_new = $this->productService->product_duplicate_store($product);
|
||||
|
||||
//Product Stock
|
||||
$this->productStockService->product_duplicate_store($product->stocks, $product_new);
|
||||
|
||||
//VAT & Tax
|
||||
$this->productTaxService->product_duplicate_store($product->taxes, $product_new);
|
||||
|
||||
flash(translate('Product has been duplicated successfully'))->success();
|
||||
return redirect()->route('seller.products');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
|
||||
if (Auth::user()->id != $product->user_id) {
|
||||
flash(translate('This product is not yours.'))->warning();
|
||||
return back();
|
||||
}
|
||||
|
||||
$product->product_translations()->delete();
|
||||
$product->stocks()->delete();
|
||||
$product->taxes()->delete();
|
||||
|
||||
|
||||
if (Product::destroy($id)) {
|
||||
Cart::where('product_id', $id)->delete();
|
||||
|
||||
flash(translate('Product has been deleted successfully'))->success();
|
||||
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return back();
|
||||
} else {
|
||||
flash(translate('Something went wrong'))->error();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
public function bulk_product_delete(Request $request)
|
||||
{
|
||||
if ($request->id) {
|
||||
foreach ($request->id as $product_id) {
|
||||
$this->destroy($product_id);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ProductQuery;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProductQueryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Retrieve queries that belongs to current seller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$queries = ProductQuery::where('seller_id', Auth::id())->latest()->paginate(20);
|
||||
return view('seller.product_query.index', compact('queries'));
|
||||
}
|
||||
/**
|
||||
* Retrieve specific query using query id.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$query = ProductQuery::find(decrypt($id));
|
||||
return view('seller.product_query.show', compact('query'));
|
||||
}
|
||||
/**
|
||||
* Store reply against the question from seller panel
|
||||
*/
|
||||
|
||||
public function reply(Request $request, $id)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'reply' => 'required',
|
||||
]);
|
||||
$query = ProductQuery::find($id);
|
||||
$query->reply = $request->reply;
|
||||
$query->save();
|
||||
flash(translate('Replied successfully!'))->success();
|
||||
return redirect()->route('seller.product_query.index');
|
||||
}
|
||||
}
|
||||
66
desarrollo/app/Http/Controllers/Seller/ProfileController.php
Normal file
66
desarrollo/app/Http/Controllers/Seller/ProfileController.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Http\Requests\SellerProfileRequest;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Hash;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$user = Auth::user();
|
||||
$addresses = $user->addresses;
|
||||
return view('seller.profile.index', compact('user','addresses'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(SellerProfileRequest $request , $id)
|
||||
{
|
||||
if(env('DEMO_MODE') == 'On'){
|
||||
flash(translate('Sorry! the action is not permitted in demo '))->error();
|
||||
return back();
|
||||
}
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
$user->name = $request->name;
|
||||
$user->phone = $request->phone;
|
||||
|
||||
if($request->new_password != null && ($request->new_password == $request->confirm_password)){
|
||||
$user->password = Hash::make($request->new_password);
|
||||
}
|
||||
|
||||
$user->avatar_original = $request->photo;
|
||||
|
||||
$shop = $user->shop;
|
||||
|
||||
if($shop){
|
||||
$shop->cash_on_delivery_status = $request->cash_on_delivery_status;
|
||||
$shop->bank_payment_status = $request->bank_payment_status;
|
||||
$shop->bank_name = $request->bank_name;
|
||||
$shop->bank_acc_name = $request->bank_acc_name;
|
||||
$shop->bank_acc_no = $request->bank_acc_no;
|
||||
$shop->bank_routing_no = $request->bank_routing_no;
|
||||
|
||||
$shop->save();
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
flash(translate('Your Profile has been updated successfully!'))->success();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
30
desarrollo/app/Http/Controllers/Seller/ReviewController.php
Normal file
30
desarrollo/app/Http/Controllers/Seller/ReviewController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use DB;
|
||||
|
||||
class ReviewController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$reviews = DB::table('reviews')
|
||||
->orderBy('id', 'desc')
|
||||
->join('products', 'reviews.product_id', '=', 'products.id')
|
||||
->where('products.user_id', Auth::user()->id)
|
||||
->select('reviews.id')
|
||||
->distinct()
|
||||
->paginate(9);
|
||||
|
||||
foreach ($reviews as $key => $value) {
|
||||
$review = \App\Models\Review::find($value->id);
|
||||
$review->viewed = 1;
|
||||
$review->save();
|
||||
}
|
||||
|
||||
return view('seller.reviews', compact('reviews'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\SellerWithdrawRequest;
|
||||
use Auth;
|
||||
|
||||
class SellerWithdrawRequestController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$seller_withdraw_requests = SellerWithdrawRequest::where('user_id', Auth::user()->id)->latest()->paginate(9);
|
||||
return view('seller.money_withdraw_requests.index', compact('seller_withdraw_requests'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$seller_withdraw_request = new SellerWithdrawRequest;
|
||||
$seller_withdraw_request->user_id = Auth::user()->id;
|
||||
$seller_withdraw_request->amount = $request->amount;
|
||||
$seller_withdraw_request->message = $request->message;
|
||||
$seller_withdraw_request->status = '0';
|
||||
$seller_withdraw_request->viewed = '0';
|
||||
if ($seller_withdraw_request->save()) {
|
||||
flash(translate('Request has been sent successfully'))->success();
|
||||
return redirect()->route('seller.money_withdraw_requests.index');
|
||||
}
|
||||
else{
|
||||
flash(translate('Something went wrong'))->error();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
126
desarrollo/app/Http/Controllers/Seller/ShopController.php
Normal file
126
desarrollo/app/Http/Controllers/Seller/ShopController.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Models\BusinessSetting;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Shop;
|
||||
use Auth;
|
||||
|
||||
class ShopController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$shop = Auth::user()->shop;
|
||||
return view('seller.shop', compact('shop'));
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$shop = Shop::find($request->shop_id);
|
||||
|
||||
if ($request->has('name') && $request->has('address')) {
|
||||
if ($request->has('shipping_cost')) {
|
||||
$shop->shipping_cost = $request->shipping_cost;
|
||||
}
|
||||
|
||||
$shop->name = $request->name;
|
||||
$shop->address = $request->address;
|
||||
$shop->phone = $request->phone;
|
||||
$shop->slug = preg_replace('/\s+/', '-', $request->name) . '-' . $shop->id;
|
||||
$shop->meta_title = $request->meta_title;
|
||||
$shop->meta_description = $request->meta_description;
|
||||
$shop->logo = $request->logo;
|
||||
}
|
||||
|
||||
if ($request->has('delivery_pickup_longitude') && $request->has('delivery_pickup_latitude')) {
|
||||
|
||||
$shop->delivery_pickup_longitude = $request->delivery_pickup_longitude;
|
||||
$shop->delivery_pickup_latitude = $request->delivery_pickup_latitude;
|
||||
} elseif (
|
||||
$request->has('facebook') ||
|
||||
$request->has('google') ||
|
||||
$request->has('twitter') ||
|
||||
$request->has('youtube') ||
|
||||
$request->has('instagram')
|
||||
) {
|
||||
$shop->facebook = $request->facebook;
|
||||
$shop->instagram = $request->instagram;
|
||||
$shop->google = $request->google;
|
||||
$shop->twitter = $request->twitter;
|
||||
$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('banner_full_width_2')
|
||||
) {
|
||||
$shop->top_banner = $request->top_banner;
|
||||
$shop->sliders = $request->sliders;
|
||||
$shop->banner_full_width_1 = $request->banner_full_width_1;
|
||||
$shop->banners_half_width = $request->banners_half_width;
|
||||
$shop->banner_full_width_2 = $request->banner_full_width_2;
|
||||
}
|
||||
|
||||
if ($shop->save()) {
|
||||
flash(translate('Your Shop has been updated successfully!'))->success();
|
||||
return back();
|
||||
}
|
||||
|
||||
flash(translate('Sorry! Something went wrong.'))->error();
|
||||
return back();
|
||||
}
|
||||
|
||||
public function verify_form ()
|
||||
{
|
||||
if (Auth::user()->shop->verification_info == null) {
|
||||
$shop = Auth::user()->shop;
|
||||
return view('seller.verify_form', compact('shop'));
|
||||
} else {
|
||||
flash(translate('Sorry! You have sent verification request already.'))->error();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
public function verify_form_store(Request $request)
|
||||
{
|
||||
$data = array();
|
||||
$i = 0;
|
||||
foreach (json_decode(BusinessSetting::where('type', 'verification_form')->first()->value) as $key => $element) {
|
||||
$item = array();
|
||||
if ($element->type == 'text') {
|
||||
$item['type'] = 'text';
|
||||
$item['label'] = $element->label;
|
||||
$item['value'] = $request['element_' . $i];
|
||||
} elseif ($element->type == 'select' || $element->type == 'radio') {
|
||||
$item['type'] = 'select';
|
||||
$item['label'] = $element->label;
|
||||
$item['value'] = $request['element_' . $i];
|
||||
} elseif ($element->type == 'multi_select') {
|
||||
$item['type'] = 'multi_select';
|
||||
$item['label'] = $element->label;
|
||||
$item['value'] = json_encode($request['element_' . $i]);
|
||||
} elseif ($element->type == 'file') {
|
||||
$item['type'] = 'file';
|
||||
$item['label'] = $element->label;
|
||||
$item['value'] = $request['element_' . $i]->store('uploads/verification_form');
|
||||
}
|
||||
array_push($data, $item);
|
||||
$i++;
|
||||
}
|
||||
$shop = Auth::user()->shop;
|
||||
$shop->verification_info = json_encode($data);
|
||||
if ($shop->save()) {
|
||||
flash(translate('Your shop verification request has been submitted successfully!'))->success();
|
||||
return redirect()->route('seller.dashboard');
|
||||
}
|
||||
|
||||
flash(translate('Sorry! Something went wrong.'))->error();
|
||||
return back();
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Seller;
|
||||
|
||||
use App\Mail\SupportMailManager;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketReply;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Mail;
|
||||
|
||||
class SupportTicketController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$tickets = Ticket::where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(9);
|
||||
return view('seller.support_ticket.index', compact('tickets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ticket = new Ticket;
|
||||
$ticket->code = max(100000, (Ticket::latest()->first() != null ? Ticket::latest()->first()->code + 1 : 0)).date('s');
|
||||
$ticket->user_id = Auth::user()->id;
|
||||
$ticket->subject = $request->subject;
|
||||
$ticket->details = $request->details;
|
||||
$ticket->files = $request->attachments;
|
||||
|
||||
if($ticket->save()){
|
||||
$this->send_support_mail_to_admin($ticket);
|
||||
flash(translate('Ticket has been sent successfully'))->success();
|
||||
return redirect()->route('seller.support_ticket.index');
|
||||
}
|
||||
else{
|
||||
flash(translate('Something went wrong'))->error();
|
||||
}
|
||||
}
|
||||
|
||||
public function send_support_mail_to_admin($ticket){
|
||||
$array['view'] = 'emails.support';
|
||||
$array['subject'] = translate('Support ticket Code is').':- '.$ticket->code;
|
||||
$array['from'] = env('MAIL_FROM_ADDRESS');
|
||||
$array['content'] = translate('Hi. A ticket has been created. Please check the ticket.');
|
||||
$array['link'] = route('support_ticket.admin_show', encrypt($ticket->id));
|
||||
$array['sender'] = $ticket->user->name;
|
||||
$array['details'] = $ticket->details;
|
||||
|
||||
try {
|
||||
Mail::to(User::where('user_type', 'admin')->first()->email)->queue(new SupportMailManager($array));
|
||||
} catch (\Exception $e) {
|
||||
// dd($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$ticket = Ticket::findOrFail(decrypt($id));
|
||||
$ticket->client_viewed = 1;
|
||||
$ticket->save();
|
||||
$ticket_replies = $ticket->ticketreplies;
|
||||
return view('seller.support_ticket.show', compact('ticket','ticket_replies'));
|
||||
}
|
||||
|
||||
public function ticket_reply_store(Request $request)
|
||||
{
|
||||
$ticket_reply = new TicketReply;
|
||||
$ticket_reply->ticket_id = $request->ticket_id;
|
||||
$ticket_reply->user_id = $request->user_id;
|
||||
$ticket_reply->reply = $request->reply;
|
||||
$ticket_reply->files = $request->attachments;
|
||||
$ticket_reply->ticket->viewed = 0;
|
||||
$ticket_reply->ticket->status = 'pending';
|
||||
$ticket_reply->ticket->save();
|
||||
if($ticket_reply->save()){
|
||||
|
||||
flash(translate('Reply has been sent successfully'))->success();
|
||||
return back();
|
||||
}
|
||||
else{
|
||||
flash(translate('Something went wrong'))->error();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user