diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0ddab8a..94a9c4a 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -74,4 +74,25 @@ $routes->get("delete_vehicle/(:any)", "Vehicle::delete_vehicle/$1"); //dashboard -$routes->get('dashboard', 'Users::dashboard'); \ No newline at end of file +$routes->get('dashboard', 'Users::dashboard'); + + + + + +//---------------------- Make And Model +// Make +$routes->get('make_index', 'Make::index'); +$routes->post('create_make', 'Make::create_make'); + + + +// Model +$routes->get('bike_model_index/(:any)', 'Model::index/$1'); + +$routes->post('create_model', 'Model::create_model'); + +$routes->post('status_model', 'Model::status_model'); + + + diff --git a/app/Controllers/Make.php b/app/Controllers/Make.php new file mode 100644 index 0000000..d6d2763 --- /dev/null +++ b/app/Controllers/Make.php @@ -0,0 +1,55 @@ +session = session(); + $this->BikemakeModel = new BikemakeModel(); + } + + public function index() + { + + $BikemakeModel = new BikemakeModel(); + $make = $BikemakeModel->findAll(); + $data['make']=$make; + + return view('make_list',$data); + } + + + + public function create_make() + { + try { + $make_name = $this->request->getPost('makename'); + $BikemakeModel = new BikemakeModel(); + $data = [ + 'make' => $make_name + ]; + $inserted = $BikemakeModel->insert($data); + if ($inserted) { + $result = $data; + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Model.php b/app/Controllers/Model.php new file mode 100644 index 0000000..e5e6d5a --- /dev/null +++ b/app/Controllers/Model.php @@ -0,0 +1,99 @@ +session = session(); + $this->BikemodelsModel = new BikemodelsModel(); + $this->BikemakeModel = new BikemakeModel(); + + } + + public function index($make_id) + { + $BikemodelsModel = new BikemodelsModel(); + $BikemakeModel = new BikemakeModel(); + + $make_value = $BikemakeModel->where('make_id',$make_id)->select('make_id,make')->find(); + $make_name= $make_value[0]['make']; + $make_id= $make_value[0]['make_id']; + + $model = $BikemodelsModel->where('make_id',$make_id)->findAll(); + $data['model']=$model; + $data['make_name'] =$make_name; + $data['make_id'] =$make_id; + + return view('bike_model_list',$data); + } + + + public function create_model() + { + try { + $make_id = $this->request->getPost('make_id'); + $model_name = $this->request->getPost('modelname'); + + $BikemodelsModel = new BikemodelsModel(); + $data = [ + 'make_id' => $make_id, + 'model_name' => $model_name + ]; + + $inserted = $BikemodelsModel->insert($data); + if ($inserted) { + $result = $data; + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } catch (\Exception $exception) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); + } + } + + + + public function status_model() + { + + try { + $model_id = $this->request->getPost('model_id'); + $isactive = $this->request->getPost('isactive'); + + $BikemodelsModel = new BikemodelsModel(); + $data = [ + 'isactive' => $isactive + ]; + + $updated = $BikemodelsModel->update($model_id, $data); + $model_list = $BikemodelsModel->findAll(); + if ($updated) { + $result = $data; + return $this->respond(['status' => 'success','code' => 200,'data' => $model_list],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } catch (\Exception $exception) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); + } + } + + + +} \ No newline at end of file diff --git a/app/Views/bike_model_list.php b/app/Views/bike_model_list.php new file mode 100644 index 0000000..8b981d9 --- /dev/null +++ b/app/Views/bike_model_list.php @@ -0,0 +1,194 @@ + +
| Bike Make | +Action | +
|---|---|
| + | + + + + " class="view-list-button" title="Model List"> + + + | +