From 66dfb94436c166e4e80e2029e7e6d06defb58a58 Mon Sep 17 00:00:00 2001 From: Supun Dulara Date: Thu, 27 Jun 2024 19:05:55 +0530 Subject: [PATCH] removed type and added created and updated status --- app/Domains/EventItem/Models/EventItem.php | 3 +- .../Backend/EventItemController.php | 2 -- app/Http/Livewire/Backend/EventItemTable.php | 4 ++- ...827_remove_type_from_event_items_table.php | 32 +++++++++++++++++++ .../views/backend/event/create.blade.php | 10 +----- resources/views/backend/event/edit.blade.php | 13 -------- .../backend/event/index-table-row.blade.php | 15 +++++++-- 7 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 database/migrations/2024_06_27_173827_remove_type_from_event_items_table.php diff --git a/app/Domains/EventItem/Models/EventItem.php b/app/Domains/EventItem/Models/EventItem.php index 689f74b..b071c53 100644 --- a/app/Domains/EventItem/Models/EventItem.php +++ b/app/Domains/EventItem/Models/EventItem.php @@ -27,11 +27,12 @@ class EventItem extends Model protected $fillable = [ 'title', 'description', - 'type', 'image', 'enabled', 'link_url', 'link_caption', + 'created_at', + 'updated_at', ]; /** diff --git a/app/Http/Controllers/Backend/EventItemController.php b/app/Http/Controllers/Backend/EventItemController.php index 927691f..e987521 100644 --- a/app/Http/Controllers/Backend/EventItemController.php +++ b/app/Http/Controllers/Backend/EventItemController.php @@ -30,7 +30,6 @@ public function store(Request $request) { $data = request()->validate([ 'title' => ['required'], - 'type' => ['required', Rule::in(array_keys(EventItem::types()))], 'description' => 'string|required', 'enabled' => 'nullable', 'link_url' => 'string', @@ -74,7 +73,6 @@ public function update(Request $request, EventItem $eventItem) { $data = request()->validate([ 'title' => ['required'], - 'type' => ['required', Rule::in(array_keys(EventItem::types()))], 'description' => 'string|required', 'enabled' => 'nullable', 'link_url' => 'string', diff --git a/app/Http/Livewire/Backend/EventItemTable.php b/app/Http/Livewire/Backend/EventItemTable.php index 8fee89c..d944e38 100644 --- a/app/Http/Livewire/Backend/EventItemTable.php +++ b/app/Http/Livewire/Backend/EventItemTable.php @@ -19,7 +19,9 @@ public function columns(): array return [ Column::make("Title", "title") ->sortable(), - Column::make("Type", "type") + Column::make("Created At", "created_at") + ->sortable(), + Column::make("Updated At", "updated_at") ->sortable(), Column::make("Description", "description") ->searchable(), diff --git a/database/migrations/2024_06_27_173827_remove_type_from_event_items_table.php b/database/migrations/2024_06_27_173827_remove_type_from_event_items_table.php new file mode 100644 index 0000000..53273ac --- /dev/null +++ b/database/migrations/2024_06_27_173827_remove_type_from_event_items_table.php @@ -0,0 +1,32 @@ +dropColumn('type'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('event_items', function (Blueprint $table) { + $table->enum('type', ['info', 'danger', 'warning', 'success'])->default('info'); + }); + } +} diff --git a/resources/views/backend/event/create.blade.php b/resources/views/backend/event/create.blade.php index cb6a583..1f743dc 100644 --- a/resources/views/backend/event/create.blade.php +++ b/resources/views/backend/event/create.blade.php @@ -31,16 +31,8 @@ -
- {!! Form::label('type', 'Type*', ['class' => 'col-md-2 col-form-label']) !!} -
- {!! Form::select('type', $types, null, ['class' => 'form-control', 'required' => true, 'placeholder' => '']) !!} - @error('type') - {{ $message }} - @enderror -
-
+
diff --git a/resources/views/backend/event/edit.blade.php b/resources/views/backend/event/edit.blade.php index d06ade5..699c0ac 100644 --- a/resources/views/backend/event/edit.blade.php +++ b/resources/views/backend/event/edit.blade.php @@ -34,20 +34,7 @@
-
- {!! Form::label('type', 'Type*', ['class' => 'col-md-2 col-form-label']) !!} -
- {!! Form::select('type', $types, $eventItem->type, [ - 'class' => 'form-control', - 'required' => true, - 'placeholder' => '', - ]) !!} - @error('type') - {{ $message }} - @enderror -
-
diff --git a/resources/views/backend/event/index-table-row.blade.php b/resources/views/backend/event/index-table-row.blade.php index 0e84fca..f9c98ee 100644 --- a/resources/views/backend/event/index-table-row.blade.php +++ b/resources/views/backend/event/index-table-row.blade.php @@ -3,16 +3,27 @@ - {{ App\Domains\EventItem\Models\EventItem::types()[$row->type] }} +
+ {{ $row->created_at }} +
- @php +
+ {{ $row->updated_at }} +
+
+ + +
+ @php $words = explode(' ', $row->description); $limitedDescription = implode(' ', array_slice($words, 0, 50)); $remainingWords = count($words) - 50; @endphp {!! $remainingWords > 0 ? $limitedDescription . ' Show more >>>' : $row->description !!} + +