EVOLUTION-NINJA
Edit File: Notification_Model.php
<?php namespace App\Models\Admin; use CodeIgniter\Model; class Notification_Model extends Model { // protected $table = 'notification'; protected $table = 'notification'; protected $primaryKey = 'id'; public function getWhereResult($table, $where) { return $this->db->table($table) ->select('*') ->where($where) ->get() ->getResult(); } // public function getWhereResultOrderBy($table, $where, $orderBy) // { // return $this->db->table($table) // ->select('*') // ->where($where) // ->orderBy($orderBy, 'DESC') // ->get() // ->getResult(); // } public function updateData($table, $data, $where) { $builder = $this->db->table($table); $builder->where($where); return $builder->update($data); } public function getWhereResultOrderBy($table, $where, $orderBy) { $builder = $this->db->table($table); $builder->where($where); $builder->orderBy($orderBy); return $builder->get()->getResult(); } public function update($id = null, $data = null): bool { if ($id === null || $data === null) { return false; } $builder = $this->db->table('notification'); $builder->where('notification_id', $id); // Replace 'notification_id' with your primary key column name $builder->update($data); return $this->db->affectedRows() > 0; } public function getNotifications() { // Query to fetch notifications, adjust the table name and columns as needed $query = $this->db->get('notification'); return $query->result(); // Return the results as an array of objects } public function deleteNotification($notificationId) { // Delete a notification by ID $builder = $this->db->table('notification'); // Make sure your table name is correct $builder->where('notification_id', $notificationId); $builder->delete(); // Check if any rows were affected if ($this->db->affectedRows() > 0) { return true; } else { return false; } } // public function getNotifications() { // // Fetch notifications with the 'id' field // return $this->db->select('id, category_type, notification, created_at') // ->get('notifications') // ->result(); // } // public function delete_notification($notification_id) // { // // Attempt to delete the notification // $this->where('notification_id', $notification_id)->delete(); // // Check if the deletion was successful and return true or false accordingly // return $this->db->affectedRows() > 0; // } // public function getData($href) // { // // Add your database query or data retrieval logic here // // For demonstration, we'll return a dummy response // $dummyData = [ // 'All Days' => 'Data for All Days', // 'This Week' => 'Data for This Week', // 'Today' => 'Data for Today', // ]; // // Return the data based on the href value // return $dummyData[$href] ?? 'No data found'; // } // public function getTabContent($tabName) { // // Perform database queries or any other necessary logic to retrieve tab content // // For demonstration purposes, let's assume you have a predefined array of tab content // $tabContents = array( // 'menu2' => 'Content for All Days tab', // 'menu1' => 'Content for This Week tab', // 'home' => 'Content for Today tab' // ); // // Check if the requested tabName exists in the predefined array // if (array_key_exists($tabName, $tabContents)) { // return $tabContents[$tabName]; // } else { // // Handle the case where the tabName is not found (e.g., return an error message) // return 'Tab content not found'; // } // } } ?>