From: Louis Date: Fri, 3 Apr 2020 16:42:26 +0000 (+0200) Subject: models & migrations v1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=efb46f015e72f6881469156d36e065a2efa45c3b;p=psq.git models & migrations v1 --- diff --git a/app/BelongsToPdfFile.php b/app/BelongsToPdfFile.php new file mode 100644 index 0000000..3d47fd3 --- /dev/null +++ b/app/BelongsToPdfFile.php @@ -0,0 +1,22 @@ +belongsTo(PdfFile::class, 'file_id'); + } + +} diff --git a/app/EmailBatch.php b/app/EmailBatch.php new file mode 100644 index 0000000..64ce5ad --- /dev/null +++ b/app/EmailBatch.php @@ -0,0 +1,25 @@ + 'array', + 'sent_to' => 'array' + ]; + + +} diff --git a/app/Http/Controllers/Admin/OrganizationController.php b/app/Http/Controllers/Admin/OrganizationController.php deleted file mode 100644 index 1223539..0000000 --- a/app/Http/Controllers/Admin/OrganizationController.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - 'title' => 'Nom', - 'field' => 'name', - ], - 'subscription_active' => [ - 'title' => 'Abonnement actif', - 'field' => 'subscription_active' - ] - ]; - - - protected $defaultOrders = ['created_at' => 'desc']; - -} diff --git a/app/Http/Requests/Admin/OrganizationRequest.php b/app/Http/Requests/Admin/OrganizationRequest.php deleted file mode 100644 index d5f1d4a..0000000 --- a/app/Http/Requests/Admin/OrganizationRequest.php +++ /dev/null @@ -1,18 +0,0 @@ - 'boolean', - ]; - -} diff --git a/app/Models/Slugs/OrganizationSlug.php b/app/Models/Slugs/OrganizationSlug.php deleted file mode 100644 index 5cd1507..0000000 --- a/app/Models/Slugs/OrganizationSlug.php +++ /dev/null @@ -1,10 +0,0 @@ - 'boolean' + ]; + + + /** + * @return boolean + */ + public function isSubscribed(): bool + { + return $this->subscription_active; + } + + /** + * @param Builder $builder + * @return Builder + */ + public function scopeSubscribed(Builder $builder): Builder + { + return $builder->where('subscription_active', 1); + } + + /** + * @return HasMany + */ + public function members(): HasMany + { + return $this->hasMany(User::class); + } + +} diff --git a/app/PdfFile.php b/app/PdfFile.php new file mode 100644 index 0000000..9811ef4 --- /dev/null +++ b/app/PdfFile.php @@ -0,0 +1,44 @@ +hasMany(SearchableText::class, 'file_id'); + } + + /** + * @return HasOne + */ + public function emailBatch(): HasOne + { + return $this->hasOne(EmailBatch::class, 'file_id'); + } + + /** + * @return HasMany + */ + public function trackedLinks(): HasMany + { + return $this->hasMany(TrackedLink::class, 'file_id'); + } +} + + diff --git a/app/SearchableText.php b/app/SearchableText.php new file mode 100644 index 0000000..7496321 --- /dev/null +++ b/app/SearchableText.php @@ -0,0 +1,10 @@ + 'datetime', ]; + + + /** + * @return BelongsTo + */ + public function organization(): BelongsTo + { + return $this->belongsTo(Organization::class); + } + + } diff --git a/database/migrations/2020_04_03_132717_create_organizations_tables.php b/database/migrations/2020_04_03_132717_create_organizations_tables.php deleted file mode 100644 index f204dab..0000000 --- a/database/migrations/2020_04_03_132717_create_organizations_tables.php +++ /dev/null @@ -1,40 +0,0 @@ -string('name', 200); - - // your generated model and form include a description field, to get you started, but feel free to get rid of it if you don't need it - $table->text('description')->nullable(); - - $table->boolean('subscription_active'); - - // add those 2 columns to enable publication timeframe fields (you can use publish_start_date only if you don't need to provide the ability to specify an end date) - // $table->timestamp('publish_start_date')->nullable(); - // $table->timestamp('publish_end_date')->nullable(); - }); - - Schema::create('organization_slugs', function (Blueprint $table) { - createDefaultSlugsTableFields($table, 'organization'); - }); - - - } - - public function down() - { - - Schema::dropIfExists('organization_slugs'); - Schema::dropIfExists('organizations'); - } -} diff --git a/database/migrations/2020_04_03_154715_create_organizations_table.php b/database/migrations/2020_04_03_154715_create_organizations_table.php new file mode 100644 index 0000000..92fe86a --- /dev/null +++ b/database/migrations/2020_04_03_154715_create_organizations_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('name'); + $table->boolean('subscription_active'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('organizations'); + } +} diff --git a/database/migrations/2020_04_03_154810_create_flow_paper_files_table.php b/database/migrations/2020_04_03_154810_create_flow_paper_files_table.php new file mode 100644 index 0000000..ddf64b1 --- /dev/null +++ b/database/migrations/2020_04_03_154810_create_flow_paper_files_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('slug')->unique(); + $table->string('title'); + $table->string('file_name'); + $table->json('tags'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('pdf_files'); + } +} diff --git a/database/migrations/2020_04_03_154911_create_searchable_texts_table.php b/database/migrations/2020_04_03_154911_create_searchable_texts_table.php new file mode 100644 index 0000000..531dde7 --- /dev/null +++ b/database/migrations/2020_04_03_154911_create_searchable_texts_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('file_id'); + $table->text('content'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('searchable_texts'); + } +} diff --git a/database/migrations/2020_04_03_154939_create_email_batches_table.php b/database/migrations/2020_04_03_154939_create_email_batches_table.php new file mode 100644 index 0000000..7def44a --- /dev/null +++ b/database/migrations/2020_04_03_154939_create_email_batches_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('subject'); + $table->json('content'); + $table->unsignedBigInteger('file_id'); + $table->json('sent_to'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('email_batches'); + } +} diff --git a/database/migrations/2020_04_03_155151_create_tracked_links_table.php b/database/migrations/2020_04_03_155151_create_tracked_links_table.php new file mode 100644 index 0000000..fbbb79c --- /dev/null +++ b/database/migrations/2020_04_03_155151_create_tracked_links_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('slug'); + $table->text('target'); + $table->unsignedBigInteger('file_id')->nullable(); + $table->unsignedBigInteger('clicks')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tracked_links'); + } +} diff --git a/database/migrations/2020_04_03_162854_add_columns_to_users_table.php b/database/migrations/2020_04_03_162854_add_columns_to_users_table.php new file mode 100644 index 0000000..ac3ff1d --- /dev/null +++ b/database/migrations/2020_04_03_162854_add_columns_to_users_table.php @@ -0,0 +1,33 @@ +unsignedBigInteger('organization_id')->nullable(); + $table->unsignedInteger('credits')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + // + }); + } +} diff --git a/resources/views/admin/organizations/form.blade.php b/resources/views/admin/organizations/form.blade.php deleted file mode 100644 index 4eb6835..0000000 --- a/resources/views/admin/organizations/form.blade.php +++ /dev/null @@ -1,28 +0,0 @@ -@extends('twill::layouts.form') - -@section('contentFields') - - @formField('input', [ - 'name' => 'name', - 'label' => 'Nom', - 'maxlength' => 100 - ]) - - @formField('radios', [ - 'name' => 'subscription_active', - 'label' => 'Abonnement actif', - 'default' => '1', - 'inline' => true, - 'options' => [ - [ - 'value' => '0', - 'label' => 'Non' - ], - [ - 'value' => '1', - 'label' => 'Oui' - ], - - ] - ]) -@stop diff --git a/routes/admin.php b/routes/admin.php index ba7b53e..42d66a8 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -2,4 +2,3 @@ Route::module('users'); -Route::module('organizations');