Skip to content

Commit

Permalink
removed type and added created and updated status
Browse files Browse the repository at this point in the history
  • Loading branch information
supundulara committed Jun 27, 2024
1 parent 052adf6 commit 66dfb94
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 28 deletions.
3 changes: 2 additions & 1 deletion app/Domains/EventItem/Models/EventItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ class EventItem extends Model
protected $fillable = [
'title',
'description',
'type',
'image',
'enabled',
'link_url',
'link_caption',
'created_at',
'updated_at',
];

/**
Expand Down
2 changes: 0 additions & 2 deletions app/Http/Controllers/Backend/EventItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Livewire/Backend/EventItemTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class RemoveTypeFromEventItemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('event_items', function (Blueprint $table) {
$table->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');
});
}
}
10 changes: 1 addition & 9 deletions resources/views/backend/event/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,8 @@
</div>

<!-- Type -->
<div class="form-group row">
{!! Form::label('type', 'Type*', ['class' => 'col-md-2 col-form-label']) !!}

<div class="col-md-10">
{!! Form::select('type', $types, null, ['class' => 'form-control', 'required' => true, 'placeholder' => '']) !!}
@error('type')
<strong>{{ $message }}</strong>
@enderror
</div>
</div>


<!-- Description -->
<div class="form-group row">
Expand Down
13 changes: 0 additions & 13 deletions resources/views/backend/event/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,7 @@
</div>

<!-- Type -->
<div class="form-group row">
{!! Form::label('type', 'Type*', ['class' => 'col-md-2 col-form-label']) !!}

<div class="col-md-10">
{!! Form::select('type', $types, $eventItem->type, [
'class' => 'form-control',
'required' => true,
'placeholder' => '',
]) !!}
@error('type')
<strong>{{ $message }}</strong>
@enderror
</div>
</div>

<!-- Description -->
<div class="form-group row">
Expand Down
15 changes: 13 additions & 2 deletions resources/views/backend/event/index-table-row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@
</x-livewire-tables::table.cell>

<x-livewire-tables::table.cell>
{{ App\Domains\EventItem\Models\EventItem::types()[$row->type] }}
<div class="custom-width-1" style="width: 75px;">
{{ $row->created_at }}
</div>
</x-livewire-tables::table.cell>

<x-livewire-tables::table.cell>
@php
<div class="custom-width-1" style="width: 75px;">
{{ $row->updated_at }}
</div>
</x-livewire-tables::table.cell>

<x-livewire-tables::table.cell>
<div class="custom-width-2" style="width: 175px;">
@php
$words = explode(' ', $row->description);
$limitedDescription = implode(' ', array_slice($words, 0, 50));
$remainingWords = count($words) - 50;
@endphp
{!! $remainingWords > 0 ? $limitedDescription . '&nbsp;<a href="#" class="show-more" data-id="' . $row->id . '">Show more >>></a><span id="full-description-' . $row->id . '" style="display: none;">' . implode(' ', array_slice($words, 10)) . '</span><a href="#" class="show-less" data-id="' . $row->id . '" style="display: none;"> Show less <<<</a>' : $row->description !!}

</div>
</x-livewire-tables::table.cell>

<x-livewire-tables::table.cell>
Expand Down

0 comments on commit 66dfb94

Please sign in to comment.