Code Monkey home page Code Monkey logo

laravel-fullcalendar's Introduction

Laravel fullcalendar component

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock Build Status Scrutinizer Code Quality

Installation

The preferred way to install this extension is through composer.

To install, either run

$ php composer.phar require edofre/laravel-fullcalendar

or add

"edofre/laravel-fullcalendar": "V1.2.4"

to the require section of your composer.json file.

Note

The fxp/composer-asset plugin is required for this package to install properly. This plugin enables you to download bower packages through composer.

You can install it using this command:

composer global require "fxp/composer-asset-plugin:^1.4.0โ€

This will add the fxp composer-asset-plugin and your composer will be able to find and download the required bower-asset/fullcalendar package. You can find more info on this page: https://packagist.org/packages/fxp/composer-asset-plugin.

Configuration

Add the ServiceProvider to your config/app.php

'providers' => [
        ...
        Edofre\Fullcalendar\FullcalendarServiceProvider::class,
    ],

And add the facade

'aliases' => [
        ...
        'Fullcalendar' => Edofre\Fullcalendar\Facades\Fullcalendar::class,
    ],

Publish assets and configuration files

php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=fullcalendar

Manually loading script files

By setting the include_scripts option in the config/.env file to false the scripts will not be included when generating the calendar. If you want to manually include the scripts you can call the following static function in your header/footer/etc.

    \Edofre\Fullcalendar\Fullcalendar::renderScriptFiles();

Example

