1 <?php
2
3class CalendarController extends \BaseController {
4
5/**
6 * Display a listing of calendar
7 *
8 * @return Response
9 */
10public function index()
11{
12 $event = DB::table('events')
13
14 ->leftJoin('people','people.people_id','=','events.people_id')
15 ->leftJoin('people_roles','people_roles.people_id','=','events.people_id')
16 ->get(array('people.address_id','people.people_id','people.occupation','people.firstname','people.lastname','people.comment','people.gender','people.middlename','people_roles.school_year','people_roles.teacher','people_roles.parent','people_roles.teacher_a_id','people_roles.admin','events.event_id','events.evt_description','events.date1','events.date2','events.time'));
17 //return View::make('people.show', compact('address'));
18 return Response::json($event);
19}
20
21/**
22 * Show the form for creating a new calendar
23 *
24 * @return Response
25 */
26public function create()
27{
28 return View::make('calendar.create');
29}
30
31/**
32 * Store a newly created calendar in storage.
33 *
34 * @return Response
35 */
36public function store()
37{
38 $events= Input::get('type');
39 $events= new Events;
40 $events->people_id = Input::get('people_id');
41 $events->evt_description =Input::get('title');
42 $events->date1 =Input::get('start');
43 $events->date2 =Input::get('end');
44 //$events->time =Input::get('time');
45
46 $events->save();
47 //$validator = Validator::make($data = Input::all(), Events::$rules);
48
49 /*if ($validator->fails())
50 {
51 return Redirect::back()->withErrors($validator)->withInput();
52 }*/
53 //Calendar::create($data);
54 return Response::json($events);
55 //return Redirect::route('calendar.index');
56}
57
58/**
59 * Display the specified calendar.
60 *
61 * @param int $id
62 * @return Response
63 */
64public function show($id)
65{
66 $calendar = Calendar::findOrFail($id);
67
68 return View::make('calendar.show', compact('calendar'));
69}
70
71/**
72 * Show the form for editing the specified calendar.
73 *
74 * @param int $id
75 * @return Response
76 */
77public function edit($id)
78{
79 $calendar = Calendar::find($id);
80
81 return View::make('calendar.edit', compact('calendar'));
82}
83
84/**
85 * Update the specified calendar in storage.
86 *
87 * @param int $id
88 * @return Response
89 */
90public function update($id)
91{
92 //$type=Input::get('type');
93 $event_id= Input::get('event_id');
94 $title= Input::get('title');
95 $roles = DB::table('events')
96 ->where('event_id','=',$event_id )
97 ->update(array('evt_description' => $title));
98
99 return Response::json(array('eventid'=>$event_id,'title'=>$title));
100
101 /*$calendar = Calendar::findOrFail($id);
102
103 $validator = Validator::make($data = Input::all(), Calendar::$rules);
104
105 if ($validator->fails())
106 {
107 return Redirect::back()->withErrors($validator)->withInput();
108 }
109
110 $calendar->update($data);
111
112 return Redirect::route('calendar.index');*/
113
114}
115
116/**
117 * Remove the specified calendar from storage.
118 *
119 * @param int $id
120 * @return Response
121 */
122public function destroy()
123{
124// Calendar::destroy($id);
125$event_id= Input::get('eventid');
126DB::table('events')->where('event_id','=',$event_id)->delete();
127
128return Response::json($event_id);
129
130// return Redirect::route('calendar.index');
131}
132
133}
134