freshinteractive / fresh-events
Fresh Events 旨在与 Laravel 和 Laravel Nova 一起使用,使创建和管理事件变得轻松。
1.1.25
2023-05-18 15:53 UTC
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-09-18 19:14:28 UTC
README
Fresh Events 旨在与 Laravel 和 Laravel Nova 一起使用,使创建和管理事件变得轻松。
安装
通过 Composer
$ composer require freshinteractive/fresh-events
$ php artisan fresh-events:install
在 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.
]);
}
配置
您可以通过以下示例使用自己的 "registrant" 类型模型和 nova 资源。
在此示例中,我们将创建一个名为 Lead 的模型和 nova 资源,并使用该模型作为我们的 "registrant" 模型和 nova 资源。
重要:替换的 "registrant" 模型必须包含一个名为 'email' 的字符串字段
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()
];
}
用法
像使用任何其他 Nova 资源一样使用包含的 Nova 资源。
端点
您可以使用这些端点检索构建自定义前端所需的所有事件相关信息。
- /api/fresh-events/events (事件索引)
- /api/fresh-events/events/{event:url} (事件显示)
变更日志
请参阅 变更日志 以获取有关最近更改的更多信息。
测试
$ composer test
贡献
请参阅 contributing.md 以获取详细信息和一个待办事项列表。
安全
如果您发现任何安全相关的问题,请通过 dev@freshiscool.com 发送电子邮件,而不是使用问题跟踪器。
致谢
许可
MIT。有关更多信息,请参阅 许可文件。