Skip to content

Commit

Permalink
Merge branch '15-co200-manage-news-items' of https://github.com/cepdn…
Browse files Browse the repository at this point in the history
…aclk/portal.ce.pdn.ac.lk into 15-co200-manage-news-items
  • Loading branch information
kusaljayawardhana committed Jul 13, 2024
2 parents 30523bf + d235ddb commit 110ecaf
Show file tree
Hide file tree
Showing 17 changed files with 276 additions and 170 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP_NAME="Portal"
APP_NAME="Laravel Boilerplate"
APP_ENV=local
APP_KEY=base64:7n3hC3NTb86r+X7P0KRCIQ5HRCeGL8AJ/XFMSBVko/k=
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

Expand Down Expand Up @@ -29,7 +29,7 @@ SESSION_LIFETIME=120
# Database
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ceportal
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

Expand Down
3 changes: 3 additions & 0 deletions app/Domains/Event/Models/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class Event extends Model
'enabled',
'link_url',
'link_caption',
'start_at',
'end_at',
'location',
'created_at',
'updated_at',
];
Expand Down
16 changes: 11 additions & 5 deletions app/Http/Controllers/Backend/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public function store(Request $request)
'title' => ['required'],
'description' => 'string|required',
'enabled' => 'nullable',
'link_url' => 'string',
'link_caption' => 'string',
'link_url' => 'nullable|url',
'link_caption' => 'nullable|string',
'start_at' => 'date_format:Y-m-d H:i',
'end_at' => 'nullable|date_format:Y-m-d H:i',
'location' => 'string',
]);
if ($request->hasFile('image')) {
$data['image'] = $request->file('image')->store('EventImages', 'public');
Expand All @@ -47,7 +50,7 @@ public function store(Request $request)

return redirect()->route('dashboard.event.index', $event)->with('Success', 'Event Item was created !');
} catch (\Exception $ex) {
\Log::error($ex->getMessage());
\Log::error($ex->getMessage());
return abort(500);
}
}
Expand Down Expand Up @@ -76,8 +79,11 @@ public function update(Request $request, Event $event)
'title' => ['required'],
'description' => 'string|required',
'enabled' => 'nullable',
'link_url' => 'string',
'link_caption' => 'string',
'link_url' => 'nullable|url',
'link_caption' => 'nullable|string',
'start_at' => 'date_format:Y-m-d H:i',
'end_at' => 'nullable|date_format:Y-m-d H:i',
'location' => 'string',
]);
if ($request->hasFile('image')) {
$data['image'] = $request->file('image')->store('EventImages', 'public');
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/Backend/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function store(Request $request)
'title' => ['required'],
'description' => 'string|required',
'enabled' => 'nullable',
'link_url' => 'string',
'link_caption' => 'string',
'link_url' => 'nullable|url',
'link_caption' => 'nullable|string',
]);
if ($request->hasFile('image')) {
$data['image'] = $request->file('image')->store('NewsImages', 'public');
Expand Down Expand Up @@ -76,8 +76,8 @@ public function update(Request $request, News $news)
'title' => ['required'],
'description' => 'string|required',
'enabled' => 'nullable',
'link_url' => 'string',
'link_caption' => 'string',
'link_url' => 'nullable|url',
'link_caption' => 'nullable|string',
]);
if ($request->hasFile('image')) {
$data['image'] = $request->file('image')->store('NewsImages', 'public');
Expand Down
22 changes: 14 additions & 8 deletions app/Http/Livewire/Backend/EventsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ public function columns(): array
{
return [
Column::make("Title", "title")
->sortable(),
->sortable()
->searchable(),
Column::make("Image", "image"),
Column::make("Author", "author")
->searchable(),
Column::make('Link Caption'),
Column::make("Enabled", "enabled")
->searchable(),
Column::make("Start Time", "start_at")
->searchable(),
Column::make("End Time", "end_at")
->searchable(),
Column::make("Location", "location")
->searchable(),
Column::make("Created At", "created_at")
->sortable(),
Column::make("Updated At", "updated_at")
->sortable(),
Column::make("Description", "description")
->searchable(),
Column::make("Image", "image"),
Column::make("Enabled", "enabled")
->searchable(),
Column::make("Link URL", "link_url"),
Column::make("Link Caption", "link_caption"),
Column::make("Actions")
];
}
Expand Down
16 changes: 7 additions & 9 deletions app/Http/Livewire/Backend/NewsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ public function columns(): array
{
return [
Column::make("Title", "title")
->sortable(),
Column::make("Created At", "created_at")
->sortable(),
Column::make("Updated At", "updated_at")
->sortable(),
Column::make("Description", "description")
->searchable(),
->sortable()
->searchable(),
Column::make("Image", "image"),
Column::make("Author", "author")
->searchable(),
Column::make("Link URL", "link_url"),
Column::make("Link Caption", "link_caption"),
Column::make('Link Caption'),
Column::make("Enabled", "enabled")
->searchable(),
Column::make("Created At", "created_at")
->sortable(),
Column::make("Updated At", "updated_at")
->sortable(),
Column::make("Actions")
];
}
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/2024_06_22_200003_create_news_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function up()
$table->text('description');
$table->string('image')->nullable();
$table->string('author');
$table->string('link_url');
$table->string('link_caption');
$table->string('link_url')->nullable();
$table->string('link_caption')->nullable();
$table->boolean('enabled')->default(true);
$table->timestamps();
});
Expand Down
7 changes: 5 additions & 2 deletions database/migrations/2024_06_27_150621_create_events_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public function up()
$table->text('description');
$table->string('image')->nullable();
$table->string('author');
$table->string('link_url');
$table->string('link_caption');
$table->string('link_url')->nullable();
$table->string('link_caption')->nullable();
$table->dateTime('start_at');
$table->dateTime('end_at')->nullable();
$table->string('location');
$table->boolean('enabled')->default(true);
$table->timestamps();
});
Expand Down
20 changes: 10 additions & 10 deletions database/seeders/NewsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ public function run()
'news',
]);
// Create some sample news items
$newss = [
[
'title' => 'Eius quia blanditiis architecto exercitationem.',
'description' => 'Nostrum qui qui ut deserunt dolores quaerat. Est quos sed ea quo placeat maxime. Sequi temporibus alias atque assumenda facere modi deleniti. Recusandae autem quia officia iste laudantium veritatis aut.',
'image' => 'sample-image.jpg',
'author' => 'Dr. Anna Murazik',
'link_url' => 'https:\/\/www.murazik.org\/aut-et-quibusdam-molestias-consectetur-consequatur',
'link_caption' => 'fugiat accusantium sit',
],
$news = [
// [
// 'title' => 'Eius quia blanditiis architecto exercitationem.',
// 'description' => 'Nostrum qui qui ut deserunt dolores quaerat. Est quos sed ea quo placeat maxime. Sequi temporibus alias atque assumenda facere modi deleniti. Recusandae autem quia officia iste laudantium veritatis aut.',
// 'image' => 'sample-image.jpg',
// 'author' => 'Dr. Anna Murazik',
// 'link_url' => 'https:\/\/www.murazik.org\/aut-et-quibusdam-molestias-consectetur-consequatur',
// 'link_caption' => 'fugiat accusantium sit',
// ],

// Add more news items as needed
];

foreach ($newss as $item) {
foreach ($news as $item) {
News::create($item);
}

Expand Down
60 changes: 55 additions & 5 deletions resources/views/backend/event/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
{!! Form::label('description', 'Description*', ['class' => 'col-md-2 col-form-label']) !!}

<div class="col-md-10">
{!! Form::textarea('description', '', ['class' => 'form-control', 'rows' => 3, 'required' => true]) !!}
<div id="editor-container" style="height: auto;"></div>
<textarea name="description" id="description" style="display:none;"></textarea>
@error('description')
<strong>{{ $message }}</strong>
@enderror
Expand All @@ -51,7 +52,7 @@
{!! Form::label('image', 'Image*', ['class' => 'col-md-2 col-form-label']) !!}

<div class="col-md-10">
{!! Form::file('image', ['class' => 'form-control', 'required' => true]) !!}
{!! Form::file('image', ['class' => 'form-control']) !!}
@error('image')
<strong>{{ $message }}</strong>
@enderror
Expand All @@ -75,7 +76,7 @@
{!! Form::label('link_url', 'Link URL*', ['class' => 'col-md-2 col-form-label']) !!}

<div class="col-md-10">
{!! Form::text('link_url', '', ['class' => 'form-control', 'required' => true]) !!}
{!! Form::text('link_url', '', ['class' => 'form-control']) !!}
@error('link_url')
<strong>{{ $message }}</strong>
@enderror
Expand All @@ -87,17 +88,66 @@
{!! Form::label('link_caption', 'Link Caption*', ['class' => 'col-md-2 col-form-label']) !!}

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

<!-- start at -->
<div class="form-group row">
{!! Form::label('start_at', 'Start At*', ['class' => 'col-md-2 col-form-label']) !!}
<div class="col-md-3">
{!! Form::text('start_at', '', ['class' => 'form-control', 'id' => 'start_at', 'required' => true]) !!}
@error('start_at')
<strong>{{ $message }}</strong>
@enderror
</div>
</div>

<!-- end at -->
<div class="form-group row">
{!! Form::label('end_at', 'End At*', ['class' => 'col-md-2 col-form-label']) !!}
<div class="col-md-3">
{!! Form::text('end_at', '', ['class' => 'form-control', 'id' => 'end_at']) !!}
@error('end_at')
<strong>{{ $message }}</strong>
@enderror
</div>
</div>

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

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

<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script>
// Initialize flatpickr on the input field
flatpickr("#start_at", {
altInput: true,
enableTime: true, // Enable time selection
dateFormat: "Y-m-d H:i", // Set the date and time format
});
flatpickr("#end_at", {
altInput: true,
enableTime: true, // Enable time selection
dateFormat: "Y-m-d H:i", // Set the date and time format
});
</script>

</x-slot>

<x-slot name="footer">
{!! Form::submit('Create', ['class' => 'btn btn-primary float-right']) !!}
{!! Form::submit('Create', ['class' => 'btn btn-primary float-right', 'id' => 'submit-button']) !!}
</x-slot>

</x-backend.card>
Expand Down
61 changes: 54 additions & 7 deletions resources/views/backend/event/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@
{!! Form::label('description', 'Description*', ['class' => 'col-md-2 col-form-label']) !!}

<div class="col-md-10">
{!! Form::textarea('description', $event->description, [
'class' => 'form-control',
'rows' => 3,
'required' => true,
]) !!}
<div id="editor-container" style="height: auto;">{!! $event->description !!}</div>
<textarea name="description" id="description" style="display:none;"></textarea>
@error('description')
<strong>{{ $message }}</strong>
@enderror
Expand All @@ -63,7 +60,7 @@
@enderror

<!-- Image preview -->
<img class="mt-3" src="{{ $event->image ? asset('storage/' . $event->image) : asset('Events/no-image.png') }}" alt="Image preview" style="max-width: 150px; max-height: 150px;" />
<img class="mt-3" src="{{ $event->image ? asset('storage/' . $event->image) : asset('Events/no-image.png') }}" alt="Image preview" style="max-width: 150px; max-height: 150px;" />
</div>
</div>

Expand Down Expand Up @@ -110,9 +107,59 @@
</div>
</div>

<!-- start time -->
<div class="form-group row">
{!! Form::label('start_at', 'Start Time*', ['class' => 'col-md-2 col-form-label']) !!}
<div class="col-md-10">
{!! Form::text('start_at', $event->start_at, [
'class' => 'form-control', 'id' => 'start_at', 'required' => true]) !!}
@error('start_at')
<strong>{{ $message }}</strong>
@enderror
</div>
</div>

<!-- end time -->
<div class="form-group row">
{!! Form::label('end_at', 'End Time*', ['class' => 'col-md-2 col-form-label']) !!}
<div class="col-md-10">
{!! Form::text('end_at', $event->end_at, [
'class' => 'form-control', 'id' => 'end_at', 'required' => true]) !!}
@error('end_at')
<strong>{{ $message }}</strong>
@enderror
</div>
</div>

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

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

<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script>
// Initialize flatpickr on the input field
flatpickr("#start_at", {
enableTime: true, // Enable time selection
dateFormat: "Y-m-d H:i", // Set the date and time format
});
flatpickr("#end_at", {
enableTime: true, // Enable time selection
dateFormat: "Y-m-d H:i", // Set the date and time format
});
</script>

</x-slot>
<x-slot name="footer">
{!! Form::submit('Update', ['class' => 'btn btn-primary float-right']) !!}
{!! Form::submit('Update', ['class' => 'btn btn-primary float-right', 'id' => 'submit-button']) !!}
</x-slot>

</x-backend.card>
Expand Down
Loading

0 comments on commit 110ecaf

Please sign in to comment.