update store item view
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php namespace App\Http\Controllers\user;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\user;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
@@ -14,13 +16,15 @@ use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
class UserController extends Controller {
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
||||
public function index(){
|
||||
public function index()
|
||||
{
|
||||
$m = new UserModel;
|
||||
$userRole = Auth::user()->role;
|
||||
|
||||
if($userRole == "store_owner"){
|
||||
if ($userRole == "store_owner") {
|
||||
$storeId = Auth::user()->store_id;
|
||||
|
||||
$countStoreOrder = $m->countStoreOrder($storeId);
|
||||
@@ -35,7 +39,7 @@ class UserController extends Controller {
|
||||
'store_product_count' => $countStoreProduct[0]->store_product_count,
|
||||
'store_published_product' => $countStorePublishedProduct[0]->store_published_product
|
||||
);
|
||||
}else{
|
||||
} else {
|
||||
$post_data = array(
|
||||
'isStoreOwner' => false,
|
||||
'store_order' => "",
|
||||
@@ -47,10 +51,10 @@ class UserController extends Controller {
|
||||
|
||||
// $post_data = json_encode($post_data, JSON_FORCE_OBJECT);
|
||||
return view('user-layouts.index')->with('data', $post_data);
|
||||
|
||||
}
|
||||
|
||||
public function addressBook(){
|
||||
public function addressBook()
|
||||
{
|
||||
$m = new UserModel;
|
||||
$userId = Auth::user()->id;
|
||||
|
||||
@@ -58,16 +62,16 @@ class UserController extends Controller {
|
||||
|
||||
return view('user-layouts.address_book')
|
||||
->with('array_address_book', $array_address_book);
|
||||
|
||||
}
|
||||
|
||||
public function createAddressBook(){
|
||||
public function createAddressBook()
|
||||
{
|
||||
|
||||
return view('user-layouts.create_address_book');
|
||||
|
||||
}
|
||||
|
||||
public function saveAddressBook(Request $request){
|
||||
public function saveAddressBook(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$m = new UserModel;
|
||||
|
||||
@@ -87,25 +91,25 @@ class UserController extends Controller {
|
||||
'Country' => $post['country']
|
||||
);
|
||||
echo $i = $m->insertAddressBook($data);
|
||||
|
||||
}
|
||||
|
||||
public function editAddressBook($id){
|
||||
public function editAddressBook($id)
|
||||
{
|
||||
$m = new UserModel;
|
||||
$userId = Auth::user()->id;
|
||||
|
||||
$array_address_book = $m->selectAddresBook('Id', $id);
|
||||
|
||||
if($array_address_book[0]->UserId != $userId){
|
||||
if ($array_address_book[0]->UserId != $userId) {
|
||||
return redirect('user/address-book');
|
||||
}
|
||||
|
||||
return view('user-layouts.edit_address_book')
|
||||
->with('array_address_book', $array_address_book);
|
||||
|
||||
}
|
||||
|
||||
public function updateAddressBook(Request $request){
|
||||
public function updateAddressBook(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$m = new UserModel;
|
||||
|
||||
@@ -128,10 +132,10 @@ class UserController extends Controller {
|
||||
|
||||
|
||||
echo $i = $m->saveUpdateAddressBook($data, $id);
|
||||
|
||||
}
|
||||
|
||||
public function profile(){
|
||||
public function profile()
|
||||
{
|
||||
$m = new UserModel;
|
||||
$userId = Auth::user()->id;
|
||||
|
||||
@@ -140,17 +144,18 @@ class UserController extends Controller {
|
||||
->with('array_profile_info', $array_profile_info);
|
||||
}
|
||||
|
||||
public function editProfile(){
|
||||
public function editProfile()
|
||||
{
|
||||
$m = new UserModel;
|
||||
$userId = Auth::user()->id;
|
||||
|
||||
$array_profile_info = $m->selectProfileInfo($userId);
|
||||
return view('user-layouts.edit_profile')
|
||||
->with('array_profile_info', $array_profile_info);
|
||||
|
||||
}
|
||||
|
||||
public function updateProfile(Request $request){
|
||||
public function updateProfile(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$m = new UserModel;
|
||||
|
||||
@@ -175,22 +180,24 @@ class UserController extends Controller {
|
||||
return $i;
|
||||
}
|
||||
|
||||
public function changePassword(){
|
||||
public function changePassword()
|
||||
{
|
||||
return view('user-layouts.change_password');
|
||||
}
|
||||
|
||||
public function updatePassword(Request $request){
|
||||
public function updatePassword(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$m = new UserModel;
|
||||
$c_password = Auth::user()->password;
|
||||
$userId = Auth::user()->id;
|
||||
|
||||
if(!(Hash::check($post['current_password'], $c_password))){
|
||||
if (!(Hash::check($post['current_password'], $c_password))) {
|
||||
$message = "Your current password does not matches with the password you provided. Please try again.";
|
||||
return $message;
|
||||
}
|
||||
|
||||
if(strcmp($post['current_password'], $post['new_password']) == 0){
|
||||
if (strcmp($post['current_password'], $post['new_password']) == 0) {
|
||||
//Current password and new password are same
|
||||
$message = "New Password cannot be same as your current password. Please choose a different password.";
|
||||
return $message;
|
||||
@@ -203,12 +210,13 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
|
||||
$i = $m->saveUpdatePassword(bcrypt($post['new_password']) , $userId);
|
||||
$i = $m->saveUpdatePassword(bcrypt($post['new_password']), $userId);
|
||||
|
||||
return $i;
|
||||
}
|
||||
|
||||
public function orders(){
|
||||
public function orders()
|
||||
{
|
||||
$m = new UserModel;
|
||||
$userId = Auth::user()->id;
|
||||
$array_payment_details = $m->selectPaymentDetails('UserId', $userId);
|
||||
@@ -220,7 +228,8 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
|
||||
public function myDesigns(){
|
||||
public function myDesigns()
|
||||
{
|
||||
$m = new UserModel;
|
||||
$userId = Auth::user()->id;
|
||||
|
||||
@@ -229,14 +238,15 @@ class UserController extends Controller {
|
||||
return view('user-layouts.my-design')->with('array_client_designs', $array_client_designs);
|
||||
}
|
||||
|
||||
public function viewDesign($designCode){
|
||||
public function viewDesign($designCode)
|
||||
{
|
||||
$m = new UserModel;
|
||||
$newMainModel = new MainModel;
|
||||
$userId = Auth::user()->id;
|
||||
$array_client_designs = $m->selectClientDesignsbyCode($designCode);
|
||||
|
||||
// check if its your design
|
||||
if($userId != $array_client_designs[0]->ClientId){
|
||||
if ($userId != $array_client_designs[0]->ClientId) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -249,7 +259,8 @@ class UserController extends Controller {
|
||||
->with('array_cat_name', $array_cat_name);
|
||||
}
|
||||
|
||||
public function updateDesignDetails(Request $request){
|
||||
public function updateDesignDetails(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$m = new UserModel;
|
||||
|
||||
@@ -263,27 +274,25 @@ class UserController extends Controller {
|
||||
$i = $m->updateClientDesign($client_design_data, $design_code);
|
||||
|
||||
return $i;
|
||||
|
||||
}
|
||||
|
||||
public function store(){
|
||||
public function store()
|
||||
{
|
||||
$m = new UserModel;
|
||||
$userRole = Auth::user()->role;
|
||||
$array_store_info = array();
|
||||
|
||||
if($userRole == "store_owner"){
|
||||
if ($userRole == "store_owner") {
|
||||
$storeId = Auth::user()->store_id;
|
||||
|
||||
$array_store_info = $m->selectStoreInfo($storeId);
|
||||
|
||||
return redirect('teamstore/'. $array_store_info[0]->StoreUrl);
|
||||
|
||||
|
||||
return redirect('teamstore/' . $array_store_info[0]->StoreUrl);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function storeItems(){
|
||||
public function storeItems()
|
||||
{
|
||||
$thumbnails = array();
|
||||
$newUserModel = new UserModel;
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
@@ -298,15 +307,15 @@ class UserController extends Controller {
|
||||
|
||||
$thumbnails_array = $newTeamStoreModel->getProductThumbnails($pr_arr->Id);
|
||||
|
||||
if(!empty($thumbnails_array)){
|
||||
if (!empty($thumbnails_array)) {
|
||||
foreach ($thumbnails_array as $t => $thumb) {
|
||||
|
||||
if($thumb->ImageClass == 'custom'){
|
||||
if ($thumb->ImageClass == 'custom') {
|
||||
$displayThumbnails = $thumb->Image;
|
||||
break;
|
||||
}
|
||||
|
||||
if($thumb->ImageClass == 'active'){
|
||||
if ($thumb->ImageClass == 'active') {
|
||||
$displayThumbnails = $thumb->Image;
|
||||
break;
|
||||
}
|
||||
@@ -317,15 +326,13 @@ class UserController extends Controller {
|
||||
'product_id' => $pr_arr->Id,
|
||||
'thumb' => $displayThumbnails
|
||||
);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$thumbnails[] = array(
|
||||
'folder' => $store_array[0]->ImageFolder,
|
||||
'product_id' => $pr_arr->Id,
|
||||
'thumb' => "product-image-placeholder.png"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('user-layouts.store_items')->with('store_array', $store_array)
|
||||
@@ -333,7 +340,8 @@ class UserController extends Controller {
|
||||
->with('thumbnails', $thumbnails);
|
||||
}
|
||||
|
||||
public function viewStoreItem($url){
|
||||
public function viewStoreItem($url)
|
||||
{
|
||||
$product_array = array();
|
||||
$newUserModel = new UserModel;
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
@@ -347,18 +355,17 @@ class UserController extends Controller {
|
||||
->with('available_size', $available_size)
|
||||
->with('thumbnails_array', $thumbnails_array)
|
||||
->with('shipping_cost', $shipping_cost);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function storeItemUpdate(Request $request){
|
||||
public function storeItemUpdate(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
|
||||
if($post['shipping_cost'] == 0){
|
||||
if ($post['shipping_cost'] == 0) {
|
||||
$shipping_cost_id = null;
|
||||
}else{
|
||||
} else {
|
||||
$shipping_cost_id = $post['shipping_cost'];
|
||||
}
|
||||
|
||||
@@ -395,18 +402,18 @@ class UserController extends Controller {
|
||||
$userId = Auth::user()->id;
|
||||
$email_is_verified = Auth::user()->email_is_verified;
|
||||
|
||||
if($email_is_verified == 0){
|
||||
if ($email_is_verified == 0) {
|
||||
$array_profile_info = $m->selectProfileInfo($userId);
|
||||
return view('user-layouts.email_verify')
|
||||
->with('array_profile_info', $array_profile_info);
|
||||
}
|
||||
|
||||
return redirect('user/profile');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function resendVericationCode(Request $request){
|
||||
public function resendVericationCode(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$random_hash = rand(1000, 9999);
|
||||
|
||||
@@ -418,18 +425,16 @@ class UserController extends Controller {
|
||||
'verification_code' => $random_hash
|
||||
];
|
||||
|
||||
Mail::send('emails.resend_code', $emailDetails, function($message) use ($emailDetails) {
|
||||
Mail::send('emails.resend_code', $emailDetails, function ($message) use ($emailDetails) {
|
||||
|
||||
$message->from('no-reply@crewsportswear.com', 'CREW Sportswear');
|
||||
$message->to($emailDetails['receiver'])->subject('CREW Sportswear Email Verification Code');
|
||||
|
||||
});
|
||||
|
||||
if( count(Mail::failures()) > 0 ) {
|
||||
if (count(Mail::failures()) > 0) {
|
||||
|
||||
echo '0';
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$data = array(
|
||||
'EmailAddress' => $post['email'],
|
||||
'VerCode' => $random_hash
|
||||
@@ -441,7 +446,8 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
|
||||
public function verifyCode(Request $request){
|
||||
public function verifyCode(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
|
||||
$verification_code = $post['verification_code'];
|
||||
@@ -458,7 +464,7 @@ class UserController extends Controller {
|
||||
$i = $newUserModel->validateCode($data);
|
||||
// var_dump($i);
|
||||
|
||||
if($i){
|
||||
if ($i) {
|
||||
|
||||
$user_logins_data = array(
|
||||
'email_is_verified' => 1
|
||||
@@ -468,18 +474,18 @@ class UserController extends Controller {
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message'=>'Your email is successfully verified.'
|
||||
'message' => 'Your email is successfully verified.'
|
||||
));
|
||||
|
||||
}else{
|
||||
} else {
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message'=>'Invalid verification code.'
|
||||
'message' => 'Invalid verification code.'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function orderDetails($ck){
|
||||
public function orderDetails($ck)
|
||||
{
|
||||
$newUserModel = new UserModel;
|
||||
$order_item_array = $newUserModel->selectOrderItem($ck);
|
||||
$item_goup_array = $newUserModel->itemGroup($ck);
|
||||
@@ -492,7 +498,8 @@ class UserController extends Controller {
|
||||
->with('order_item_array', $order_item_array);
|
||||
}
|
||||
|
||||
public function sellDesign($designCode){
|
||||
public function sellDesign($designCode)
|
||||
{
|
||||
$m = new UserModel;
|
||||
$newMainModel = new MainModel;
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
@@ -501,7 +508,7 @@ class UserController extends Controller {
|
||||
$array_client_designs = $m->selectClientDesignsbyCode($designCode);
|
||||
$store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
|
||||
// check if its your design
|
||||
if($userId != $array_client_designs[0]->ClientId){
|
||||
if ($userId != $array_client_designs[0]->ClientId) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -517,7 +524,8 @@ class UserController extends Controller {
|
||||
->with('array_cat_name', $array_cat_name);
|
||||
}
|
||||
|
||||
public function buyDesign($designCode){
|
||||
public function buyDesign($designCode)
|
||||
{
|
||||
$m = new UserModel;
|
||||
$newMainModel = new MainModel;
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
@@ -526,7 +534,7 @@ class UserController extends Controller {
|
||||
$array_client_designs = $m->selectClientDesignsbyCode($designCode);
|
||||
// $store_array = $newTeamStoreModel->selectTeamStore('Id', $store_id);
|
||||
// check if its your design
|
||||
if($userId != $array_client_designs[0]->ClientId){
|
||||
if ($userId != $array_client_designs[0]->ClientId) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -540,11 +548,11 @@ class UserController extends Controller {
|
||||
->with('array_template_paths', $array_template_paths)
|
||||
// ->with('store_array', $store_array)
|
||||
->with('array_cat_name', $array_cat_name);
|
||||
|
||||
}
|
||||
|
||||
//save item from my design //
|
||||
public function saveNewStoreItem(Request $request){
|
||||
public function saveNewStoreItem(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
@@ -567,27 +575,29 @@ class UserController extends Controller {
|
||||
'ProductURL' => $itemUrl
|
||||
);
|
||||
|
||||
$validator = Validator::make($check_product_url, [
|
||||
$validator = Validator::make(
|
||||
$check_product_url,
|
||||
[
|
||||
'ProductURL' => 'unique:teamstore_products'
|
||||
],
|
||||
[
|
||||
'ProductURL.unique' => 'The Item URL has already been taken.',
|
||||
]);
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
if ($validator->fails()) {
|
||||
$errors = "";
|
||||
// var_dump(($validator->errors()->all()));
|
||||
foreach($validator->errors()->all() as $error){
|
||||
$errors .= "<li>".$error."</li>";
|
||||
foreach ($validator->errors()->all() as $error) {
|
||||
$errors .= "<li>" . $error . "</li>";
|
||||
}
|
||||
|
||||
$message = '
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> ERROR:</h4>
|
||||
'.$errors.
|
||||
' . $errors .
|
||||
'</div>';
|
||||
|
||||
return response()->json(array(
|
||||
@@ -600,7 +610,7 @@ class UserController extends Controller {
|
||||
'TeamStoreId' => $store_id,
|
||||
'ProductName' => $itemName,
|
||||
'ProductPrice' => str_replace('$ ', '', $itemPrice),
|
||||
'ProductDescription'=> $itemDescription,
|
||||
'ProductDescription' => $itemDescription,
|
||||
'ProductURL' => $itemUrl,
|
||||
'ProductForm' => $itemForm,
|
||||
'AvailableSizes' => $available_size,
|
||||
@@ -614,11 +624,11 @@ class UserController extends Controller {
|
||||
|
||||
$array_template_paths = $UserModel->selectTemplatePaths('TemplateCode', $templateCode);
|
||||
|
||||
foreach($array_template_paths as $key => $row1){
|
||||
if($key == 0){
|
||||
foreach ($array_template_paths as $key => $row1) {
|
||||
if ($key == 0) {
|
||||
$thumb = $designCode . '-front-thumbnail.png';
|
||||
$class = "active";
|
||||
}else{
|
||||
} else {
|
||||
$thumb = $designCode . '-' . strtolower($row1->Side) . '-thumbnail.png';
|
||||
$class = null;
|
||||
}
|
||||
@@ -626,24 +636,22 @@ class UserController extends Controller {
|
||||
$thumbs = $data = array(
|
||||
'ProductId' => $id,
|
||||
'Image' => $thumb,
|
||||
'ImageClass' =>$class
|
||||
'ImageClass' => $class
|
||||
);
|
||||
|
||||
$UserModel->insertNewProductThumbnails($thumbs);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$prod_code = array('ProductCode' => $getYear . '-' .str_pad($id, 10,'0', STR_PAD_LEFT));
|
||||
$prod_code = array('ProductCode' => $getYear . '-' . str_pad($id, 10, '0', STR_PAD_LEFT));
|
||||
$i = $UserModel->updateProductCode($prod_code, $id);
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
function addStoreItem(){
|
||||
function addStoreItem()
|
||||
{
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
|
||||
$user_role = Auth::user()->role;
|
||||
@@ -654,7 +662,8 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
//manually uploading item
|
||||
function saveNewItem(Request $request){
|
||||
function saveNewItem(Request $request)
|
||||
{
|
||||
|
||||
$post = $request->all();
|
||||
// var_dump($post['imgupload']);
|
||||
@@ -681,27 +690,29 @@ class UserController extends Controller {
|
||||
'ProductURL' => $itemUrl
|
||||
);
|
||||
|
||||
$validator = Validator::make($check_product_url, [
|
||||
$validator = Validator::make(
|
||||
$check_product_url,
|
||||
[
|
||||
'ProductURL' => 'unique:teamstore_products'
|
||||
],
|
||||
[
|
||||
'ProductURL.unique' => 'The Item URL has already been taken.',
|
||||
]);
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
if ($validator->fails()) {
|
||||
$errors = "";
|
||||
// var_dump(($validator->errors()->all()));
|
||||
foreach($validator->errors()->all() as $error){
|
||||
$errors .= "<li>".$error."</li>";
|
||||
foreach ($validator->errors()->all() as $error) {
|
||||
$errors .= "<li>" . $error . "</li>";
|
||||
}
|
||||
|
||||
$message = '
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> ERROR:</h4>
|
||||
'.$errors.
|
||||
' . $errors .
|
||||
'</div>';
|
||||
|
||||
return response()->json(array(
|
||||
@@ -714,7 +725,7 @@ class UserController extends Controller {
|
||||
'TeamStoreId' => $store_id,
|
||||
'ProductName' => $itemName,
|
||||
'ProductPrice' => str_replace('$ ', '', $itemPrice),
|
||||
'ProductDescription'=> $itemDescription,
|
||||
'ProductDescription' => $itemDescription,
|
||||
'ProductURL' => $itemUrl,
|
||||
'ProductForm' => $itemForm,
|
||||
'AvailableSizes' => $available_size,
|
||||
@@ -726,25 +737,25 @@ class UserController extends Controller {
|
||||
$id = $UserModel->insertNewProduct($data); // product item id
|
||||
// echo $id;
|
||||
|
||||
for($i = 0; $i < count($post['imgupload']); $i++){
|
||||
$rawName = date('Ymd') . "-" . time().'-'.$request->file('imgupload')[$i]->getClientOriginalName();
|
||||
for ($i = 0; $i < count($post['imgupload']); $i++) {
|
||||
$rawName = date('Ymd') . "-" . time() . '-' . $request->file('imgupload')[$i]->getClientOriginalName();
|
||||
$imageExt = $request->file('imgupload')[$i]->getClientOriginalExtension();
|
||||
|
||||
$custom_file_name = str_replace(' ','-',strtolower($rawName));
|
||||
$custom_file_name = str_replace(' ', '-', strtolower($rawName));
|
||||
$custom_file_name = preg_replace("/\.[^.\s]{3,4}$/", "", $custom_file_name);
|
||||
$NewImageName = $custom_file_name.'.'.$imageExt;
|
||||
$NewImageName = $custom_file_name . '.' . $imageExt;
|
||||
$thumbnail = $NewImageName;
|
||||
|
||||
if($i == 0){
|
||||
if ($i == 0) {
|
||||
$imageClass = "active";
|
||||
}else{
|
||||
} else {
|
||||
$imageClass = null;
|
||||
}
|
||||
|
||||
$thumbs = $data = array(
|
||||
'ProductId' => $id,
|
||||
'Image' => $thumbnail,
|
||||
'ImageClass' =>$imageClass
|
||||
'ImageClass' => $imageClass
|
||||
);
|
||||
|
||||
$u = $UserModel->insertNewProductThumbnails($thumbs);
|
||||
@@ -754,7 +765,7 @@ class UserController extends Controller {
|
||||
// var_dump($s);
|
||||
}
|
||||
|
||||
$prod_code = array('ProductCode' => $getYear . '-' .str_pad($id, 10,'0', STR_PAD_LEFT));
|
||||
$prod_code = array('ProductCode' => $getYear . '-' . str_pad($id, 10, '0', STR_PAD_LEFT));
|
||||
$i = $UserModel->updateProductCode($prod_code, $id);
|
||||
|
||||
|
||||
@@ -762,10 +773,10 @@ class UserController extends Controller {
|
||||
'success' => true,
|
||||
'message' => 'success'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
function saveNewItemImage(Request $request){
|
||||
function saveNewItemImage(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
$getYear = date('y');
|
||||
@@ -773,25 +784,25 @@ class UserController extends Controller {
|
||||
|
||||
$getActiveDisplay = $UserModel->selectDisplayItemThumbById($id);
|
||||
|
||||
for($i = 0; $i < count($post['upload_images']); $i++){
|
||||
$rawName = date('Ymd') . "-" . time().'-'.$request->file('upload_images')[$i]->getClientOriginalName();
|
||||
for ($i = 0; $i < count($post['upload_images']); $i++) {
|
||||
$rawName = date('Ymd') . "-" . time() . '-' . $request->file('upload_images')[$i]->getClientOriginalName();
|
||||
$imageExt = $request->file('upload_images')[$i]->getClientOriginalExtension();
|
||||
|
||||
$custom_file_name = str_replace(' ','-',strtolower($rawName));
|
||||
$custom_file_name = str_replace(' ', '-', strtolower($rawName));
|
||||
$custom_file_name = preg_replace("/\.[^.\s]{3,4}$/", "", $custom_file_name);
|
||||
$NewImageName = $custom_file_name.'.'.$imageExt;
|
||||
$NewImageName = $custom_file_name . '.' . $imageExt;
|
||||
$thumbnail = $NewImageName;
|
||||
|
||||
if($i == 0 && empty($getActiveDisplay)){
|
||||
if ($i == 0 && empty($getActiveDisplay)) {
|
||||
$imageClass = "active";
|
||||
}else{
|
||||
} else {
|
||||
$imageClass = null;
|
||||
}
|
||||
|
||||
$thumbs = $data = array(
|
||||
'ProductId' => $id,
|
||||
'Image' => $thumbnail,
|
||||
'ImageClass' =>$imageClass
|
||||
'ImageClass' => $imageClass
|
||||
);
|
||||
|
||||
$u = $UserModel->insertNewProductThumbnails($thumbs);
|
||||
@@ -805,17 +816,17 @@ class UserController extends Controller {
|
||||
'success' => true,
|
||||
'message' => 'success'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
function deleteImageThumb(Request $request){
|
||||
function deleteImageThumb(Request $request)
|
||||
{
|
||||
$file = $request->thumb_filename;
|
||||
$id = $request->thumb_id;
|
||||
$UserModel = new UserModel;
|
||||
|
||||
$storagePath = Storage::disk('sftp')->getDriver()->getAdapter()->getPathPrefix();
|
||||
if(file_exists($storagePath.$file)) {
|
||||
unlink($storagePath.$file);
|
||||
if (file_exists($storagePath . $file)) {
|
||||
unlink($storagePath . $file);
|
||||
}
|
||||
|
||||
$i = $UserModel->deleteImageThumb('Id', $id);
|
||||
@@ -825,10 +836,10 @@ class UserController extends Controller {
|
||||
'message' => 'success',
|
||||
'delete_row' => 'item-' . $id
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
function updateActiveThumbnail(Request $request){
|
||||
function updateActiveThumbnail(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
$i = $UserModel->updateActiveThumb($post['id'], $post['product_id']);
|
||||
@@ -836,7 +847,8 @@ class UserController extends Controller {
|
||||
|
||||
}
|
||||
|
||||
function saveThumbnailOrdering(Request $request){
|
||||
function saveThumbnailOrdering(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$arrayItems = $post['item'];
|
||||
$order = 1;
|
||||
@@ -853,7 +865,8 @@ class UserController extends Controller {
|
||||
));
|
||||
}
|
||||
|
||||
function saveItemOrdering(Request $request){
|
||||
function saveItemOrdering(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$arrayItems = $post['order_number'];
|
||||
$order = 1;
|
||||
@@ -872,7 +885,8 @@ class UserController extends Controller {
|
||||
|
||||
|
||||
|
||||
function storeSettingUpdate(Request $request){
|
||||
function storeSettingUpdate(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
|
||||
@@ -882,51 +896,53 @@ class UserController extends Controller {
|
||||
$orig_store_url = $post['orig_store_url'];
|
||||
|
||||
|
||||
if($post['store_status'] == "Public"){
|
||||
if ($post['store_status'] == "Public") {
|
||||
$store_status = "true";
|
||||
}else{
|
||||
} else {
|
||||
$store_status = "false";
|
||||
}
|
||||
|
||||
if(isset($post['set_store_password'])){
|
||||
if (isset($post['set_store_password'])) {
|
||||
$store_password = $post['store_password'];
|
||||
}else{
|
||||
} else {
|
||||
$store_password = null;
|
||||
}
|
||||
|
||||
if($request->file('store_logo') != null){
|
||||
$store_logo_name = 'logo.'. $request->file('store_logo')->getClientOriginalExtension();
|
||||
}else{
|
||||
if ($request->file('store_logo') != null) {
|
||||
$store_logo_name = 'logo.' . $request->file('store_logo')->getClientOriginalExtension();
|
||||
} else {
|
||||
$store_logo_name = $post['orig_store_logo'];
|
||||
}
|
||||
|
||||
if($request->file('store_banner') != null){
|
||||
$store_banner_name = 'banner.'. $request->file('store_banner')->getClientOriginalExtension();
|
||||
}else{
|
||||
if ($request->file('store_banner') != null) {
|
||||
$store_banner_name = 'banner.' . $request->file('store_banner')->getClientOriginalExtension();
|
||||
} else {
|
||||
$store_banner_name = $post['orig_store_banner'];
|
||||
}
|
||||
|
||||
|
||||
if($orig_store_url != $store_url){
|
||||
if ($orig_store_url != $store_url) {
|
||||
|
||||
$check_store_url = array(
|
||||
'StoreUrl' => $store_url
|
||||
);
|
||||
|
||||
$validator = Validator::make($check_store_url, [
|
||||
$validator = Validator::make(
|
||||
$check_store_url,
|
||||
[
|
||||
'StoreUrl' => 'unique:teamstores'
|
||||
],
|
||||
[
|
||||
'StoreUrl.unique' => 'The Store URL has already been taken.',
|
||||
]);
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
if ($validator->fails()) {
|
||||
$errors = "";
|
||||
|
||||
foreach($validator->errors()->all() as $error){
|
||||
$errors .= "<li>".$error."</li>";
|
||||
foreach ($validator->errors()->all() as $error) {
|
||||
$errors .= "<li>" . $error . "</li>";
|
||||
}
|
||||
|
||||
return response()->json(array(
|
||||
@@ -935,9 +951,6 @@ class UserController extends Controller {
|
||||
'message' => $errors
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$data = array(
|
||||
@@ -957,18 +970,18 @@ class UserController extends Controller {
|
||||
$res = $UserModel->updateTeamstore($store_id, $data);
|
||||
// var_dump($res);
|
||||
// if($res){
|
||||
if($request->file('store_logo') != null){
|
||||
Storage::disk('uploads')->put('/teamstore/'. $orig_store_url . '/' . $store_logo_name, fopen($request->file('store_logo'), 'r+'));
|
||||
if ($request->file('store_logo') != null) {
|
||||
Storage::disk('uploads')->put('/teamstore/' . $orig_store_url . '/' . $store_logo_name, fopen($request->file('store_logo'), 'r+'));
|
||||
}
|
||||
|
||||
if($request->file('store_banner') != null){
|
||||
Storage::disk('uploads')->put('/teamstore/'. $orig_store_url . '/' . $store_banner_name, fopen($request->file('store_banner'), 'r+'));
|
||||
if ($request->file('store_banner') != null) {
|
||||
Storage::disk('uploads')->put('/teamstore/' . $orig_store_url . '/' . $store_banner_name, fopen($request->file('store_banner'), 'r+'));
|
||||
}
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'clearform' => false,
|
||||
'message'=>'Store is successfully updated.'
|
||||
'message' => 'Store is successfully updated.'
|
||||
));
|
||||
|
||||
// }else{
|
||||
@@ -981,7 +994,8 @@ class UserController extends Controller {
|
||||
|
||||
}
|
||||
|
||||
function storeOrders(){
|
||||
function storeOrders()
|
||||
{
|
||||
$UserModel = new UserModel;
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
$store_id = Auth::user()->store_id;
|
||||
@@ -994,7 +1008,8 @@ class UserController extends Controller {
|
||||
->with('array_store_orders', $array_store_orders);
|
||||
}
|
||||
|
||||
function showStoreOrderDetails(Request $request){
|
||||
function showStoreOrderDetails(Request $request)
|
||||
{
|
||||
|
||||
$post = $request->all();
|
||||
// var_dump($post['pid']);
|
||||
@@ -1021,7 +1036,8 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
|
||||
function itemStoreReArrange(){
|
||||
function itemStoreReArrange()
|
||||
{
|
||||
$thumbnails = array();
|
||||
$newUserModel = new UserModel;
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
@@ -1036,15 +1052,17 @@ class UserController extends Controller {
|
||||
|
||||
$thumbnails_array = $newTeamStoreModel->getProductThumbnails($pr_arr->Id);
|
||||
|
||||
if(!empty($thumbnails_array)){
|
||||
if (!empty($thumbnails_array)) {
|
||||
$displayThumbnails = "product-image-placeholder.png";
|
||||
|
||||
foreach ($thumbnails_array as $t => $thumb) {
|
||||
|
||||
if($thumb->ImageClass == 'custom'){
|
||||
if ($thumb->ImageClass == 'custom') {
|
||||
$displayThumbnails = $thumb->Image;
|
||||
break;
|
||||
}
|
||||
|
||||
if($thumb->ImageClass == 'active'){
|
||||
if ($thumb->ImageClass == 'active') {
|
||||
$displayThumbnails = $thumb->Image;
|
||||
break;
|
||||
}
|
||||
@@ -1055,15 +1073,13 @@ class UserController extends Controller {
|
||||
'product_id' => $pr_arr->Id,
|
||||
'thumb' => $displayThumbnails
|
||||
);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$thumbnails[] = array(
|
||||
'folder' => $store_array[0]->ImageFolder,
|
||||
'product_id' => $pr_arr->Id,
|
||||
'thumb' => "product-image-placeholder.png"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('user-layouts.store_items_arrange')->with('store_array', $store_array)
|
||||
@@ -1071,19 +1087,20 @@ class UserController extends Controller {
|
||||
->with('thumbnails', $thumbnails);
|
||||
}
|
||||
|
||||
function deleteStoreItem(Request $request){
|
||||
function deleteStoreItem(Request $request)
|
||||
{
|
||||
//
|
||||
$post = $request->all();
|
||||
|
||||
$UserModel = new UserModel;
|
||||
$res = $UserModel->deleteStoreItem($post['id']);
|
||||
|
||||
if($res){
|
||||
if ($res) {
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message' => "Store item is successfully delete."
|
||||
));
|
||||
}else{
|
||||
} else {
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => "Something went wrong. Please try again!"
|
||||
@@ -1092,15 +1109,16 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
|
||||
function announcementIndex(){
|
||||
function announcementIndex()
|
||||
{
|
||||
$UserModel = new UserModel;
|
||||
$storeId = Auth::user()->store_id;
|
||||
|
||||
$getAnnouncement = $UserModel->getAnnouncement($storeId);
|
||||
|
||||
if(count($getAnnouncement) > 0){
|
||||
if (count($getAnnouncement) > 0) {
|
||||
$data = $getAnnouncement[0];
|
||||
}else{
|
||||
} else {
|
||||
$data = (object) array(
|
||||
'Id' => 0,
|
||||
'StoreId' => "",
|
||||
@@ -1112,11 +1130,11 @@ class UserController extends Controller {
|
||||
return view('user-layouts.announcement')
|
||||
->with("data", $data)
|
||||
->render();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function announcementUpdateSave(Request $request){
|
||||
function announcementUpdateSave(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
|
||||
@@ -1130,9 +1148,9 @@ class UserController extends Controller {
|
||||
|
||||
// var_dump($getAnnouncement[0]->Id);
|
||||
|
||||
if(count($getAnnouncement) > 0){
|
||||
if (count($getAnnouncement) > 0) {
|
||||
$response = $UserModel->updateAnnouncement($getAnnouncement[0]->Id, $data);
|
||||
}else{
|
||||
} else {
|
||||
$data['IsActive'] = 0;
|
||||
$response = $UserModel->saveNewAnnouncement($data);
|
||||
}
|
||||
@@ -1151,7 +1169,8 @@ class UserController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
function announcementUpdateStatus(Request $request){
|
||||
function announcementUpdateStatus(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
|
||||
@@ -1159,7 +1178,7 @@ class UserController extends Controller {
|
||||
|
||||
$getAnnouncement = $UserModel->getAnnouncement($storeId);
|
||||
|
||||
if(!count($getAnnouncement)){
|
||||
if (!count($getAnnouncement)) {
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => 'Please update your announcement first.'
|
||||
@@ -1183,5 +1202,4 @@ class UserController extends Controller {
|
||||
// $response = $UserModel->updateAnnouncement($getAnnouncement[0]->Id, $data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user