added clipart category

This commit is contained in:
franknstayn
2019-12-04 16:41:41 +08:00
parent c539b41371
commit 85a729f85d
8 changed files with 560 additions and 102 deletions

View File

@@ -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);
}
}