added clipart category
This commit is contained in:
@@ -414,11 +414,11 @@ class AdminController extends Controller
|
||||
return view('admin_pages.reports');
|
||||
}
|
||||
|
||||
public function viewClipart(){
|
||||
public function addClipart(){
|
||||
$AdminModel = new AdminModel;
|
||||
$clipart_categories_array = $AdminModel->selectClipartCategory();
|
||||
|
||||
return view('admin_pages.clipart')
|
||||
return view('admin_pages.add_clipart')
|
||||
->with('clipart_categories_array', $clipart_categories_array);
|
||||
}
|
||||
|
||||
@@ -432,12 +432,13 @@ class AdminController extends Controller
|
||||
);
|
||||
|
||||
$res = $AdminModel->insertClipartCategory($data);
|
||||
|
||||
// var_dump($res);
|
||||
if($res){
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'addClass'=> 'modal-close-reload',
|
||||
'message' => 'Clipart Category is successfully added.'
|
||||
'message' => 'Clipart Category is successfully added.',
|
||||
'last_inserted_id' => $res
|
||||
));
|
||||
|
||||
}else{
|
||||
@@ -569,5 +570,84 @@ class AdminController extends Controller
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function viewClipartCategories(){
|
||||
$AdminModel = new AdminModel;
|
||||
$clipart_categories_array = $AdminModel->ClipartCategory();
|
||||
return view('admin_pages.clipart_categories')
|
||||
->with('clipart_categories_array', $clipart_categories_array);
|
||||
}
|
||||
|
||||
public function deleteClipartCategory(Request $request){
|
||||
$post = $request->all();
|
||||
$AdminModel = new AdminModel;
|
||||
|
||||
$res = $AdminModel->deleteClipartCategory($post['id']);
|
||||
|
||||
if($res){
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message' => "Clipart Category is successfully deleted."
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function saveClipartCatOrdering(Request $request){
|
||||
$post = $request->all();
|
||||
$AdminModel = new AdminModel;
|
||||
|
||||
$arrayClipartCat = $post['clip_cat_id'];
|
||||
$order = 1;
|
||||
|
||||
foreach ($arrayClipartCat as $item) {
|
||||
$i = $AdminModel->updateClipartCatOrdering($order, $item);
|
||||
$order++;
|
||||
}
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message' => "Clipart Category ordering is succcessfully updated!"
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function updateClipartCategory(Request $request){
|
||||
$post = $request->all();
|
||||
$AdminModel = new AdminModel;
|
||||
|
||||
$id = $post['id'];
|
||||
$category = $post['category'];
|
||||
$is_active = $post['is_active'];
|
||||
|
||||
$data = array (
|
||||
'CategoryName' => $category,
|
||||
'IsActive' => $is_active
|
||||
);
|
||||
|
||||
$res = $AdminModel->updateClipartCategory($id, $data);
|
||||
|
||||
if($res){
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message' => "Clipart Category ordering is succcessfully updated!"
|
||||
));
|
||||
}else{
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => "Something went wrong. Please refresh the page and try again."
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function viewClipart(){
|
||||
$AdminModel = new AdminModel;
|
||||
$clipart_array = $AdminModel->selectCliparts();
|
||||
|
||||
return view('admin_pages.cliparts')
|
||||
->with('clipart_array', $clipart_array);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -43,10 +43,18 @@ Route::group(['middleware' => 'auth'], function () {
|
||||
Route::get('overlay-pattern', 'admin\AdminController@overlayPattern');
|
||||
|
||||
Route::get('reports', 'admin\AdminController@viewReports');
|
||||
Route::get('clipart', 'admin\AdminController@viewClipart');
|
||||
|
||||
Route::get('clipart-add', 'admin\AdminController@addClipart');
|
||||
Route::get('cliparts', 'admin\AdminController@viewClipart');
|
||||
Route::get('clipart-categories', 'admin\AdminController@viewClipartCategories');
|
||||
Route::post('clipart/save-category', 'admin\AdminController@saveClipartCategory');
|
||||
Route::post('clipart/save-svg-clipart', 'admin\AdminController@saveSVGClipart');
|
||||
Route::post('clipart/delete-clipart-category', 'admin\AdminController@deleteClipartCategory');
|
||||
Route::post('clipart/save-clipart-cat-ordering', 'admin\AdminController@saveClipartCatOrdering');
|
||||
Route::post('clipart/update-clipart-category', 'admin\AdminController@updateClipartCategory');
|
||||
|
||||
|
||||
|
||||
Route::get('user-list', 'admin\AdminController@userList');
|
||||
|
||||
Route::post('post/update-user-as-store-owner', 'admin\AdminController@updatUserAsStoreOwner');
|
||||
|
||||
@@ -146,6 +146,15 @@ class AdminModel extends Model
|
||||
return $i;
|
||||
}
|
||||
|
||||
function ClipartCategory(){
|
||||
$i = DB::table('clipart_categories')
|
||||
->leftjoin('user_logins', 'clipart_categories.UserId', '=', 'user_logins.id')
|
||||
->select('clipart_categories.*', 'user_logins.username')
|
||||
->orderby('clipart_categories.Ordering', 'ASC')
|
||||
->paginate(18);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectStoreOwners($store_id){
|
||||
$i = DB::table('user_logins')
|
||||
->where('role', 'store_owner')
|
||||
@@ -156,7 +165,7 @@ class AdminModel extends Model
|
||||
|
||||
function insertClipartCategory($data){
|
||||
|
||||
$i = DB::table('clipart_categories')->insert($data);
|
||||
$i = DB::table('clipart_categories')->insertGetId($data);
|
||||
return $i;
|
||||
}
|
||||
|
||||
@@ -166,6 +175,11 @@ class AdminModel extends Model
|
||||
return $i;
|
||||
}
|
||||
|
||||
function updateClipartCatOrdering($order, $id){
|
||||
$i = DB::table('clipart_categories')->where('Id', $id)
|
||||
->update(['Ordering' => $order]);
|
||||
}
|
||||
|
||||
|
||||
function userList(){
|
||||
$i = DB::table('user_logins')
|
||||
@@ -193,6 +207,34 @@ class AdminModel extends Model
|
||||
->update(['role'=> 'user', 'store_id'=> $data['store_id']]);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function deleteClipartCategory($id){
|
||||
|
||||
$i = DB::table('clipart_categories')
|
||||
->where("Id", $id)
|
||||
->delete();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function updateClipartCategory($id, $data){
|
||||
|
||||
$i = DB::table('clipart_categories')
|
||||
->where("Id", $id)
|
||||
->update($data);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectCliparts(){
|
||||
|
||||
$i = DB::table('cliparts')
|
||||
->orderby("Id", "DESC")
|
||||
->paginate(16);
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user