Example #1
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $data['user'] = Auth::user();
     $perms = Auth::user()->menushow()->get();
     foreach ($perms as $perm) {
         $ltdperms[] = $perm->society_id;
     }
     $data['groups'] = Group::wherein('society_id', $ltdperms)->where('contact', '=', $data['user']->individual_id)->orderBy('groupname')->get();
     $data['recentedits'] = Individual::socindivrecent($ltdperms)->orderBy('individuals.updated_at', 'desc')->take(5)->get();
     $data['recentadds'] = Individual::socindivrecent($ltdperms)->orderBy('individuals.created_at', 'desc')->take(5)->get();
     $data['recentpastorals'] = Pastoral::with('household', 'individual')->has('household')->orderBy('diarydate', 'desc')->take(5)->get();
     $thisyr = date("Y");
     $mon = strval(date('m-d', strtotime("next Monday") - 604800));
     $tue = strval(date('m-d', strtotime("next Monday") + 86400 - 604800));
     $wed = strval(date('m-d', strtotime("next Monday") + 172800 - 604800));
     $thu = strval(date('m-d', strtotime("next Monday") + 259200 - 604800));
     $fri = strval(date('m-d', strtotime("next Monday") + 345600 - 604800));
     $sat = strval(date('m-d', strtotime("next Monday") + 432000 - 604800));
     $sun = strval(date('m-d', strtotime("next Monday") + 518400 - 604800));
     $days = array($mon, $tue, $wed, $thu, $fri, $sat, $sun);
     $data['birthdays'] = Individual::join('households', 'household_id', '=', 'households.id')->select('individuals.id', 'society_id', 'household_id', 'homephone', 'householdcell', 'cellphone', 'firstname', 'surname', DB::raw('substr(birthdate, 6, 5) as bd'))->wherein(DB::raw('substr(birthdate, 6, 5)'), $days)->orderBy(DB::raw('substr(birthdate, 6, 5)'))->get();
     $data['anniversaries'] = Specialday::join('households', 'household_id', '=', 'households.id')->select('homephone', 'society_id', 'householdcell', 'addressee', 'household_id', 'anntype', 'details', DB::raw('substr(anniversarydate, 6, 5) as ad'))->wherein(DB::raw('substr(anniversarydate, 6, 5)'), $days)->orderBy(DB::raw('substr(anniversarydate, 6, 5)'))->get();
     $view->with($data);
 }
Example #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($society, $hid, $id)
 {
     $pastoral = Pastoral::find($id);
     $pastoral->delete();
     return Redirect::to($society . '/households/' . $hid)->with('okmessage', 'Pastoral entry deleted');
 }