Code Monkey home page Code Monkey logo

Comments (4)

wdelfuego avatar wdelfuego commented on May 28, 2024 1

I've been playing with this and have to choose from several approaches. Will probably be released in version 2.0 together with PHP7 support because I don't think I can do this without introducing breaking changes.

from nova-calendar.

Violet-Vibes avatar Violet-Vibes commented on May 28, 2024

This is something I would definitely use as it'd allow me to separate certain types of events into their own calendar as currently some days can get very "cluttered" when there's a ton of stuff going on.

from nova-calendar.

vesper8 avatar vesper8 commented on May 28, 2024

Well with very little effort I was able to hack something together that allows for this. Here's how I did it.

First I needed to add multiple new routes that would all lead to the same calendar. So inside my NovaServiceProvider.php boot method I added


        $this->app->booted(function () {
            Nova::router(['nova', \Wdelfuego\NovaCalendar\Http\Middleware\Authorize::class], 'bookings-calendar')
            ->group(base_path('vendor/wdelfuego/nova-calendar/routes/inertia.php'));

            Nova::router(['nova', \Wdelfuego\NovaCalendar\Http\Middleware\Authorize::class], 'lessons-calendar')
            ->group(base_path('vendor/wdelfuego/nova-calendar/routes/inertia.php'));
        });

So now I have two routes that lead to my calendar /nova/bookings-calendar and /nova/lessons-calendar

Then, inside my CalendarDataProvider I simply need to know which route I'm on and based on this I'll use different resources.

Here's how I did that:



    public function novaResources(): array
    {
        switch(basename(request()->server('HTTP_REFERER'))) {
            case 'bookings-calendar':
                $resources = [
                    \App\Nova\Resources\Bookings\Booking::class => ['starts_at', 'ends_at'],
                ];
                break;

            case 'lessons-calendar':
                $resources = [
                    \App\Nova\Resources\Bookings\BookingLesson::class => 'created_at',
                ];
                break;
        }

        return $resources;
    }

And voila! Easy-peasy ;-)

from nova-calendar.

wdelfuego avatar wdelfuego commented on May 28, 2024

Will be released in 2.0 for sure, already available on the dev branch

from nova-calendar.

Related Issues (20)

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.