how to initialize events in fullcalendar through json data in laravel code example
Example: how to initialize events in fullcalendar through json data in laravel
<?php
class CalendarController extends \BaseController {
/**
* Display a listing of calendar
*
* @return Response
*/
public function index()
{
$event = DB::table('events')
->leftJoin('people','people.people_id','=','events.people_id')
->leftJoin('people_roles','people_roles.people_id','=','events.people_id')
->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'));
//return View::make('people.show', compact('address'));
return Response::json($event);
}
/**
* Show the form for creating a new calendar
*
* @return Response
*/
public function create()
{
return View::make('calendar.create');
}
/**
* Store a newly created calendar in storage.
*
* @return Response
*/
public function store()
{
$events= Input::get('type');
$events= new Events;
$events->people_id = Input::get('people_id');
$events->evt_description =Input::get('title');
$events->date1 =Input::get('start');
$events->date2 =Input::get('end');
//$events->time =Input::get('time');
$events->save();
//$validator = Validator::make($data = Input::all(), Events::$rules);
/*if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}*/
//Calendar::create($data);
return Response::json($events);
//return Redirect::route('calendar.index');
}
/**
* Display the specified calendar.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$calendar = Calendar::findOrFail($id);
return View::make('calendar.show', compact('calendar'));
}
/**
* Show the form for editing the specified calendar.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$calendar = Calendar::find($id);
return View::make('calendar.edit', compact('calendar'));
}
/**
* Update the specified calendar in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//$type=Input::get('type');
$event_id= Input::get('event_id');
$title= Input::get('title');
$roles = DB::table('events')
->where('event_id','=',$event_id )
->update(array('evt_description' => $title));
return Response::json(array('eventid'=>$event_id,'title'=>$title));
/*$calendar = Calendar::findOrFail($id);
$validator = Validator::make($data = Input::all(), Calendar::$rules);
if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}
$calendar->update($data);
return Redirect::route('calendar.index');*/
}
/**
* Remove the specified calendar from storage.
*
* @param int $id
* @return Response
*/
public function destroy()
{
// Calendar::destroy($id);
$event_id= Input::get('eventid');
DB::table('events')->where('event_id','=',$event_id)->delete();
return Response::json($event_id);
// return Redirect::route('calendar.index');
}
}