I'm doing a project in laravel, where I can show my list of events using fullcalendar. I already created/have a fullcalendar view with events and adding event, but I want to be able to click the date and edit it or delete it.
I already search some solutions or guides for this, but I can't work it properly. I tried creating another one from scratch but it doesn't work.
Here are the links that I searched and doing it as my guide.
FullCalendar Events and Scheduling
github driftingruby/042-fullcalendar
This is my codes in my create.blade.php
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">Event Calendar</div>
<div class="panel-body">
{!! Form::open(array('route' => 'admin/events.create','method'=>'POST','files'=>'true')) !!}
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
@if (Session::has('success'))
<div class="alert alert-success"></div>
@elseif (Session::has('warning'))
<div class="alert alert-danger"></div>
@endif
</div>
<div class="col-xs-4 col-sm-4 col-md-4">
<div class="form-group">
{!! Form::label('event_name','Event Name:') !!}
<div class="">
{!! Form::text('event_name', null, ['class' => 'form-control']) !!}
<!-- {!! $errors->first('event_name', '<p class="alert alert-danger">:message</p>') !!} -->
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="form-group">
{!! Form::label('start_date','Start Date:') !!}
<div class="">
{!! Form::date('start_date', null, ['class' => 'form-control']) !!}
<!-- {!! $errors->first('start_date', '<p class="alert alert-danger">:message</p>') !!} -->
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="form-group">
{!! Form::label('end_date','End Date:') !!}
<div class="">
{!! Form::date('end_date', null, ['class' => 'form-control']) !!}
<!-- {!! $errors->first('end_date', '<p class="alert alert-danger">:message</p>') !!} -->
</div>
</div>
</div>
<div class="col-xs-1 col-sm-1 col-md-1 text-center"> <br/>
{!! Form::submit('Add Event',['class'=>'btn btn-primary']) !!}
</div>
</div>
{!! Form::close() !!}
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">Event Details</div>
<div class="panel-body">
{!! $calendar_details->calendar() !!}
</div>
</div>
</div>
<link rel="stylesheet" href="https://cdjns.cloudfare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.css"/>
<!-- Scripts -->
<script src="http://code.jquery.com/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.js"></script>
{!! $calendar_details->script() !!}
And this is my code for my AdminEventsController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Events;
use App\Barangay;
use Illuminate\Support\Facades\Auth;
use Session;
use Calendar;
class AdminEventsController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index() {
$events = Events::get();
$event_list = [];
foreach ($events as $key => $event) {
$event_list[] = Calendar::event(
$event->event_name,
true,
new \DateTime($event->start_date),
new \DateTime($event->end_date.' +1 day')
);
}
$calendar_details = Calendar::addEvents($event_list);
return view('admin.events.create', compact('calendar_details') );
}
public function addEvent(Request $request)
{
$mybrgyid = Auth::user()->brgyid;
$mybarangay = Barangay::select('brgyname')->where('id', $mybrgyid)->get();
session(['mybarangay' => $mybarangay]);
$this->validate($request,[
'event_name' => 'required',
'start_date' => 'required',
'end_date' => 'required'
]);
//$validator = validator::make($request->all(), [
//'event_name' => 'required',
//'start_date' => 'required',
//'end_date' => 'required'
//]);
//if ($validator->fails()) {
// \session::flash('warning', 'Please enter the valid details');
// return Redirect::to('/admin/events')->withErrors($validator);
//}
$event = new Events;
$event->brgyid = Auth::user()->id;
$event->event_name = $request['event_name'];
$event->start_date = $request['start_date'];
$event->end_date = $request['end_date'];
$event->save();
return redirect('/admin/events')->with('success', 'Event Created');
}
}
Somehow I'm being confuse as to where I would create a modal for editing and deleting an event in my fullcalendar.
Your help is much appreciated.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TO4XMs
via IFTTT
Aucun commentaire:
Enregistrer un commentaire