vendredi 5 octobre 2018

How to use fullcalendar eventSources for 2 Table Database on Laravel

i am beginner on web programing, i have succes to show start date and end date on my fullcalender, but only 1 table from database, i need to show more date from other table with only one calendar. table name is holiday and leave. how to make it ? this is my code.

My Controller

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Holiday;
use App\Leave;

class HolidayController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $holiday = Holiday::all();
        $leave = Leave::all();
        return view('holiday.index', compact('holiday','leave'));
    }

My index.blade.php

        <h1 class="page-title">Holiday Calendar</h1>
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a href="">Home</a>
                    <i class="fa fa-angle-right"></i>
                </li>
                <li>
                    <span>Holiday Calendar</span>
                </li>
            </ul>
            <div class="page-toolbar">
            </div>
        </div>
        <div></div>
         <div class="col-md-12">
                <div class="portlet box white">
                    <div id="calendar1"></div>
                </div>
            </div>
        </div>
<!-- END CONTENT -->
@endsection

@section('script')
<script type="text/javascript">
 $(document).ready(function() {

        // page is now ready, initialize the calendar...
        $('#calendar1').fullCalendar({
            // put your options and callbacks here
            events :[
                @foreach($holiday as $holidays){
                    title : '',
                    start : '',
                    end : ''
                },  
                @endforeach
            ]    
        })
    });    
</script>

@yield('js')

@endsection



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire