Merge branch 'develop' into trunk
This commit is contained in:
commit
0121ee8bdb
12 changed files with 108 additions and 31 deletions
|
|
@ -26,7 +26,7 @@ class AsInput implements CastsAttributes
|
|||
// phpcs:enable
|
||||
/** @var array<string, integer|string|boolean> $inputData */
|
||||
$inputData = \json_decode($value, true);
|
||||
$inputClass = InputTypeEnum::make($inputData['type'])->inputTypes();
|
||||
$inputClass = InputTypeEnum::make($inputData['type'])->getInputClass();
|
||||
return $inputClass::from(InputData::make(...\array_values($inputData)), $inputData['required'] ?? false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ enum InputTypeEnum: int
|
|||
];
|
||||
|
||||
/**
|
||||
* Get translation key.
|
||||
* Get InputType class based on the enum value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function inputTypes(): string
|
||||
public function getInputClass(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::text => InputText::class,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class AppController extends Controller
|
|||
$response = [];
|
||||
$settings = Setting::query()
|
||||
->where('tenant_id', $tenantKey)
|
||||
->where('key', 'Button1')
|
||||
->orWhere('key', 'Button1')
|
||||
->orWhere('key', 'Button2')
|
||||
->orWhere('key', 'Button3')
|
||||
->get();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace App\Http\Controllers\API;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Api\Contacts\DestroyContactsRequest;
|
||||
use App\Http\Requests\Api\Contacts\UpsertContactsRequest;
|
||||
use App\Http\Resources\ApiResponseResource;
|
||||
use App\Http\Resources\AppUserResource;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use App\Http\Resources\DirectoryResource;
|
||||
|
|
@ -32,14 +31,13 @@ use Illuminate\Support\Facades\URL;
|
|||
class SyncController extends Controller
|
||||
{
|
||||
/**
|
||||
* @return \App\Http\Resources\ApiResponseResource
|
||||
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
*/
|
||||
public function getUsers(): \App\Http\Resources\ApiResponseResource
|
||||
public function getUsers(): \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
||||
{
|
||||
$users = AppUserResource::collection(
|
||||
return AppUserResource::collection(
|
||||
AppUser::query()->where('tenant_id', \tenant()->getKey())->where('status', 1)->get()
|
||||
)->toArray(request());
|
||||
return new ApiResponseResource("OK", $users);
|
||||
);
|
||||
}
|
||||
|
||||
// *** --- START CONTACTS ---
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Enums\Formularies\InputTypeEnum;
|
|||
use App\Lib\Inputs\Definition\InputData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class UpsertContactsRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -68,10 +69,7 @@ class UpsertContactsRequest extends FormRequest
|
|||
'contacts.*.data.*' => 'array',
|
||||
'contacts.*.data.*.title' => 'present|string|min:1|max:255',
|
||||
'contacts.*.data.*.formSlug' => 'present|string|min:1|max:255',
|
||||
'contacts.*.data.*.type' => 'present|in:' . implode(
|
||||
',',
|
||||
array_column(InputTypeEnum::cases(), 'name')
|
||||
),
|
||||
'contacts.*.data.*.type' => ['present', new Enum(InputTypeEnum::class)],
|
||||
'contacts.*.data.*.value' => 'present',
|
||||
'contacts.*.data.*.required' => 'present|boolean',
|
||||
'contacts.*.data.*.send_to_app_user_id' => 'nullable|numeric',
|
||||
|
|
@ -108,10 +106,15 @@ class UpsertContactsRequest extends FormRequest
|
|||
'error' => "wrong formSlug on data index '{$index}'"
|
||||
]);
|
||||
}
|
||||
$type = InputTypeEnum::make($data->get('type') ? $data->get('type') : null, 'name');
|
||||
$type = InputTypeEnum::make($data->get('type') ? $data->get('type') : null);
|
||||
if (\is_null($type)) {
|
||||
throw ValidationException::withMessages([
|
||||
'error' => "wrong inputType on data index '{$index}'"
|
||||
]);
|
||||
}
|
||||
$value = $data['value'] ?? null;
|
||||
$required = $data->get('required') ? true : false;
|
||||
$inputClass = $type->inputTypes();
|
||||
$inputClass = $type->getInputClass();
|
||||
return $inputClass::from(InputData::make(
|
||||
$title,
|
||||
$formSlug,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class DocumentResource extends JsonResource
|
|||
'type' => $document->type,
|
||||
'directory' => $document->directory_id,
|
||||
'path' => $document->path,
|
||||
'lang' => $document->lang->value,
|
||||
'lang' => $document->lang->name,
|
||||
'published' => ($document->status) ? 1 : 0,
|
||||
'parent' => $document->document_id,
|
||||
'created_at' => $document->created_at,
|
||||
|
|
|
|||
|
|
@ -146,6 +146,30 @@ class Directory extends Model
|
|||
return Directory::renderDirectories($directoriesFiltered);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default settings for a specific tenant.
|
||||
*
|
||||
* @param \App\Models\Tenant $tenant
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultDirectories(Tenant $tenant): void
|
||||
{
|
||||
// Default locked salon directory.
|
||||
$directory = new self();
|
||||
$directory->name = [
|
||||
"fr" => "Salon",
|
||||
"en" => "Salon",
|
||||
"de" => "Wohnzimmer",
|
||||
"nl" => "Tentoonstelling",
|
||||
];
|
||||
$directory->directory_id = null;
|
||||
$directory->needAuthorization = (bool)0;
|
||||
$directory->is_system = (bool)1;
|
||||
$directory->order = 1;
|
||||
$directory->tenant_id = $tenant->getKey();
|
||||
$directory->saveOrFail();
|
||||
}
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class Tenant extends BaseTenant implements TenantContract
|
|||
static::created(function (self $model) {
|
||||
(new Setting())->setDefaultSettings($model);
|
||||
(new Formulary())->setDefaultFormularies($model);
|
||||
(new Directory())->setDefaultDirectories($model);
|
||||
self::resetCache();
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
"stancl/tenancy": "^3.9",
|
||||
"usmanhalalit/laracsv": "^2.0",
|
||||
"uwil/admin-secure-laravel": "^4.0",
|
||||
"uwil/k8s-laravel": "^2.0",
|
||||
"uwil/laravel-common": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
|
|
|
|||
63
composer.lock
generated
63
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "bd1a3f6788044c02043bfc2d090ab189",
|
||||
"content-hash": "0eb882c623bc540ee0defb89f0fb2380",
|
||||
"packages": [
|
||||
{
|
||||
"name": "24slides/laravel-saml2",
|
||||
|
|
@ -8641,6 +8641,67 @@
|
|||
"issues": "https://lab.s-web.fr/ldc-web/projets/ldc-web-admin-secure-laravel/-/issues"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "uwil/k8s-laravel",
|
||||
"version": "2.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git@lab.s-web.fr:ldc-web/projets/k8s-laravel.git",
|
||||
"reference": "050fb59ac50ed676661cca2a44050f116ef996fb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://lab.s-web.fr/api/v4/projects/90/packages/composer/archives/uwil/k8s-laravel.zip?sha=050fb59ac50ed676661cca2a44050f116ef996fb",
|
||||
"reference": "050fb59ac50ed676661cca2a44050f116ef996fb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "~8|~9|~10|~11|~12",
|
||||
"laravel/framework": "~8|~9|~10|~11|~12",
|
||||
"php": "~7.3|~7.4|~8"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^8.5",
|
||||
"phpunit/php-code-coverage": "^9.2",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"slevomat/coding-standard": "^8.3",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Uwil\\K8S\\Laravel\\K8SServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Uwil\\K8S\\Laravel\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Uwil\\K8S\\Laravel\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"vendor/bin/phpunit"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"@php ./vendor/bin/testbench package:discover --ansi"
|
||||
]
|
||||
},
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Laravel requirements for k8s",
|
||||
"support": {
|
||||
"email": "equipe.web@ldc.fr",
|
||||
"issues": "https://lab.s-web.fr/ldc-web/projets/k8s-laravel/-/issues"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "uwil/laravel-common",
|
||||
"version": "3.1.2",
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ return [
|
|||
* Package Service Providers...
|
||||
*/
|
||||
|
||||
Uwil\K8S\Laravel\K8SServiceProvider::class,
|
||||
Maatwebsite\Excel\ExcelServiceProvider::class,
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -17,19 +17,7 @@ class DirectorySeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$directory = new Directory();
|
||||
$directory->name = [
|
||||
"fr" => "Salon",
|
||||
"en" => "Salon",
|
||||
"de" => "Wohnzimmer",
|
||||
"nl" => "Tentoonstelling",
|
||||
];
|
||||
$directory->directory_id = null;
|
||||
$directory->needAuthorization = 0;
|
||||
$directory->is_system = 1;
|
||||
$directory->order = 1;
|
||||
$directory->tenant_id = Tenant::query()->first()->getKey();
|
||||
$directory->saveOrFail();
|
||||
// Default "Salon" directory is created in the Tenant model.
|
||||
|
||||
Directory::factory(14)->create();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue