added duplicate store
This commit is contained in:
@@ -1294,4 +1294,36 @@ class AdminController extends Controller
|
|||||||
'message' => "successfully updated."
|
'message' => "successfully updated."
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function duplicateStore($storeid, $newStore)
|
||||||
|
{
|
||||||
|
$AdminModel = new AdminModel;
|
||||||
|
$newStoreId = $newStore;
|
||||||
|
$storeProducts = $AdminModel->selectTeamstoreProducts('TeamStoreId', $storeid);
|
||||||
|
|
||||||
|
foreach($storeProducts as $product) {
|
||||||
|
|
||||||
|
$productId = $product->Id;
|
||||||
|
unset($product->Id);
|
||||||
|
unset($product->DateCreated);
|
||||||
|
|
||||||
|
$product->ProductURL = str_slug($product->ProductURL . '-copy');
|
||||||
|
$product->TeamStoreId = $newStoreId;
|
||||||
|
|
||||||
|
$product = json_decode(json_encode($product), true);
|
||||||
|
var_dump($product);
|
||||||
|
|
||||||
|
$response = $AdminModel->insertStoreItem($product);
|
||||||
|
var_dump($response);
|
||||||
|
|
||||||
|
$productThumbnails = $AdminModel->selectProductThumbnail($productId);
|
||||||
|
foreach($productThumbnails as $productThumbnail) {
|
||||||
|
unset($productThumbnail->Id);
|
||||||
|
unset($productThumbnail->DateCreated);
|
||||||
|
$productThumbnail->ProductId = $response['lastId'];
|
||||||
|
$AdminModel->insertProductThumbnails(json_decode(json_encode($productThumbnail), true));
|
||||||
|
var_dump($productThumbnail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,9 +92,13 @@ Route::group(['middleware' => 'auth'], function () {
|
|||||||
Route::post('post/update-hibernate', 'admin\AdminController@updateHibernate');
|
Route::post('post/update-hibernate', 'admin\AdminController@updateHibernate');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Route::get('duplicate-store/{id}/{newstore_id}', 'admin\AdminController@duplicateStore' );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Route::auth();
|
Route::auth();
|
||||||
|
|
||||||
// Route::get('/home', 'HomeController@index');
|
// Route::get('/home', 'HomeController@index');
|
||||||
|
|||||||
@@ -496,4 +496,41 @@ class AdminModel extends Model
|
|||||||
ON t.Id = tx.TeamstoreId");
|
ON t.Id = tx.TeamstoreId");
|
||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectTeamstoreProducts($field, $value){
|
||||||
|
|
||||||
|
$i = DB::table('teamstore_products')
|
||||||
|
->where($field, $value)
|
||||||
|
->get();
|
||||||
|
return $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectProductThumbnail($id){
|
||||||
|
|
||||||
|
$i = DB::table('teamstore_product_thumbnails')
|
||||||
|
->where('ProductId', $id)
|
||||||
|
->get();
|
||||||
|
return $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertStoreItem($data){
|
||||||
|
|
||||||
|
$i = DB::table('teamstore_products')->insert($data);
|
||||||
|
var_dump($i);
|
||||||
|
$id = DB::getPdo()->lastInsertId();
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'i' => $i,
|
||||||
|
'lastId' => $id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertProductThumbnails($data){
|
||||||
|
|
||||||
|
$i = DB::table('teamstore_product_thumbnails')->insert($data);
|
||||||
|
// $id = DB::getPdo()->lastInsertId();
|
||||||
|
|
||||||
|
return $i;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user