php - i cant see my event in full calendar in Laravel project -
im working on open source project in laravel ,this booking room system , every thing working there somthing in full calendar script cant see event have created , when vew source page see event correctly not show in calendar
this booking index page script code full calendar:
@inject('request', 'illuminate\http\request') @extends('layouts.app') @section('content') <h3 class="page-title">@lang('quickadmin.bookings.title')</h3> @can('booking_create') <p> <a href="{{ route('admin.bookings.create') }}" class="btn btn-success">@lang('quickadmin.qa_add_new')</a> </p> @endcan <link href='//fonts.googleapis.com/css?family=lato:100,400,700' rel='stylesheet' /> <link href='https://fullcalendar.io/css/base.css?3.5.1-1.7.1-1' rel='stylesheet' /> <link rel='stylesheet' href='https://fullcalendar.io/js/fullcalendar-3.5.1/fullcalendar.min.css' /> <div id='calendar'></div> @stop @section('javascript') <script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src='https://fullcalendar.io/js/fullcalendar-3.5.1/fullcalendar.min.js'></script> <script src='https://fullcalendar.io/js/home.js?3.5.1-1.7.1-1'></script> <script> $(document).ready(function(){ $('#calendar').fullcalendar({ defaultview: 'agendaweek', editable: true, events:[ @foreach($bookings $booking) { title:'{{$booking->room->name.' '.$booking->room->notes}}', start:'{{$booking->date.' '.$booking->start_time}}', finish:'{{$booking->date.' '.$booking->finish_time}}', url :'{{route('admin.bookings.edit',$booking->id)}}' }, @endforeach ] }) }); </script> @endsection
this booking controller :
<?php namespace app\http\controllers\admin; use app\booking; use illuminate\http\request; use illuminate\support\facades\gate; use app\http\controllers\controller; use app\http\requests\admin\storebookingsrequest; use app\http\requests\admin\updatebookingsrequest; class bookingscontroller extends controller { /** * display listing of booking. * * @return \illuminate\http\response */ public function index() { if (! gate::allows('booking_access')) { return abort(401); } if (request('show_deleted') == 1) { if (! gate::allows('booking_delete')) { return abort(401); } $bookings = booking::onlytrashed()->get(); } else { $bookings = booking::all(); } return view('admin.bookings.index', compact('bookings')); } /** * show form creating new booking. * * @return \illuminate\http\response */ public function create() { if (! gate::allows('booking_create')) { return abort(401); } $rooms = \app\room::get()->pluck('name', 'id')->prepend(trans('quickadmin.qa_please_select'), ''); return view('admin.bookings.create', compact('rooms')); } /** * store newly created booking in storage. * * @param \app\http\requests\storebookingsrequest $request * @return \illuminate\http\response */ public function store(storebookingsrequest $request) { if (! gate::allows('booking_create')) { return abort(401); } $booking = booking::create($request->all()); return redirect()->route('admin.bookings.index'); } /** * show form editing booking. * * @param int $id * @return \illuminate\http\response */ public function edit($id) { if (! gate::allows('booking_edit')) { return abort(401); } $rooms = \app\room::get()->pluck('name', 'id')->prepend(trans('quickadmin.qa_please_select'), ''); $booking = booking::findorfail($id); return view('admin.bookings.edit', compact('booking', 'rooms')); } /** * update booking in storage. * * @param \app\http\requests\updatebookingsrequest $request * @param int $id * @return \illuminate\http\response */ public function update(updatebookingsrequest $request, $id) { if (! gate::allows('booking_edit')) { return abort(401); } $booking = booking::findorfail($id); $booking->update($request->all()); return redirect()->route('admin.bookings.index'); } /** * display booking. * * @param int $id * @return \illuminate\http\response */ public function show($id) { if (! gate::allows('booking_view')) { return abort(401); } $booking = booking::findorfail($id); return view('admin.bookings.show', compact('booking')); } /** * remove booking storage. * * @param int $id * @return \illuminate\http\response */ public function destroy($id) { if (! gate::allows('booking_delete')) { return abort(401); } $booking = booking::findorfail($id); $booking->delete(); return redirect()->route('admin.bookings.index'); } /** * delete selected booking @ once. * * @param request $request */ public function massdestroy(request $request) { if (! gate::allows('booking_delete')) { return abort(401); } if ($request->input('ids')) { $entries = booking::wherein('id', $request->input('ids'))->get(); foreach ($entries $entry) { $entry->delete(); } } } /** * restore booking storage. * * @param int $id * @return \illuminate\http\response */ public function restore($id) { if (! gate::allows('booking_delete')) { return abort(401); } $booking = booking::onlytrashed()->findorfail($id); $booking->restore(); return redirect()->route('admin.bookings.index'); } /** * permanently delete booking storage. * * @param int $id * @return \illuminate\http\response */ public function perma_del($id) { if (! gate::allows('booking_delete')) { return abort(401); } $booking = booking::onlytrashed()->findorfail($id); $booking->forcedelete(); return redirect()->route('admin.bookings.index'); } }
this booking model :
<?php namespace app; use illuminate\database\eloquent\model; use carbon\carbon; use illuminate\database\eloquent\softdeletes; /** * class booking * * @package app * @property string $room * @property string $booking_name * @property string $start_time * @property string $finish_time * @property string $phone * @property string $email * @property string $notes */ class booking extends model { use softdeletes; protected $fillable = ['booking_name', 'start_time', 'finish_time', 'phone', 'email', 'notes', 'room_id']; /** * set null if empty * @param $input */ public function setroomidattribute($input) { $this->attributes['room_id'] = $input ? $input : null; } /** * set attribute date format * @param $input */ public function setstarttimeattribute($input) { if ($input != null && $input != '') { $this->attributes['start_time'] = carbon::createfromformat(config('app.date_format') . ' h:i:s', $input)->format('y-m-d h:i:s'); } else { $this->attributes['start_time'] = null; } } /** * attribute date format * @param $input * * @return string */ public function getstarttimeattribute($input) { $zerodate = str_replace(['y', 'm', 'd'], ['0000', '00', '00'], config('app.date_format') . ' h:i:s'); if ($input != $zerodate && $input != null) { return carbon::createfromformat('y-m-d h:i:s', $input)->format(config('app.date_format') . ' h:i:s'); } else { return ''; } } /** * set attribute date format * @param $input */ public function setfinishtimeattribute($input) { if ($input != null && $input != '') { $this->attributes['finish_time'] = carbon::createfromformat(config('app.date_format') . ' h:i:s', $input)->format('y-m-d h:i:s'); } else { $this->attributes['finish_time'] = null; } } /** * attribute date format * @param $input * * @return string */ public function getfinishtimeattribute($input) { $zerodate = str_replace(['y', 'm', 'd'], ['0000', '00', '00'], config('app.date_format') . ' h:i:s'); if ($input != $zerodate && $input != null) { return carbon::createfromformat('y-m-d h:i:s', $input)->format(config('app.date_format') . ' h:i:s'); } else { return ''; } } public function room() { return $this->belongsto(room::class, 'room_id')->withtrashed(); } }
this route of booking:
route::resource('bookings', 'admin\bookingscontroller'); route::post('bookings_mass_destroy', ['uses' => 'admin\bookingscontroller@massdestroy', 'as' => 'bookings.mass_destroy']); route::post('bookings_restore/{id}', ['uses' => 'admin\bookingscontroller@restore', 'as' => 'bookings.restore']); route::delete('bookings_perma_del/{id}', ['uses' => 'admin\bookingscontroller@perma_del', 'as' => 'bookings.perma_del']);
Comments
Post a Comment