Initial commit

This commit is contained in:
Ronald Huynen
2026-03-23 21:37:59 +01:00
commit 2547717edb
2193 changed files with 972171 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
return (new Config())
->setParallelConfig(ParallelConfigFactory::detect()) // @TODO 4.0 no need to call this manually
->setRiskyAllowed(false)
->setRules([
'@auto' => true
])
// 💡 by default, Fixer looks for `*.php` files excluding `./vendor/` - here, you can groom this config
->setFinder(
(new Finder())
// 💡 root folder to check
->in(__DIR__)
// 💡 additional files, eg bin entry file
// ->append([__DIR__.'/bin-entry-file'])
// 💡 folders to exclude, if any
// ->exclude([/* ... */])
// 💡 path patterns to exclude, if any
// ->notPath([/* ... */])
// 💡 extra configs
// ->ignoreDotFiles(false) // true by default in v3, false in v4 or future mode
// ->ignoreVCS(true) // true by default
)
;

View File

@@ -0,0 +1,100 @@
<?php
namespace App\Http\Livewire\Welcome;
use App\Models\Category;
use App\Models\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Livewire\Component;
class ArticleCardFull extends Component
{
public $author;
public $post = [];
public $posts;
public $media;
public $postNr;
public bool $random = false;
public function mount($postNr = 0, $random = null, Request $request)
{
$this->postNr = $postNr;
if ($random) {
$this->random = true;
}
// Get article posts from all locations for welcome page
$post = Post::with([
'postable' => function ($query) {
$query->select(['id', 'name']);
},
'category' => function ($query) {
$query->where('type', 'App\Models\Article');
},
'translations' => function ($query) {
$query->where('locale', App::getLocale());
},
'author',
'media',
])
->whereHas('category', function ($query) {
$query->where('type', 'App\Models\Article');
})
->whereHas('translations', function ($query) {
$query
->where('locale', App::getLocale())
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
});
// Apply random or sorted ordering
if ($this->random) {
$post = $post->inRandomOrder()->get();
} else {
$post = $post->get()->sortByDesc(function ($query) {
if (isset($query->translations)) {
return $query->translations->first()->updated_at;
};
})->values(); // Use values() method to reset the collection keys after sortBy
}
$lastNr = $post->count() - 1;
if ($postNr > $lastNr || $post->isEmpty()) {
$post = null;
$this->post = null;
} else {
$post = $post[$postNr];
}
if ($post && isset($post->translations) && $post->translations->isNotEmpty()) {
$translation = $post->translations->first();
$this->post = $translation;
$this->post['slug'] = $translation->slug;
$this->post['from'] = $translation->from;
$category = Category::find($post->category_id);
$categoryTranslation = $category ? $category->translations->where('locale', App::getLocale())->first() : null;
$this->post['category'] = $categoryTranslation ? $categoryTranslation->name : '';
$this->post['author'] = $post->author ? $post->author->name : timebank_config('posts.site-content-writer');
$this->post['id'] = $post->id;
$this->post['model'] = get_class($post);
$this->post['like_count'] = $post->like_count ?? 0;
if ($post->media && $post->media->isNotEmpty()) {
$this->media = Post::find($post->id)->getFirstMedia('posts');
}
}
}
public function render()
{
return view('livewire.welcome.article-card-full');
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Livewire\Welcome;
use App\Models\Post;
use Illuminate\Support\Facades\App;
use Livewire\Component;
class CtaPost extends Component
{
public $type;
public bool $random;
public int $limit;
public function mount($type, $sticky = null, $random = null, $limit = null)
{
$this->type = $type;
$this->random = $random ?? false;
$this->limit = $limit ?? 1;
}
public function register()
{
return redirect()->route('register');
}
public function render()
{
$locale = App::getLocale();
// Random post
if ($this->random) {
$posts = Post::with([
'category',
'translations' => function ($query) use ($locale) {
$query->where('locale', $locale)
->orderBy('created_at', 'desc')
->limit($this->limit);
}
])
->whereHas('category', function ($query) {
$query->where('type', $this->type);
})
->whereHas('translations', function ($query) use ($locale) {
$query->where('locale', $locale)
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
})
->inRandomOrder()
->limit($this->limit)
->get(); // Execute the query to get a Collection of posts
} else {
// Latest post first
$posts = Post::with([
'category',
'images' => function ($query) {
$query->select('images.id', 'caption', 'path');
},
'translations' => function ($query) use ($locale) {
$query->where('locale', $locale)
->orderBy('created_at', 'desc')
->limit($this->limit);
}
])
->whereHas('category', function ($query) {
$query->where('type', $this->type);
})
->whereHas('translations', function ($query) use ($locale) {
$query->where('locale', $locale)
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
})
->orderBy('created_at', 'desc')
->limit($this->limit)
->get(); // Execute the query to get a Collection of posts
}
$photo = null;
if ($posts->isNotEmpty()) {
$firstPost = $posts->first(); // Get the first post from the collection
if ($firstPost->hasMedia('*')) { // Now, hasMedia() is called on a Post instance
$photo = $firstPost->getFirstMedia('*')->getUrl();
}
}
return view('livewire.welcome.cta-post', [
'posts' => $posts,
'photo' => $photo,
]);
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Http\Livewire\Welcome;
use App\Models\Category;
use App\Models\Locations\City;
use App\Models\Locations\Country;
use App\Models\Locations\Division;
use App\Models\Locations\Location;
use App\Models\Meeting;
use App\Models\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
use Livewire\Component;
class EventCardFull extends Component
{
public $author;
public $post = [];
public $posts;
public $media;
public $postNr;
public function mount($postNr = 0, Request $request)
{
$this->postNr = $postNr;
// Get upcoming events from all locations for welcome page
$post = Post::with([
'postable' => function ($query) {
$query->select(['id', 'name']);
},
'category' => function ($query) {
$query->where('type', Meeting::class);
},
'translations' => function ($query) {
$query->where('locale', App::getLocale());
},
'meeting',
'media',
])
->whereHas('category', function ($query) {
$query->where('type', Meeting::class);
})
->whereHas('translations', function ($query) {
$query
->where('locale', App::getLocale())
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
})
->get()->sortBy(function ($query) {
if (isset($query->meeting->from)) {
return $query->meeting->from;
};
})->values(); // Use values() method to reset the collection keys after sortBy
$lastNr = $post->count() - 1;
if ($postNr > $lastNr || $post->isEmpty()) {
$post = null;
$this->post = null;
} else {
$post = $post[$postNr];
}
if ($post && isset($post->translations) && $post->translations->isNotEmpty()) {
$translation = $post->translations->first();
$this->post = $translation;
$this->post['start'] = Carbon::parse($translation->updated_at)->isoFormat('LL');
$this->post['slug'] = $translation->slug;
$category = Category::find($post->category_id);
$categoryTranslation = $category ? $category->translations->where('locale', App::getLocale())->first() : null;
$this->post['category'] = $categoryTranslation ? $categoryTranslation->name : '';
$this->post['author'] = $post->postable ? $post->postable->name : '';
$this->post['id'] = $post->id;
$this->post['model'] = get_class($post);
$this->post['like_count'] = $post->like_count ?? 0;
if ($post->meeting) {
$this->post['address'] = ($post->meeting->address) ? $post->meeting->address : '';
$this->post['from'] = ($post->meeting->from) ? $post->meeting->from : '';
$this->post['venue'] = ($post->meeting->venue) ? $post->meeting->venue : '';
$this->post['city'] = $post->meeting->location?->first()?->city?->translations?->first()?->name ?? '';
$this->post['price'] = ($post->meeting->price) ? tbFormat($post->meeting->price) : '';
}
if ($post->media && $post->media->isNotEmpty()) {
$this->media = Post::find($post->id)->getFirstMedia('posts');
}
}
}
public function render()
{
return view('livewire.welcome.event-card-full');
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Http\Livewire\Welcome;
use App\Models\Category;
use App\Models\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Livewire\Component;
class ImageCardFull extends Component
{
public $author;
public $post = [];
public $posts;
public $media;
public $postNr;
public bool $random = false;
public function mount($postNr = 0, $random = null, Request $request)
{
$this->postNr = $postNr;
if ($random) {
$this->random = true;
}
// Get image posts from all locations for welcome page
$locale = App::getLocale();
$categoryTypes = ['App\Models\ImagePost', 'App\Models\ImagePost\\' . $locale];
$post = Post::with([
'postable' => function ($query) {
$query->select(['id', 'name']);
},
'category' => function ($query) use ($categoryTypes) {
$query->whereIn('type', $categoryTypes);
},
'translations' => function ($query) {
$query->where('locale', App::getLocale());
},
'author',
'media',
])
->whereHas('category', function ($query) use ($categoryTypes) {
$query->whereIn('type', $categoryTypes);
})
->whereHas('translations', function ($query) {
$query
->where('locale', App::getLocale())
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
});
// Apply random or sorted ordering
if ($this->random) {
$post = $post->inRandomOrder()->get();
} else {
$post = $post->get()->sortByDesc(function ($query) {
if (isset($query->translations)) {
return $query->translations->first()->updated_at;
};
})->values(); // Use values() method to reset the collection keys after sortBy
}
$lastNr = $post->count() - 1;
if ($postNr > $lastNr || $post->isEmpty()) {
$post = null;
$this->post = null;
} else {
$post = $post[$postNr];
}
if ($post && isset($post->translations) && $post->translations->isNotEmpty()) {
$translation = $post->translations->first();
$this->post = $translation;
$this->post['slug'] = $translation->slug;
$this->post['from'] = $translation->from;
$category = Category::find($post->category_id);
$categoryTranslation = $category ? $category->translations->where('locale', App::getLocale())->first() : null;
$this->post['category'] = $categoryTranslation ? $categoryTranslation->name : '';
$this->post['author'] = $post->author ? $post->author->name : timebank_config('posts.site-content-writer');
$this->post['author_id'] = $post->author ? $post->author->id : null;
$this->post['author_profile_photo_path'] = $post->author && $post->author->profile_photo_path ? $post->author->profile_photo_path : null;
$this->post['id'] = $post->id;
$this->post['model'] = get_class($post);
$this->post['like_count'] = $post->like_count ?? 0;
if ($post->media && $post->media->isNotEmpty()) {
$this->media = Post::find($post->id)->getFirstMedia('posts');
// Get media owner and caption
$this->post['media_owner'] = $this->media->getCustomProperty('owner', '');
$captionKey = 'caption-' . App::getLocale();
$this->post['media_caption'] = $this->media->getCustomProperty($captionKey, '');
}
}
}
public function render()
{
return view('livewire.welcome.image-card-full');
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Http\Livewire\Welcome;
use App\Models\Category;
use App\Models\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Livewire\Component;
class ImageLocalizedCardFull extends Component
{
public $author;
public $post = [];
public $posts;
public $media;
public $postNr;
public bool $random = false;
public function mount($postNr = 0, $random = null, Request $request)
{
$this->postNr = $postNr;
if ($random) {
$this->random = true;
}
// Get localized image posts from all locations for welcome page
$locale = App::getLocale();
$categoryType = 'App\\Models\\ImagePost\\' . $locale;
$post = Post::with([
'postable' => function ($query) {
$query->select(['id', 'name']);
},
'category' => function ($query) use ($categoryType) {
$query->where('type', $categoryType);
},
'translations' => function ($query) {
$query->where('locale', App::getLocale());
},
'author',
'media',
])
->whereHas('category', function ($query) use ($categoryType) {
$query->where('type', $categoryType);
})
->whereHas('translations', function ($query) {
$query
->where('locale', App::getLocale())
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
});
// Apply random or sorted ordering
if ($this->random) {
$post = $post->inRandomOrder()->get();
} else {
$post = $post->get()->sortByDesc(function ($query) {
if (isset($query->translations)) {
return $query->translations->first()->updated_at;
};
})->values(); // Use values() method to reset the collection keys after sortBy
}
$lastNr = $post->count() - 1;
if ($postNr > $lastNr || $post->isEmpty()) {
$post = null;
$this->post = null;
} else {
$post = $post[$postNr];
}
if ($post && isset($post->translations) && $post->translations->isNotEmpty()) {
$translation = $post->translations->first();
$this->post = $translation;
$this->post['slug'] = $translation->slug;
$this->post['from'] = $translation->from;
$category = Category::find($post->category_id);
$categoryTranslation = $category ? $category->translations->where('locale', App::getLocale())->first() : null;
$this->post['category'] = $categoryTranslation ? $categoryTranslation->name : '';
$this->post['author'] = $post->author ? $post->author->name : timebank_config('posts.site-content-writer');
$this->post['author_id'] = $post->author ? $post->author->id : null;
$this->post['author_profile_photo_path'] = $post->author && $post->author->profile_photo_path ? $post->author->profile_photo_path : null;
$this->post['id'] = $post->id;
$this->post['model'] = get_class($post);
$this->post['like_count'] = $post->like_count ?? 0;
if ($post->media && $post->media->isNotEmpty()) {
$this->media = Post::find($post->id)->getFirstMedia('posts');
// Get media owner and caption
$this->post['media_owner'] = $this->media->getCustomProperty('owner', '');
$captionKey = 'caption-' . App::getLocale();
$this->post['media_caption'] = $this->media->getCustomProperty($captionKey, '');
}
}
}
public function render()
{
return view('livewire.welcome.image-localized-card-full');
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace App\Http\Livewire\Welcome;
use App\Models\Post;
use Illuminate\Support\Facades\App;
use Livewire\Component;
class LandingPost extends Component
{
public $type;
public bool $random;
public int $limit;
public function mount($type, $sticky = null, $random = null, $limit = null)
{
$this->type = $type;
$this->random = $random ?? false;
$this->limit = $limit ?? 1;
}
public function render()
{
$locale = App::getLocale();
// Random post
if ($this->random) {
$posts = Post::with([
'category',
'translations' => function ($query) use ($locale) {
$query->where('locale', $locale)
->orderBy('created_at', 'desc')
->limit($this->limit);
}
])
->whereHas('category', function ($query) {
$query->where('type', $this->type);
})
->whereHas('translations', function ($query) use ($locale) {
$query->where('locale', $locale)
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
})
->inRandomOrder()
->limit($this->limit)
->get(); // Execute the query to get a Collection of posts
} else {
// Latest post first
$posts = Post::with([
'category',
'images' => function ($query) {
$query->select('images.id', 'caption', 'path');
},
'translations' => function ($query) use ($locale) {
$query->where('locale', $locale)
->orderBy('created_at', 'desc')
->limit($this->limit);
}
])
->whereHas('category', function ($query) {
$query->where('type', $this->type);
})
->whereHas('translations', function ($query) use ($locale) {
$query->where('locale', $locale)
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
})
->orderBy('created_at', 'desc')
->limit($this->limit)
->get(); // Execute the query to get a Collection of posts
}
$photo = null;
if ($posts->isNotEmpty()) {
$firstPost = $posts->first(); // Get the first post from the collection
if ($firstPost->hasMedia('*')) { // Now, hasMedia() is called on a Post instance
$photo = $firstPost->getFirstMedia('*')->getUrl();
}
}
return view('livewire.welcome.landing-post', [
'posts' => $posts,
'photo' => $photo,
]);
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace App\Http\Livewire\Welcome;
use App\Models\Post;
use Illuminate\Support\Facades\App;
use Livewire\Component;
class LoginLandingPost extends Component
{
public $type;
public bool $random;
public int $limit;
public function mount($type, $sticky = null, $random = null, $limit = null)
{
$this->type = $type;
$this->random = $random ?? false;
$this->limit = $limit ?? 1;
}
public function render()
{
$locale = App::getLocale();
// Random post
if ($this->random) {
$posts = Post::with([
'category',
'translations' => function ($query) use ($locale) {
$query->where('locale', $locale)
->orderBy('created_at', 'desc')
->limit($this->limit);
}
])
->whereHas('category', function ($query) {
$query->where('type', $this->type);
})
->whereHas('translations', function ($query) use ($locale) {
$query->where('locale', $locale)
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
})
->inRandomOrder()
->limit($this->limit)
->get(); // Execute the query to get a Collection of posts
} else {
// Latest post first
$posts = Post::with([
'category',
'images' => function ($query) {
$query->select('images.id', 'caption', 'path');
},
'translations' => function ($query) use ($locale) {
$query->where('locale', $locale)
->orderBy('created_at', 'desc')
->limit($this->limit);
}
])
->whereHas('category', function ($query) {
$query->where('type', $this->type);
})
->whereHas('translations', function ($query) use ($locale) {
$query->where('locale', $locale)
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
})
->orderBy('created_at', 'desc')
->limit($this->limit)
->get(); // Execute the query to get a Collection of posts
}
$photo = null;
if ($posts->isNotEmpty()) {
$firstPost = $posts->first(); // Get the first post from the collection
if ($firstPost->hasMedia('*')) { // Now, hasMedia() is called on a Post instance
$photo = $firstPost->getFirstMedia('*')->getUrl();
}
}
return view('livewire.welcome.login-landing-post', [
'posts' => $posts,
'photo' => $photo,
]);
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Http\Livewire\Welcome;
use App\Models\Category;
use App\Models\News;
use App\Models\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
use Livewire\Component;
class NewsCardFull extends Component
{
public $author;
public $post = [];
public $posts;
public $media;
public $postNr;
public function mount($postNr = 0, Request $request)
{
$this->postNr = $postNr;
// Get news posts from all locations for welcome page
$post = Post::with([
'postable' => function ($query) {
$query->select(['id', 'name']);
},
'category' => function ($query) {
$query->where('type', News::class)->with('categoryable.translations');
},
'translations' => function ($query) {
$query->where('locale', App::getLocale());
},
'author',
'media',
])
->whereHas('category', function ($query) {
$query->where('type', News::class);
})
->whereHas('translations', function ($query) {
$query
->where('locale', App::getLocale())
->whereDate('from', '<=', now())
->where(function ($query) {
$query->whereDate('till', '>', now())->orWhereNull('till');
})
->orderBy('updated_at', 'desc');
})
->get()->sortByDesc(function ($query) {
if (isset($query->translations)) {
return $query->translations->first()->updated_at;
};
})->values(); // Use values() method to reset the collection keys after sortBy
$lastNr = $post->count() - 1;
if ($postNr > $lastNr || $post->isEmpty()) {
$post = null;
$this->post = null;
} else {
$post = $post[$postNr];
}
if ($post && isset($post->translations) && $post->translations->isNotEmpty()) {
$translation = $post->translations->first();
$this->post = $translation;
$this->post['start'] = Carbon::parse(strtotime($translation->updated_at))->isoFormat('LL');
$this->post['slug'] = $translation->slug;
$this->post['from'] = $translation->from;
$category = Category::find($post->category_id);
$categoryTranslation = $category ? $category->translations->where('locale', App::getLocale())->first() : null;
$this->post['category'] = $categoryTranslation ? $categoryTranslation->name : '';
$this->post['author'] = $post->author ? $post->author->name : timebank_config('posts.site-content-writer');
$this->post['id'] = $post->id;
$this->post['model'] = get_class($post);
$this->post['like_count'] = $post->like_count ?? 0;
// Prepend location name to excerpt if available
$excerpt = $translation->excerpt;
if ($post->category && $post->category->categoryable && $post->category->categoryable->translations) {
$locationTranslation = $post->category->categoryable->translations->where('locale', App::getLocale())->first();
if ($locationTranslation && $locationTranslation->name) {
$locationName = strtoupper($locationTranslation->name);
$excerpt = $locationName . ' - ' . $excerpt;
}
}
$this->post['excerpt'] = $excerpt;
if ($post->media && $post->media->isNotEmpty()) {
$this->media = Post::find($post->id)->getFirstMedia('posts');
}
}
}
public function render()
{
return view('livewire.welcome.news-card-full');
}
}