Below is an example of a controller action configuring the calendar

    public function index()
    {
        // Generate a new fullcalendar instance
        $calendar = new \Edofre\Fullcalendar\Fullcalendar();

        // You can manually add the objects as an array
        $events = $this->getEvents();
        $calendar->setEvents($events);
        // Or you can add a route and return the events using an ajax requests that returns the events as json
        $calendar->setEvents(route('fullcalendar-ajax-events'));

        // Set options
        $calendar->setOptions([
            'locale'      => 'nl',
            'weekNumbers' => true,
            'selectable'  => true,
            'defaultView' => 'agendaWeek',
            // Add the callbacks
            'eventClick' => new \Edofre\Fullcalendar\JsExpression("
                function(event, jsEvent, view) {
                    console.log(event);
                }
            "),
            'viewRender' => new \Edofre\Fullcalendar\JsExpression("
                function( view, element ) {
                    console.log(\"View \"+view.name+\" rendered\");
                }
            "),
        ]);

        // Check out the documentation for all the options and callbacks.
        // https://fullcalendar.io/docs/

        return view('fullcalendar.index', [
            'calendar' => $calendar,
        ]);
    }

    /**
     * @param Request $request
     * @return string
     */
    public function ajaxEvents(Request $request)
    {
        // start and end dates will be sent automatically by fullcalendar, they can be obtained using:
        // $request->get('start') & $request->get('end')
        $events = $this->getEvents();
        return json_encode($events);
    }

    /**
     * @return array
     */
    private function getEvents()
    {
        $events = [];
        $events[] = new \Edofre\Fullcalendar\Event([
            'id'     => 0,
            'title'  => 'Rest',
            'allDay' => true,
            'start'  => Carbon::create(2016, 11, 20),
            'end'    => Carbon::create(2016, 11, 20),
        ]);

        $events[] = new \Edofre\Fullcalendar\Event([
            'id'    => 1,
            'title' => 'Appointment #' . rand(1, 999),
            'start' => Carbon::create(2016, 11, 15, 13),
            'end'   => Carbon::create(2016, 11, 15, 13)->addHour(2),
        ]);

        $events[] = new \Edofre\Fullcalendar\Event([
            'id'               => 2,
            'title'            => 'Appointment #' . rand(1, 999),
            'editable'         => true,
            'startEditable'    => true,
            'durationEditable' => true,
            'start'            => Carbon::create(2016, 11, 16, 10),
            'end'              => Carbon::create(2016, 11, 16, 13),
        ]);

        $events[] = new \Edofre\Fullcalendar\Event([
            'id'               => 3,
            'title'            => 'Appointment #' . rand(1, 999),
            'editable'         => true,
            'startEditable'    => true,
            'durationEditable' => true,
            'start'            => Carbon::create(2016, 11, 14, 9),
            'end'              => Carbon::create(2016, 11, 14, 10),
            'backgroundColor'  => 'black',
            'borderColor'      => 'red',
            'textColor'        => 'green',
        ]);
        return $events;
    }

You can then render the calendar by generating the HMTL and scripts

    {!! $calendar->generate() !!}

Tests

Run the tests by executing the following command:

composer test

laravel-fullcalendar's People

Contributors

ebarquero85 avatar edofre avatar meirct avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-fullcalendar's Issues

Your requirements could not be resolved to an installable set of packages

When I try to install it I get the following error.

composer require edofre/laravel-fullcalendar
Using version ^1.1 for edofre/laravel-fullcalendar
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for edofre/laravel-fullcalendar ^1.1 -> satisfiable by edofre/laravel-fullcalendar[V1.1.0].
    - edofre/laravel-fullcalendar V1.1.0 requires bower-asset/fullcalendar v3.0.1 -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Install order fix

Hey,
please replace the order of the following install steps:
Publish assets and configuration files
and
Add the ServiceProvider to your config/app.php

because files won't be published this way.
thanks :)

Unknown downloader type on install

Hi, I am getting this error when I try to install via composer:

[InvalidArgumentException]
Unknown downloader type: npm-signature. Available types: git, svn, fossil,
hg, perforce, zip, rar, tar, gzip, xz, phar, file, path.

I have the fxp/composer-asset-plugin.

Please advise

Laravel 5.4

Hi Edofre!

I'd like to try your callendar ($ composer require edofre/laravel-fullcalendar
) but I've got this error message:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- edofre/laravel-fullcalendar V1.0.6 requires laravel/framework 5.3.* -> satisfiable by laravel/framework[5.3.x-dev, v5.3.0, v5.3.0-RC1, v5.3.1, v5.3.10, v5.3.11, v5.3.12, v5.3.13, v5.3.14, v5.3.15, v5.3.16, v5.3.17, v5.3.18, v5.3.19, v5.3.2, v5.3.20, v5.3.21, v5.3.22, v5.3.23, v5.3.24, v5.3.25, v5.3.26, v5.3.27, v5.3.28, v5.3.29, v5.3.3, v5.3.30, v5.3.4, v5.3.5, v5.3.6, v5.3.7, v5.3.8, v5.3.9] but these conflict with your requirements or minimum-stability.

Best Regards!

failing at L5.5

Trying to install at a fresh project with Laravel 5.5 is throwing the following error:

$ composer require edofre/laravel-fullcalendar
Using version ^1.2 for edofre/laravel-fullcalendar
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals

  • Installing npm-asset/moment (2.18.1): Downloading (100%)
  • Installing npm-asset/jquery (3.2.1): Downloading (100%)
  • Installing npm-asset/fullcalendar (3.4.0): Downloading (100%)
  • Installing edofre/laravel-fullcalendar (V1.2.0): Downloading (100%)
    Writing lock file
    Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover

[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'EdoFre\Fullcalendar\FullcalendarServiceProvider' not found

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json to its original content.

5.5

Using version ^1.2 for edofre/laravel-fullcalendar
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- edofre/laravel-fullcalendar V1.2.4 requires npm-asset/fullcalendar v3.8.0 -> no matching package found.
- edofre/laravel-fullcalendar V1.2.3 requires npm-asset/fullcalendar v3.5.1 -> no matching package found.
- edofre/laravel-fullcalendar V1.2.2 requires npm-asset/fullcalendar v3.5.1 -> no matching package found.
- edofre/laravel-fullcalendar V1.2.1 requires npm-asset/fullcalendar v3.4.0 -> no matching package found.
- edofre/laravel-fullcalendar V1.2.0 requires npm-asset/fullcalendar v3.4.0 -> no matching package found.
- Installation request for edofre/laravel-fullcalendar ^1.2 -> satisfiable by edofre/laravel-fullcalendar[V1.2.0, V1.2.1, V1.2.2, V1.2.3, V1.2.4].

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

Call to undefined function Edofre\Fullcalendar\JsExpression()

Hi, I just followed the README file.

  1. When I run the following, nothing happens.
php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=fullcalendar
  1. When I go to calendar page I get the following error.

Call to undefined function Edofre\Fullcalendar\JsExpression()

  1. The package put the following css and js, but links are not working. How can I modify the link?
<h1>Calendar</h1>
<div id='fullcalendar'></div><!-- fullcalendar css -->
<link href="/css/fullcalendar.print.css" rel="stylesheet" media="print">
<link href="/css/fullcalendar.css" rel="stylesheet">
<!-- moment js -->
<script src="/js/moment.js"></script>
<!-- fullcalendar js -->
<script src="/js/fullcalendar.js"></script>
<script src="/js/locale-all.js"></script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.