Skip to content
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
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ node_modules
# Laravel
.mcp.json
.env.example
.env.testing
phpstan.neon
phpunit.xml
phpunit.*.xml
rector.php
pint.json
tests
Expand Down
56 changes: 33 additions & 23 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@ APP_NAME="LaravelCameroun"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_DOMAIN=laravelcm.local
APP_URL=http://laravelcm.local
ASSET_URL=https://laravelcm.local
APP_LOCALE=fr
APP_FALLBACK_LOCALE=fr
APP_PORT=8080
APP_SERVICE=laravelcm
FILAMENT_PATH=cp

LOG_CHANNEL=stack
LOG_STACK=single,nightwatch
LOG_LEVEL=debug

RAY_HOST=ray@buggregator
RAY_PORT=8000
SENTRY_LARAVEL_DSN=http://sentry@buggregator:8000/1
SENTRY_TRACES_SAMPLE_RATE=1.0
VAR_DUMPER_FORMAT=server
VAR_DUMPER_SERVER=tcp://buggregator:9912
INSPECTOR_URL=http://inspector@buggregator:8000
INSPECTOR_API_KEY=test
INSPECTOR_INGESTION_KEY=1test
INSPECTOR_ENABLE=true

DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_PORT=5432
Expand All @@ -20,10 +33,16 @@ DB_USERNAME=sail
DB_PASSWORD=password

BROADCAST_DRIVER=log
CACHE_DRIVER=file
MEDIA_DISK=media
FILESYSTEM_DISK=${MEDIA_DISK}
FILAMENT_FILESYSTEM_DISK=${MEDIA_DISK}
FILAMENT_PATH=cpanel

QUEUE_CONNECTION=database
BROADCAST_CONNECTION=log
CACHE_DRIVER=file
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_LIFETIME=1400

MEMCACHED_HOST=127.0.0.1

Expand All @@ -41,10 +60,13 @@ MAIL_FROM_ADDRESS=no-reply@laravel.cm
MAIL_FROM_NAME="${APP_NAME}"
MAIL_SUPPORT=mail-support@laravel.cm

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_ACCESS_KEY_ID=sail
AWS_SECRET_ACCESS_KEY=password
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_BUCKET=laravelcm
AWS_ENDPOINT="http://minio:9000"
AWS_URL="http://localhost:9000/laravelcm"
AWS_USE_PATH_STYLE_ENDPOINT=true

PUSHER_APP_ID=
PUSHER_APP_KEY=
Expand All @@ -57,39 +79,27 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT=${APP_URL}/auth/github/callback

GITHUB_FINE_GRAINED_TOKEN=
MARKDOWNX_GIPHY_API_KEY=
TORCHLIGHT_TOKEN=
TORCHLIGHT_THEME=moonlight-ii
UNSPLASH_ACCESS_KEY=

TELEGRAM_BOT_TOKEN=
TELEGRAM_CHANNEL=

MEDIA_DISK=media
FILAMENT_FILESYSTEM_DISK=${MEDIA_DISK}

NOTCHPAY_PUBLIC_KEY=

TWITTER_CONSUMER_KEY=your-consumer-key
TWITTER_CONSUMER_SECRET=your-consumer-secret
TWITTER_ACCESS_TOKEN=your-accesss_token
TWITTER_ACCESS_SECRET=your-access-token-secret

GOOGLE_RECAPTCHA_SITE_KEY=your-recaptcha-site-key
GOOGLE_RECAPTCHA_SECRET_KEY=your-secret-key

GITHUB_FINE_GRAINED_TOKEN=
UNSPLASH_ACCESS_KEY=
NOTCHPAY_PUBLIC_KEY=
NIGHTWATCH_TOKEN=
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1

SCOUT_DRIVER=typesense
TYPESENSE_HOST=typesense
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http
TYPESENSE_API_KEY=xyz

NIGHTWATCH_TOKEN=
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1

