Comments (4)
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.
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.
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.
Will be released in 2.0 for sure, already available on the dev
branch
from nova-calendar.
Related Issues (20)
- Applying styles to calendar cells (for example to highlight current day and fade-out days in the past) HOT 3
- Allow us to include html inside the event notes HOT 2
- Please allow CMD/Meta/Ctrl click to open in a new tab when clicking on an event HOT 3
- Customizing Event properties in custom event generator HOT 3
- Poor performance - eager loading breaks in Custom Event Generators HOT 1
- recommendation: calendar backend library vkurko/calendar
- ERROR There are no commands defined in the "nova-calendar" namespace. HOT 2
- calendar does not load - missing slash in api url HOT 7
- Week View Update? HOT 1
- [Bug] Method Laravel\Nova\Http\Requests\NovaRequest::schemeAndHttpHost does not exist HOT 7
- When searching, events are still clickable HOT 7
- month and year pickers disappear on press HOT 3
- BindingResolutionException: Target class [] does not exist. when caching routes HOT 4
- Ability to use url parameters for optionally filtering down HOT 11
- It is possible to change the URL by clicking the event to access a custom tool instead of using the resource? HOT 3
- Style problems HOT 6
- How can I add the calendar to my Main.php dashboard? HOT 1
- Vue warning DropdownTrigger HOT 4
- Cannot change url by method `withUrl()`, when events are created by generator HOT 3
- Status of day view, week view, ... HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nova-calendar.