Skip to content

Commit

Permalink
improve pages
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanramsi committed Dec 1, 2023
1 parent 00495cf commit c1b4693
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 260 deletions.
37 changes: 14 additions & 23 deletions app/Conference/Pages/AnnouncementList.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,22 @@ class AnnouncementList extends Page
{
protected static string $view = 'conference.pages.announcement-list';

public Carbon $currentDate;

public function mount()
{
$this->currentDate = today();
}

public function getRecordsProperty()
{
return Announcement::query()
->whereMeta('expires_at', '>', now()->startOfDay())
->orWhereMeta('expires_at', '')->orderBy('created_at', 'desc')
->with([
'tags' => function ($query) {
$query->take(3);
},
'user',
])
->withCount('tags')
->get();
}

protected function getViewData(): array
{
return [];
return [
'announcements' => Announcement::query()
->whereMeta('expires_at', '>', now()->startOfDay())
->orWhereMeta('expires_at', '')
->orderBy('created_at', 'desc')
->with([
'tags' => function ($query) {
$query->take(3);
},
'user',
])
->withCount('tags')
->get(),
];
}

public static function routes(PageGroup $pageGroup): void
Expand Down
33 changes: 11 additions & 22 deletions app/Conference/Pages/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Announcement;
use App\Models\ParticipantPosition;
use App\Models\Topic;
use Illuminate\Support\Facades\Route;
use Rahmanramsi\LivewirePageGroup\PageGroup;
use Rahmanramsi\LivewirePageGroup\Pages\Page;
Expand All @@ -12,32 +13,20 @@ class Home extends Page
{
protected static string $view = 'conference.pages.home';

protected function getViewData(): array
{
$filteredPositions = $this->getFilteredParticipantPositions();
$announcements = $this->getAnnouncements();

return [
'announcements' => $announcements,
'participantPosition' => $filteredPositions,
];
}

protected function getFilteredParticipantPositions()
{
return ParticipantPosition::query()
->whereHas('participants')
->with(['participants' => ['media', 'meta']])
->get();
}

protected function getAnnouncements()
public function mount()
{
return Announcement::query()->get();
}

public function mount()
protected function getViewData(): array
{
return [
'announcements' => Announcement::query()->get(),
'participantPosition' => ParticipantPosition::query()
->whereHas('participants')
->with(['participants' => ['media', 'meta']])
->get(),
'topics' => Topic::query()->get(),
];
}

public static function routes(PageGroup $pageGroup): void
Expand Down
17 changes: 16 additions & 1 deletion app/Models/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Participant extends Model implements HasMedia, Sortable
protected function fullName(): Attribute
{
return Attribute::make(
get: fn () => Str::squish($this->given_name.' '.$this->family_name),
get: fn () => Str::squish($this->given_name . ' ' . $this->family_name),
);
}

Expand Down Expand Up @@ -81,4 +81,19 @@ public function positions(): MorphToMany
return $this
->morphedByMany(ParticipantPosition::class, 'model', 'model_has_participants', 'participant_id', 'model_id');
}

public function getProfilePicture()
{
if($profilePicture = $this->getFirstMedia('profile')?->getAvailableUrl(['thumb', 'thumb-xl'])){
return $profilePicture;
}

$name = Str::of($this->fullName)
->trim()
->explode(' ')
->map(fn (string $segment): string => filled($segment) ? mb_substr($segment, 0, 1) : '')
->join(' ');

return 'https://ui-avatars.com/api/?name=' . urlencode($name) . '&color=FFFFFF&background=111827&font-size=0.33';
}
}
7 changes: 4 additions & 3 deletions app/Website/Pages/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class Home extends Page

protected function getViewData(): array
{
$activeConference = Conference::active();
return [
'topics' => Topic::where('conference_id', Conference::active()->getKey())->get(),
'upcomings' => Conference::upcoming()->get(),
'activeConference' => Conference::active(),
'topics' => Topic::withoutGlobalScopes()->where('conference_id', $activeConference->getKey())->get(),
'upcomingConferences' => Conference::upcoming()->get(),
'activeConference' => $activeConference,
];
}