# SSH Tunnel Configuration for Database Migration
SSH_TUNNEL_USER=
SSH_TUNNEL_HOSTNAME=
Expand Down
42 changes: 42 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
APP_NAME="LaravelCameroun"
APP_ENV=testing
APP_KEY=base64:NXoQgjw2ZlOxnGbo5ZRhYgTdM6xLYsgYElNAgcTQJkE=
APP_DEBUG=false
APP_DOMAIN=laravelcm.test
APP_URL=http://laravelcm.test
ASSET_URL=http://laravelcm.test
APP_LOCALE=fr
APP_FALLBACK_LOCALE=fr

LOG_CHANNEL=stack
LOG_STACK=single
LOG_LEVEL=error

# Base de données PostgreSQL pour les tests
DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_PORT=5432
DB_DATABASE=testing
DB_USERNAME=sail
DB_PASSWORD=password

# Cache et sessions pour les tests
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_CONNECTION=sync

# Mail en mode array pour les tests
MAIL_MAILER=array

# Désactiver les services externes en mode test
TELESCOPE_ENABLED=false
RAY_ENABLED=false
SENTRY_LARAVEL_DSN=
INSPECTOR_ENABLE=false

# Optimisations pour les tests
BCRYPT_ROUNDS=4

# Répertoires pour les tests (éviter les problèmes de permissions)
VIEW_COMPILED_PATH=/tmp/views
LOG_CHANNEL=null
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, bcmath, soap, intl, gd, exif, iconv, imagick
tools: composer:v2
coverage: none
- name: ℹ Setup Problem Matches
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ jobs:
pest:
runs-on: ubuntu-22.04

services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_PASSWORD: password
POSTGRES_USER: sail
POSTGRES_DB: testing
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: 👀 Checkout
uses: actions/checkout@v5
Expand All @@ -27,4 +42,4 @@ jobs:
- name: 🧱 Build JS Dependencies
run: yarn build
- name: 🕵️‍♂️ Run Pest Tests
run: ./vendor/bin/pest
run: ./vendor/bin/pest --configuration=phpunit.ci.xml --parallel --processes=4 --bail
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ FROM ghcr.io/yieldstudio/php:${PHP_VERSION}-frankenphp AS base

ENV HEALTHCHECK_PATH="/up"

## Uncomment if you need to install additional PHP extensions
# USER root
# RUN install-php-extensions bcmath gd

