Bugfixes & Model for participants
This commit is contained in:
27
app/Enumerations/EfzStatus.php
Normal file
27
app/Enumerations/EfzStatus.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enumerations;
|
||||
|
||||
use App\Scopes\CommonModel;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @property string $slug
|
||||
* @property string $name
|
||||
*/
|
||||
class EfzStatus extends CommonModel
|
||||
{
|
||||
public const EFZ_STATUS_NOT_CHECKED = 'not_checked';
|
||||
public const EFZ_STATUS_NOT_REQUIRED = 'not_required';
|
||||
|
||||
public const EFZ_STATUS_CHECKED_VALID = 'checked_valid';
|
||||
public const EFZ_STATUS_CHECKED_INVALID = 'checked_invalid';
|
||||
|
||||
protected $table = 'efz_status';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'name',
|
||||
];
|
||||
}
|
||||
@@ -8,8 +8,8 @@ use App\Models\User;
|
||||
|
||||
class DevelopmentDataSeeder {
|
||||
public function execute() {
|
||||
//$this->installTenants();
|
||||
//$this->installUsers();
|
||||
$this->installTenants();
|
||||
$this->installUsers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Installer;
|
||||
use App\Enumerations\CostUnitType;
|
||||
use App\Enumerations\CronTaskType;
|
||||
use App\Enumerations\EatingHabit;
|
||||
use App\Enumerations\EfzStatus;
|
||||
use App\Enumerations\FirstAidPermission;
|
||||
use App\Enumerations\InvoiceStatus;
|
||||
use App\Enumerations\InvoiceType;
|
||||
@@ -12,20 +13,30 @@ use App\Enumerations\ParticipationFeeType;
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Enumerations\SwimmingPermission;
|
||||
use App\Enumerations\UserRole;
|
||||
use App\Models\CronTask;
|
||||
use App\Models\Tenant;
|
||||
|
||||
class ProductionDataSeeder {
|
||||
public function execute() {
|
||||
/*$this->installCronTypes();
|
||||
$this->installCronTypes();
|
||||
$this->installUserRoles();
|
||||
$this->installCostUnitTypes();
|
||||
$this->installSwimmingPermissions();
|
||||
$this->installEatingHabits();
|
||||
$this->installFirstAidPermissions();
|
||||
$this->installTenants();
|
||||
$this->installInvoiceMetaData();*/
|
||||
$this->installInvoiceMetaData();
|
||||
$this->installParticipationFeeTypes();
|
||||
$this->installParticipationTypes();
|
||||
$this->installEfzStatus();
|
||||
$this->installCronTasks();
|
||||
}
|
||||
|
||||
private function installEfzStatus() {
|
||||
EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_NOT_CHECKED, 'name' => 'Nicht geprüft']);
|
||||
EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_NOT_REQUIRED, 'name' => 'Nicht erforderlich']);
|
||||
EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_CHECKED_VALID, 'name' => 'Geprüft und gültig']);
|
||||
EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_CHECKED_INVALID, 'name' => 'Geprüft und ungültig']);
|
||||
}
|
||||
|
||||
private function installParticipationTypes() {
|
||||
@@ -141,7 +152,12 @@ class ProductionDataSeeder {
|
||||
}
|
||||
|
||||
private function installCronTypes() {
|
||||
CronTaskType::creata(['slug' => CronTaskType::CRON_TASK_TYPE_REALTIME]);
|
||||
CronTaskType::creata(['slug' => CronTaskType::CRON_TASK_TYPE_DAILY]);
|
||||
CronTaskType::create(['slug' => CronTaskType::CRON_TASK_TYPE_REALTIME]);
|
||||
CronTaskType::create(['slug' => CronTaskType::CRON_TASK_TYPE_DAILY]);
|
||||
}
|
||||
|
||||
private function installCronTasks() {
|
||||
CronTask::create(['name' => 'UploadInvoices', 'execution_type' => CronTaskType::CRON_TASK_TYPE_REALTIME]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Scopes\InstancedModel;
|
||||
use DateTime;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property string $tenant
|
||||
@@ -164,4 +165,8 @@ class Event extends InstancedModel
|
||||
return $this->belongsToMany(User::class, 'event_managers', 'event_id', 'user_id')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function participants() : hasMany {
|
||||
return $this->hasMany(EventParticipant::class);
|
||||
}
|
||||
}
|
||||
|
||||
135
app/Models/EventParticipant.php
Normal file
135
app/Models/EventParticipant.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Casts\AmountCast;
|
||||
use App\Enumerations\EatingHabit;
|
||||
use App\Enumerations\EfzStatus;
|
||||
use App\Enumerations\FirstAidPermission;
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Enumerations\SwimmingPermission;
|
||||
use App\Scopes\InstancedModel;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
|
||||
class EventParticipant extends InstancedModel
|
||||
{
|
||||
protected $table = 'event_participants';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant',
|
||||
'event_id',
|
||||
'user_id',
|
||||
|
||||
'firstname',
|
||||
'lastname',
|
||||
'nickname',
|
||||
|
||||
'participation_type',
|
||||
'local_group',
|
||||
'birthday',
|
||||
|
||||
'address_1',
|
||||
'address_2',
|
||||
'postcode',
|
||||
'city',
|
||||
|
||||
'email_1',
|
||||
'phone_1',
|
||||
'email_2',
|
||||
'phone_2',
|
||||
'contact_person',
|
||||
|
||||
'allergies',
|
||||
'intolerances',
|
||||
'eating_habits',
|
||||
'swimming_permission',
|
||||
'first_aid_permission',
|
||||
|
||||
'foto_socialmedia',
|
||||
'foto_print',
|
||||
'foto_webseite',
|
||||
'foto_partner',
|
||||
'foto_intern',
|
||||
|
||||
'arrival_date',
|
||||
'departure_date',
|
||||
'arrival_eating',
|
||||
'departure_eating',
|
||||
|
||||
'notes',
|
||||
'amount',
|
||||
'amount_paid',
|
||||
'efz_status',
|
||||
'unregistered_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'birthday' => 'datetime',
|
||||
'arrival_date' => 'datetime',
|
||||
'departure_date' => 'datetime',
|
||||
'unregistered_at' => 'datetime',
|
||||
|
||||
'foto_socialmedia' => 'boolean',
|
||||
'foto_print' => 'boolean',
|
||||
'foto_webseite' => 'boolean',
|
||||
'foto_partner' => 'boolean',
|
||||
'foto_intern' => 'boolean',
|
||||
|
||||
'amount' => AmountCast::class,
|
||||
'amount_paid' => AmountCast::class,
|
||||
];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Relationships
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public function event()
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function tenantRelation()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class, 'tenant', 'slug');
|
||||
}
|
||||
|
||||
public function localGroup()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class, 'local_group', 'slug');
|
||||
}
|
||||
|
||||
public function participationType()
|
||||
{
|
||||
return $this->belongsTo(ParticipationType::class, 'participation_type', 'slug');
|
||||
}
|
||||
|
||||
public function swimmingPermission()
|
||||
{
|
||||
return $this->belongsTo(SwimmingPermission::class, 'swimming_permission', 'slug');
|
||||
}
|
||||
|
||||
public function eatingHabit()
|
||||
{
|
||||
return $this->belongsTo(EatingHabit::class, 'eating_habits', 'slug');
|
||||
}
|
||||
|
||||
public function firstAidPermission()
|
||||
{
|
||||
return $this->belongsTo(FirstAidPermission::class, 'first_aid_permission', 'slug');
|
||||
}
|
||||
|
||||
public function efzStatus()
|
||||
{
|
||||
return $this->belongsTo(EfzStatus::class, 'efz_status', 'slug');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -68,18 +68,22 @@ class CostUnitRepository {
|
||||
$canSeeAll = false;
|
||||
$user = Auth()->user();
|
||||
|
||||
if ($tenant->slug !== 'lv') {
|
||||
if (
|
||||
$user->user_role_main === UserRole::USER_ROLE_ADMIN ||
|
||||
in_array( $user->user_role_local_group, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
|
||||
) {
|
||||
$canSeeAll = true;
|
||||
}
|
||||
if ($disableAccessCheck) {
|
||||
$canSeeAll = true;
|
||||
} else {
|
||||
if (
|
||||
in_array( $user->user_role_main, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
|
||||
) {
|
||||
$canSeeAll = true;
|
||||
if ($tenant->slug !== 'lv') {
|
||||
if (
|
||||
$user->user_role_main === UserRole::USER_ROLE_ADMIN ||
|
||||
in_array($user->user_role_local_group, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
|
||||
) {
|
||||
$canSeeAll = true;
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
in_array($user->user_role_main, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
|
||||
) {
|
||||
$canSeeAll = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,18 +27,22 @@ class EventRepository {
|
||||
$canSeeAll = false;
|
||||
$user = Auth()->user();
|
||||
|
||||
if ($tenant->slug !== 'lv') {
|
||||
if (
|
||||
$user->user_role_main === UserRole::USER_ROLE_ADMIN ||
|
||||
in_array( $user->user_role_local_group, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
|
||||
) {
|
||||
$canSeeAll = true;
|
||||
}
|
||||
if (!$accessCheck) {
|
||||
$canSeeAll = true;
|
||||
} else {
|
||||
if (
|
||||
in_array( $user->user_role_main, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
|
||||
) {
|
||||
$canSeeAll = true;
|
||||
if ($tenant->slug !== 'lv') {
|
||||
if (
|
||||
$user->user_role_main === UserRole::USER_ROLE_ADMIN ||
|
||||
in_array($user->user_role_local_group, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
|
||||
) {
|
||||
$canSeeAll = true;
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
in_array($user->user_role_main, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
|
||||
) {
|
||||
$canSeeAll = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user