public function home()
 {
     $q = Annoucement::with('role')->where(function ($query) {
         $query->where('start_date', '<=', date('Y-m-d'))->where('end_date', '>=', date('Y-m-d'));
     });
     if (!Auth::check()) {
         $q->where('for_all', '=', 1);
     } else {
         foreach (Auth::user()->roles as $role) {
             $role_id = $role->id;
         }
         $q->where(function ($query) use($role_id) {
             $query->where('for_all', '=', 1)->orWhere(function ($query1) use($role_id) {
                 $query1->whereHas('role', function ($query2) use($role_id) {
                     $query2->where('role_id', '=', $role_id);
                 });
             });
         });
     }
     $annoucements = $q->get();
     $assets = ['hide_sidebar'];
     return view('home', compact('assets', 'annoucements'));
 }
 public function destroy(Annoucement $annoucement)
 {
     if (!Entrust::can('delete_annoucement')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     Helper::deleteCustomField($this->form, $annoucement->id);
     $annoucement->delete();
     $activity = 'Deleted a annoucement';
     Activity::log($activity);
     return redirect('/annoucement')->withSuccess(config('constants.DELETED'));
 }