Skip to content

Feature/lar 14 update communities links #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions app/Http/Controllers/DiscussionController.php

This file was deleted.

39 changes: 0 additions & 39 deletions app/Http/Controllers/FileUploadController.php

This file was deleted.

61 changes: 0 additions & 61 deletions app/Http/Controllers/HomeController.php

This file was deleted.

39 changes: 0 additions & 39 deletions app/Http/Controllers/SlackController.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Http\Requests;
namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Http\Requests;
namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
Expand Down
1 change: 1 addition & 0 deletions app/Livewire/Pages/Forum/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function reloadThreads(?int $channelId): void
}

$this->resetPage();

$this->dispatch('render');
}

Expand Down
69 changes: 69 additions & 0 deletions app/Livewire/Pages/Home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);

namespace App\Livewire\Pages;

use App\Models\Article;
use App\Models\Discussion;
use App\Models\Plan;
use App\Models\Thread;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Livewire\Component;

final class Home extends Component
{
public function render(): View
{
$ttl = now()->addDays(2);

// @phpstan-ignore-next-line
seo()
->description(__('pages/home.description'))
->twitterDescription(__('pages/home.description'))
->image(asset('/images/socialcard.png'))
->twitterSite('laravelcm')
->withUrl();

return view('livewire.pages.home', [
'plans' => Cache::remember(
key: 'plans',
ttl: now()->addYear(),
callback: fn () => Plan::query()->developer()->get()
),
'latestArticles' => Cache::remember(
key: 'latestArticles',
ttl: $ttl,
callback: fn (): Collection => Article::with(['tags', 'user', 'user.transactions']) // @phpstan-ignore-line
->published()
->orderByDesc('sponsored_at')
->orderByDesc('published_at')
->orderByViews()
->trending()
->limit(4)
->get()
),
'latestThreads' => Cache::remember(
key: 'latestThreads',
ttl: $ttl,
callback: fn (): Collection => Thread::with(['user', 'user.transactions'])
->whereNull('solution_reply_id')
->whereBetween('threads.created_at', [now()->subMonths(3), now()])
->inRandomOrder()
->limit(4)
->get()
),
'latestDiscussions' => Cache::remember(
key: 'latestDiscussions',
ttl: $ttl,
callback: fn (): Collection => Discussion::with(['user', 'user.transactions']) // @phpstan-ignore-line
->recent()
->orderByViews()
->limit(3)
->get()
),
]);
}
}
3 changes: 1 addition & 2 deletions app/Models/Discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ final class Discussion extends Model implements ReactableInterface, ReplyInterfa
];

protected $appends = [
// @phpstan-ignore-next-line
'count_all_replies_with_child',
'count_all_replies_with_child', // @phpstan-ignore-line
];

protected bool $removeViewsOnDelete = true;
Expand Down
31 changes: 17 additions & 14 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand Down Expand Up @@ -137,28 +138,30 @@ public function hasEnterprise(): bool
return $this->enterprise !== null;
}

public function getRolesLabelAttribute(): string
public function rolesLabel(): Attribute
{
$roles = $this->getRoleNames()->toArray();

if (count($roles)) {
return implode(', ', array_map(fn ($item) => ucwords($item), $roles));
}

return 'N/A';
return Attribute::get(
fn () => count($roles)
? implode(', ', array_map(fn ($item) => ucwords($item), $roles))
: 'N/A'
);
}

public function getIsSponsorAttribute(): bool
public function IsSponsor(): Attribute
{
if ($this->transactions_count > 0) {
$transaction = $this->transactions()
->where('status', TransactionStatus::COMPLETE->value)
->first();
return Attribute::get(function (): bool {
if ($this->transactions_count > 0) {
$transaction = $this->transactions()
->where('status', TransactionStatus::COMPLETE->value)
->first();

return (bool) $transaction;
}
return (bool) $transaction;
}

return false;
return false;
});
}

public function isAdmin(): bool
Expand Down
5 changes: 1 addition & 4 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Providers;

use App\Events\ApiRegistered;
// use App\Events\ApiRegistered;
use App\Events\ArticleWasSubmittedForApproval;
use App\Events\CommentWasAdded;
use App\Events\ReplyWasCreated;
Expand Down Expand Up @@ -52,9 +52,6 @@ final class EventServiceProvider extends ServiceProvider
CommentWasAdded::class => [
SendNewCommentNotification::class,
],
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
\SocialiteProviders\Twitter\TwitterExtendSocialite::class.'@handle',
],

// ApiRegistered::class => [
// SendCompanyEmailVerificationNotification::class,
Expand Down
13 changes: 13 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Carbon\Carbon;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Support\Facades\Auth;
use League\CommonMark\Output\RenderedContentInterface;
Expand Down Expand Up @@ -91,3 +92,15 @@ function route_to_reply_able(mixed $replyAble): string
return route($routeName, $replyAble->slug);
}
}

if (! function_exists('isHolidayWeek')) {
function isHolidayWeek(): bool
{
$now = Carbon::now();

$holidayStart = Carbon::createFromDate($now->year, 12, 21)->startOfDay();
$holidayEnd = Carbon::createFromDate($now->year + 1, 1, 2)->endOfDay();

return $now->between($holidayStart, $holidayEnd);
}
}
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"qcod/laravel-gamify": "1.0.8",
"ramsey/uuid": "^4.7.4",
"sentry/sentry-laravel": "^4.10",
"socialiteproviders/twitter": "^4.1.2",
"spatie/laravel-data": "^4.10",
"spatie/laravel-feed": "^4.2.1",
"spatie/laravel-google-fonts": "^1.2.3",
Expand Down
Loading
Loading