Expand Down
6 changes: 3 additions & 3 deletions public/build/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"src": "resources/assets/images/logo.png"
},
"resources/panel/css/panel.css": {
"file": "assets/panel-8a63042e.css",
"file": "assets/panel-de28f92e.css",
"isEntry": true,
"src": "resources/panel/css/panel.css"
},
Expand All @@ -14,12 +14,12 @@
"src": "resources/panel/js/panel.js"
},
"resources/website/css/website.css": {
"file": "assets/website-26806a4d.css",
"file": "assets/website-e4f96494.css",
"isEntry": true,
"src": "resources/website/css/website.css"
},
"resources/website/js/website.js": {
"file": "assets/website-02a4b6a2.js",
"file": "assets/website-a9ec73b1.js",
"isEntry": true,
"src": "resources/website/js/website.js"
}
Expand Down
9 changes: 4 additions & 5 deletions resources/views/conference/pages/about.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<x-website::layouts.main>
<div class="card-body">
<div class="p-5">
<x-website::breadcrumbs :breadcrumbs="$this->getBreadcrumbs()" />
<div class="flex flex-col mb-6 mt-6 ms-1">
<h2 class="text-heading">{{ $this->getTitle() }} </h2>
<div class="">
<h1 class="text-heading">{{ $this->getTitle() }} </h1>
<div class="user-content">
{{ new Illuminate\Support\HtmlString($currentConference->getMeta('about')) }}
</div>
</div>

</div>
</x-conference::layouts.main>
</x-website::layouts.main>
18 changes: 9 additions & 9 deletions resources/views/conference/pages/announcement-list.blade.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<x-website::layouts.main>
<div class="card-body">
<h2 class="text-heading mt-6 ms-1">{{ 'Announcements' }}</h2>
<div class="divide-y overflow-y-auto mb-1 ms-1">
@forelse ($this->records as $announcement)
<div class="p-5 space-y-2">
<h2 class="text-heading">{{ 'Announcements' }}</h2>
<div class="divide-y overflow-y-auto space-y-2">
@forelse ($announcements as $announcement)
<a href="{{ route('livewirePageGroup.current-conference.pages.announcement-page', ['announcement' => $announcement->id]) }}"
class="flex flex-col bg-white md:flex-row hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700">
class="flex w-full bg-white md:flex-row hover:bg-gray-100 gap-x-2 p-1">
@if ($featuredImage = $announcement->getFirstMedia('featured_image'))
<img class="object-cover h-28 aspect-square mt-4 mb-4"
<img class="object-cover h-28 aspect-square"
src="{{ $featuredImage->getAvailableUrl(['thumb']) }}" alt="">
@endif
<div class="flex flex-col justify-between p-4 leading-normal">
<h5 class=" text-lg tracking-tight text-gray-900 dark:text-white">{{ $announcement->title }}</h5>
<div class="leading-normal">
<h3 class="text-lg tracking-tight text-gray-900 dark:text-white">{{ $announcement->title }}</h3>
@php
$announcementCreatedDate = $announcement->created_at->startOfDay();
$diffInDays = $announcementCreatedDate->diffInDays($currentDate);
$diffInDays = $announcementCreatedDate->diffInDays(today());
@endphp
<p class="mb-3 text-xs font-medium text-gray-500 dark:text-gray-400">
@if ($diffInDays > 0)
Expand Down
34 changes: 31 additions & 3 deletions resources/views/conference/pages/announcement.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
<x-website::layouts.main>
<div class="card-body text-gray-800">
<p class="text-xs text-gray-500 font-medium">{{ $this->announcement->created_at->format('l, j F Y') }}</p>
<div class="p-5">
@can('update', $announcement)
<div class="flex">
<a class="ms-auto btn btn-primary btn-xs" href="{{ route('filament.panel.resources.conferences.announcements.edit', ['tenant' => $currentConference->path, 'record' => $announcement->getKey()]) }}"><x-heroicon-s-pencil-square class="h-4 w-4" /> Edit</a>
</div>
@endcan
<div class="text-xs text-gray-500 font-medium">
{{ $this->announcement->created_at->format(setting('format.date')) }}</div>
<h1 class="card-title">{{ $this->announcement->title }}</h1>
<div class="announcement-information">
@php
$announcementCreatedDate = $announcement->created_at->startOfDay();
$diffInDays = $announcementCreatedDate->diffInDays(today());
@endphp
<div class="flex flex-wrap justify-between">
<p class="text-xs text-gray-500">
@if ($diffInDays > 0)
Published {{ $diffInDays }} days ago
@else
Published today
@endif
</p>
<p class="text-gray-500 text-xs">
@if ($user = $announcement->user)
By {{ $user->fullName }}
@else
By Admin
@endif
</p>
</div>
</div>
<div class="user-content">
{{ new Illuminate\Support\HtmlString($this->announcement->getMeta('content')) }}
</div>
</div>
</x-conference::layouts.main>
</x-conference::layouts.main>
Loading

0 comments on commit c1b4693

Please sign in to comment.