############################################
# Development Image
############################################
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/AssignUserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function handle(): void
{
$this->info('Assigning user role to all users...');

foreach (User::withoutRole()->get() as $user) {
foreach (User::query()->scopes('withoutRole')->get() as $user) {
$user->assignRole('user');
}

Expand Down
5 changes: 3 additions & 2 deletions app/Console/Commands/PublishArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public function handle(): void

foreach ($articles as $article) {
/** @var Article $article */
$article->published_at = $article->submitted_at;
$article->save();
$article->update([
'published_at' => $article->submitted_at,
]);
}

$count = $articles->count();
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/SendUnVerifiedMails.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class SendUnVerifiedMails extends Command

public function handle(): void
{
foreach (User::unVerifiedUsers()->get() as $user) {
foreach (User::query()->scopes('unVerifiedUsers')->get() as $user) {
Mail::to($user)->send(new SendMailToUnVerifiedUsers($user));
}
}
Expand Down
16 changes: 16 additions & 0 deletions app/Contracts/HasCachedMediaInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace App\Contracts;

interface HasCachedMediaInterface
{
public function getCacheKey(string $collection): string;

public function getCacheTtl(): \DateTimeInterface;

public function flushMediaCache(?string $collection = null): void;

public function getMediaCollections(): array;
}
23 changes: 12 additions & 11 deletions app/Livewire/Components/ChannelsSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@

use App\Models\Channel;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Collection;
use Livewire\Attributes\Computed;
use Livewire\Component;

/**
* @property Channel | null $currentChannel
* @property-read Channel|null $currentChannel
* @property-read Collection<int, Channel> $channels
*/
final class ChannelsSelector extends Component
{
public ?string $slug = null;

public function selectedChannel(int $channelId): void
{
$this->slug = Channel::query()->find($channelId)?->slug;
$this->slug = $this->channels->firstWhere('id', $channelId)?->slug;

$this->dispatch('channelUpdated', channelId: $channelId);
}
Expand All @@ -34,17 +35,17 @@ public function resetChannel(): void
#[Computed]
public function currentChannel(): ?Channel
{
return filled($this->slug) ? Channel::findBySlug($this->slug) : null;
return $this->channels->firstWhere('slug', $this->slug);
}

#[Computed(persist: true, seconds: 3600 * 24 * 30, cache: true)]
public function channels(): Collection
{
return Channel::with('items')->whereNull('parent_id')->get();
}

public function render(): View
{
return view('livewire.components.channels-selector', [
'channels' => Cache::remember(
'channels',
now()->addMonth(),
fn () => Channel::with('items')->whereNull('parent_id')->get()
),
]);
return view('livewire.components.channels-selector');
}
}
9 changes: 2 additions & 7 deletions app/Livewire/Components/Slideovers/ArticleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Laravelcm\LivewireSlideOvers\SlideOverComponent;

/**
* @property Form $form
* @property-read Form $form
*/
final class ArticleForm extends SlideOverComponent implements HasForms
{
Expand All @@ -40,7 +40,7 @@ public function mount(?int $articleId = null): void
{
// @phpstan-ignore-next-line
$this->article = filled($articleId)
? Article::query()->findOrFail($articleId)
? Article::with('tags')->findOrFail($articleId)
: new Article;

$this->form->fill(array_merge($this->article->toArray(), [
Expand All @@ -55,11 +55,6 @@ public static function panelMaxWidth(): string
return '6xl';
}

public static function closePanelOnEscape(): bool
{
return false;
}

public static function closePanelOnClickAway(): bool
{
return false;
Expand Down
7 changes: 1 addition & 6 deletions app/Livewire/Components/Slideovers/DiscussionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function form(Form $form): Form
->relationship(
name: 'tags',
titleAttribute: 'name',
modifyQueryUsing: fn ($query) => $query->whereJsonContains('concerns', 'discussion')
modifyQueryUsing: fn ($query) => $query->whereRaw("jsonb_exists(concerns::jsonb, ?)", ['discussion'])
)
->required()
->minItems(1)
Expand Down Expand Up @@ -136,11 +136,6 @@ public static function panelMaxWidth(): string
return '2xl';
}

public static function closePanelOnEscape(): bool
{
return false;
}

public static function closePanelOnClickAway(): bool
{
return false;
Expand Down
7 changes: 1 addition & 6 deletions app/Livewire/Components/Slideovers/ThreadForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class ThreadForm extends SlideOverComponent implements HasForms
public function mount(?int $threadId = null): void
{
$this->thread = filled($threadId)
? Thread::query()->findOrFail($threadId)
? Thread::with('channels')->findOrFail($threadId)
: new Thread;

$this->form->fill(array_merge($this->thread->toArray(), [
Expand All @@ -50,11 +50,6 @@ public static function panelMaxWidth(): string
return '2xl';
}

public static function closePanelOnEscape(): bool
{
return false;
}

public static function closePanelOnClickAway(): bool
{
return false;
Expand Down
3 changes: 2 additions & 1 deletion app/Livewire/Components/User/Articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ final class Articles extends Component implements HasActions, HasForms
#[Computed]
public function articles(): LengthAwarePaginator
{
return Article::with('tags', 'reactions')
return Article::with('tags')
->withCount('reactions')
->where('user_id', Auth::id())
->latest()
->paginate(10);
Expand Down
Loading
Loading