Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. public function show_calendar(Field $field)
  2.     {        
  3.         return view('field.calendar', compact('field'));
  4.     }
  5.  
  6.     public function show_schedule(Request $request)
  7.     {        
  8.         $solicitations = Solicitation::where('field_id', '=', $request->field)->get();
  9.         $response = array();
  10.         foreach ($solicitations as $solicitation)
  11.         {
  12.             $object = array(
  13.                 'title' => $solicitation->person->name(),
  14.                 'start' => $solicitation->init_hour
  15.             );
  16.             array_push($response, $object);
  17.         }
  18.  
  19.         return Response()->json($response);
  20.     }
  21.  
  22.  
  23. -----
  24.  
  25.  
  26.  
  27. @extends('layouts.app')
  28.  
  29. @section('content')
  30. <body>
  31.  
  32.     <div id='calendar'></div>
  33.  
  34. </body>
  35. @endsection
  36. @section('script')
  37. <script>
  38.  
  39.     $(document).ready(function() {
  40.        
  41.         $('#calendar').fullCalendar({
  42.             header: {
  43.                 left: 'prev,next today',
  44.                 center: 'title',
  45.                 right: 'month,basicDay'
  46.             },
  47.             allDayText: false,
  48.             allDaySlot: false,
  49.             defaultTimedEventDuration: '01:00:00',
  50.             slotLabelFormat: 'h(:mm)a',
  51.             navLinks: true, // can click day/week names to navigate views
  52.             editable: true,
  53.             eventLimit: true, // allow "more" link when too many events
  54.             events: {
  55.                 url: '/field/schedules',
  56.                 type: 'POST',
  57.                 data:{
  58.                     "field": "{{ $field->id }}",
  59.                     "_token": "{{ csrf_token() }}"
  60.                 },
  61.                 error: function() {
  62.                     alert('Error al cargar las fechas');
  63.                 },
  64.                 color: '#008000',  
  65.                 textColor: 'white'
  66.             }
  67.         });
  68.        
  69.     });
  70.  
  71. </script>
  72.  
  73. @endsection
  74.  
  75. @section('style')
  76. <style>
  77.  
  78.     body {
  79.         margin: 0 0;
  80.         padding: 0;
  81.         font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  82.         font-size: 14px;
  83.     }
  84.  
  85.     #calendar {
  86.         max-width: 900px;
  87.         margin: 0 auto;
  88.     }
  89.  
  90. </style>
  91. @endsection('style')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement