public function scopeNotif($query) { $item = $query->where('status', 1)->where('parent_id', 0); if (!in_array(1, \Me::level())) { $item->where('data_feedback.id_karyawan', \Me::data()->id_karyawan); $item->select(\DB::raw('SUM(notif) AS total'))->groupby('status'); } else { $item->select(\DB::raw('COUNT(notif) AS total')); } }
public function access() { $paths = ''; for ($i = 0; $i < 2; $i++) { if (isset($this->path[$i])) { $paths .= $this->path[$i] . '/'; } } $path = rtrim($paths, '/'); $menu = data_menu_user::whereIn('id_level', \Me::level())->get(); $access = []; foreach ($menu as $val) { $access[] = $val->id_menu; } $slug = data_menu::whereIn('id_menu', $access)->select('slug')->get(); $slugs = []; foreach ($slug as $aces) { $slugs[] = $aces->slug; } if (!empty(\Request::path())) { $cek = empty($path) ? 0 : data_menu::whereSlug($path)->count(); if (!empty($path) && !in_array($path, $slugs) && $cek > 0) { return ['return' => false]; } $cek = empty($path) ? 0 : data_menu::whereSlug($path)->count(); if (!empty($path) && !in_array($path, $slugs) && $cek > 0) { return ['return' => false]; } } return ['return' => true]; }