From 3749c3653bc7cb81d7dfc69fa349f4771b326cae Mon Sep 17 00:00:00 2001 From: Benjamin Takats Date: Fri, 2 Dec 2022 22:57:22 +0100 Subject: [PATCH] lecturer description added --- app/Console/Kernel.php | 3 +- app/Http/Livewire/Tables/LecturerTable.php | 2 +- app/Models/Lecturer.php | 2 + app/Nova/Lecturer.php | 13 +- composer.json | 1 + composer.lock | 200 +++++++++++++++++- .../2022_12_02_162000_create_trix_tables.php | 46 ++++ ...d_description_field_to_lecturers_table.php | 30 +++ 8 files changed, 292 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2022_12_02_162000_create_trix_tables.php create mode 100644 database/migrations/2022_12_02_162124_add_description_field_to_lecturers_table.php diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index d8bc1d29..820a3a30 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -4,6 +4,7 @@ namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; +use Laravel\Nova\Trix\PruneStaleAttachments; class Kernel extends ConsoleKernel { @@ -15,7 +16,7 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - // $schedule->command('inspire')->hourly(); + $schedule->call(new PruneStaleAttachments)->daily(); } /** diff --git a/app/Http/Livewire/Tables/LecturerTable.php b/app/Http/Livewire/Tables/LecturerTable.php index 93418de0..f51b533d 100644 --- a/app/Http/Livewire/Tables/LecturerTable.php +++ b/app/Http/Livewire/Tables/LecturerTable.php @@ -45,7 +45,7 @@ class LecturerTable extends DataTableComponent ]), Column::make("Name", "name") ->sortable(), - BooleanColumn::make("Aktiv", "active") + BooleanColumn::make("Aktiv", 'active') ->sortable(), Column::make('Kurse') ->label( diff --git a/app/Models/Lecturer.php b/app/Models/Lecturer.php index 3b10ca2a..116d202b 100644 --- a/app/Models/Lecturer.php +++ b/app/Models/Lecturer.php @@ -49,6 +49,8 @@ class Lecturer extends Model implements HasMedia $this->addMediaCollection('avatar') ->singleFile() ->useFallbackUrl(asset('img/einundzwanzig-cover-lesestunde.png')); + $this->addMediaCollection('images') + ->useFallbackUrl(asset('img/einundzwanzig-cover-lesestunde.png')); } /** diff --git a/app/Nova/Lecturer.php b/app/Nova/Lecturer.php index fda9cff1..cee72b4b 100644 --- a/app/Nova/Lecturer.php +++ b/app/Nova/Lecturer.php @@ -8,6 +8,7 @@ use Laravel\Nova\Fields\BelongsTo; use Laravel\Nova\Fields\Boolean; use Laravel\Nova\Fields\Field; use Laravel\Nova\Fields\ID; +use Laravel\Nova\Fields\Markdown; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; @@ -56,8 +57,12 @@ class Lecturer extends Resource ID::make() ->sortable(), - Images::make('Avatar', 'avatar') // second parameter is the media collection name - ->conversionOnIndexView('thumb'), // conversion used to display the image + Images::make('Avatar', 'avatar') + ->conversionOnIndexView('thumb'), + + Images::make('Images', 'images') + ->conversionOnIndexView('thumb') + ->help('Lade hier Bilder hoch, um sie eventuell später in der Markdown Description einzufügen. Du musst vorher aber Speichern.'), Text::make('Name') ->rules('required', 'string'), @@ -70,6 +75,10 @@ class Lecturer extends Resource ->rules('required') ->default(true), + Markdown::make('Description') + ->alwaysShow() + ->help('Markdown ist erlaubt. Du kannst Bilder aus dem Feld "Images" hier einfügen. Benutze das Link Symbol der Bilder für die Urls, nach dem du auf "Aktualisieren und Weiterarbeiten" geklickt hast.'), + BelongsTo::make('Team'), ]; diff --git a/composer.json b/composer.json index 1edffaf1..f52fac9f 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "sentry/sentry-laravel": "^3.1", "simplesoftwareio/simple-qrcode": "^4.2", "spatie/laravel-google-fonts": "^1.2", + "spatie/laravel-markdown": "^2.2", "spatie/laravel-medialibrary": "^10.0.0", "spatie/laravel-sluggable": "^3.4", "staudenmeir/eloquent-has-many-deep": "^1.7", diff --git a/composer.lock b/composer.lock index 80cea129..0c2f4f21 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "ff5b859d3c6ae9f19b73878a2e055f42", + "content-hash": "568870ac3cd35dadcdbedcc3bd76c682", "packages": [ { "name": "akuechler/laravel-geoly", @@ -6204,6 +6204,66 @@ }, "time": "2022-08-12T19:00:25+00:00" }, + { + "name": "spatie/commonmark-shiki-highlighter", + "version": "2.1.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/commonmark-shiki-highlighter.git", + "reference": "52528a02f61d84030b313b5c7b0c4dd8edca7187" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/commonmark-shiki-highlighter/zipball/52528a02f61d84030b313b5c7b0c4dd8edca7187", + "reference": "52528a02f61d84030b313b5c7b0c4dd8edca7187", + "shasum": "" + }, + "require": { + "league/commonmark": "^2.0", + "php": "^8.0", + "spatie/shiki-php": "^1.1.1", + "symfony/process": "^5.3|^6.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.19", + "phpunit/phpunit": "^9.5", + "spatie/phpunit-snapshot-assertions": "^4.2.7", + "spatie/ray": "^1.28" + }, + "type": "commonmark-extension", + "autoload": { + "psr-4": { + "Spatie\\CommonMarkShikiHighlighter\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Highlight code blocks with league/commonmark and Shiki", + "homepage": "https://github.com/spatie/commonmark-shiki-highlighter", + "keywords": [ + "commonmark-shiki-highlighter", + "spatie" + ], + "support": { + "source": "https://github.com/spatie/commonmark-shiki-highlighter/tree/2.1.1" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-11-28T08:03:04+00:00" + }, { "name": "spatie/image", "version": "2.2.4", @@ -6406,6 +6466,81 @@ ], "time": "2022-09-07T10:01:34+00:00" }, + { + "name": "spatie/laravel-markdown", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-markdown.git", + "reference": "fbc1932b9513f4ee3ec83ac00537d92c188fc3cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-markdown/zipball/fbc1932b9513f4ee3ec83ac00537d92c188fc3cb", + "reference": "fbc1932b9513f4ee3ec83ac00537d92c188fc3cb", + "shasum": "" + }, + "require": { + "illuminate/cache": "^8.49|^9.0", + "illuminate/contracts": "^8.37|^9.0", + "illuminate/support": "^8.49|^9.0", + "illuminate/view": "^8.49|^9.0", + "league/commonmark": "^2.2", + "php": "^8.0", + "spatie/commonmark-shiki-highlighter": "^2.0", + "spatie/laravel-package-tools": "^1.4.3" + }, + "require-dev": { + "brianium/paratest": "^6.2", + "nunomaduro/collision": "^5.3|^6.0", + "orchestra/testbench": "^6.15|^7.0", + "phpunit/phpunit": "^9.3", + "spatie/laravel-ray": "^1.23", + "spatie/phpunit-snapshot-assertions": "^4.2", + "vimeo/psalm": "^4.8" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\LaravelMarkdown\\MarkdownServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Spatie\\LaravelMarkdown\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "A highly configurable markdown renderer and Blade component for Laravel", + "homepage": "https://github.com/spatie/laravel-markdown", + "keywords": [ + "Laravel-Markdown", + "laravel", + "spatie" + ], + "support": { + "source": "https://github.com/spatie/laravel-markdown/tree/2.2.4" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-05-21T11:53:53+00:00" + }, { "name": "spatie/laravel-medialibrary", "version": "10.7.3", @@ -6778,6 +6913,69 @@ ], "time": "2022-04-21T12:23:20+00:00" }, + { + "name": "spatie/shiki-php", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/shiki-php.git", + "reference": "34fe61405b405c735c82a9c56feffd3f7c5544ff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/shiki-php/zipball/34fe61405b405c735c82a9c56feffd3f7c5544ff", + "reference": "34fe61405b405c735c82a9c56feffd3f7c5544ff", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^v3.0", + "pestphp/pest": "^1.8", + "phpunit/phpunit": "^9.5", + "spatie/pest-plugin-snapshots": "^1.1", + "spatie/ray": "^1.10" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\ShikiPhp\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rias Van der Veken", + "email": "rias@spatie.be", + "role": "Developer" + }, + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Highlight code using Shiki in PHP", + "homepage": "https://github.com/spatie/shiki-php", + "keywords": [ + "shiki", + "spatie" + ], + "support": { + "source": "https://github.com/spatie/shiki-php/tree/1.3.0" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-06-01T11:28:41+00:00" + }, { "name": "spatie/temporary-directory", "version": "2.1.1", diff --git a/database/migrations/2022_12_02_162000_create_trix_tables.php b/database/migrations/2022_12_02_162000_create_trix_tables.php new file mode 100644 index 00000000..cd44feb7 --- /dev/null +++ b/database/migrations/2022_12_02_162000_create_trix_tables.php @@ -0,0 +1,46 @@ +increments('id'); + $table->string('draft_id') + ->index(); + $table->string('attachment'); + $table->string('disk'); + $table->timestamps(); + }); + + Schema::create('nova_trix_attachments', function (Blueprint $table) { + $table->increments('id'); + $table->string('attachable_type'); + $table->unsignedInteger('attachable_id'); + $table->string('attachment'); + $table->string('disk'); + $table->string('url') + ->index(); + $table->timestamps(); + + $table->index(['attachable_type', 'attachable_id']); + }); + + } + + /** + * Reverse the migrations. + * @return void + */ + public function down() + { + // + } +}; diff --git a/database/migrations/2022_12_02_162124_add_description_field_to_lecturers_table.php b/database/migrations/2022_12_02_162124_add_description_field_to_lecturers_table.php new file mode 100644 index 00000000..08c08eae --- /dev/null +++ b/database/migrations/2022_12_02_162124_add_description_field_to_lecturers_table.php @@ -0,0 +1,30 @@ +longText('description') + ->nullable(); + }); + } + + /** + * Reverse the migrations. + * @return void + */ + public function down() + { + Schema::table('lecturers', function (Blueprint $table) { + // + }); + } +};