freshinteractive / fresh-events
Fresh Events is meant to be used with Laravel and Laravel Nova, and makes creating and managing events a breeze.
Requires
- php: ^7.4|^8.0
- digital-creative/conditional-container: ^1.3
- ebess/advanced-nova-media-library: ^3.3
- froala/nova-froala-field: ^3.4
- gterrusa/frontendmedialibrary: ^1.1.4
- laravel/framework: ^7.0|^8.0
- laravel/legacy-factories: ^1.1
- laravel/nova: ^3.0
- maatwebsite/laravel-nova-excel: ^1.2.5
- spatie/laravel-medialibrary: ~8|~9
- spatie/laravel-tags: ~2|~3|~4
- spatie/nova-tags-field: ~2|~3
- staudenmeir/eloquent-has-many-deep: ^1.12
- whitecube/nova-flexible-content: ^0.2.8
Requires (Dev)
- orchestra/testbench: ~5|~6
- phpunit/phpunit: ~9.0
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-11-18 19:44:19 UTC
README
Fresh Events is meant to be used with Laravel and Laravel Nova, and makes creating and managing events a breeze.
Installation
Via Composer
$ composer require freshinteractive/fresh-events
$ php artisan fresh-events:install
Include in NovaServiceProvider.php:
/**
* Register the application's Nova resources.
*
* @return void
*/
protected function resources()
{
Nova::resourcesIn(app_path('Nova'));
Nova::resources([
\Freshinteractive\FreshEvents\Nova\Event::class,
\Freshinteractive\FreshEvents\Nova\Asset::class,
\Freshinteractive\FreshEvents\Nova\Session::class,
\Freshinteractive\FreshEvents\Nova\TimeSlot::class,
\Freshinteractive\FreshEvents\Nova\Speaker::class,
\Freshinteractive\FreshEvents\Nova\Registrant::class, // Comment out if not using default registrant class.
]);
}
Config
You can use your own "registrant" type model and nova resource by following the example below.
In this example, we will create a model and nova resource called Lead , and use this model as our "registrant" model and nova resource.
IMPORTANT: the replacement "registrant" model must include a string 'email' field
config/fresh-events.php
<?php
use App\Models\Lead;
use App\Nova\Lead as LeadResource;
return [
'registrant_model' => Lead::class, // the fully qualified class name to replace the default 'registrant_model' with.
'registrant_nova_resource' => LeadResource::class // the fully qualified class name to replace the default 'registrant_nova_resource' with.
];
app/Models/Lead.php
<?php
namespace App\Models;
use Freshinteractive\FreshEvents\Traits\RegistrantRelationships;
use Illuminate\Database\Eloquent\Model;
class Lead extends Model
{
use RegistrantRelationships; // make sure to include this
...
/**
* Maps what fields should be downloaded by the 'ExportRegistrants' action.
* In the form of 'field_name' => 'Heading Name'
*
* @return string[]
*/
public static function downloadFields(): array
{
return [
'name' => 'Name',
'email' => 'Email'
];
}
}
app/Nova/Lead.php
<?php
namespace App\Nova;
...
class Lead extends Resource
{
use RegistrantRelationshipsFields; // includes relationshipFields function.
...
/**
* The logical group associated with the resource.
*
* @var string
*/
public static $group = 'Fresh Events'; // include this if you'd like it to fall under the "Fresh Events" group in the Nova sidebar
...
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
...
new Panel('Relationships', $this->relationshipFields()) // call the relationship fields
];
}
...
/**
* Get the actions available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function actions(Request $request)
{
return [
(new DownloadExcel())
->withFilename('leads-' . time() . '.csv')
->withHeadings()
];
}
Usage
Use the included Nova Resources as you would any other Nova Resource.
Endpoints:
You can use these endpoints to retrieve any event related information that you need to build out a custom frontend.
- /api/fresh-events/events (events index)
- /api/fresh-events/events/{event:url} (events show)
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email dev@freshiscool.com instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.