Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
327c9a8
Font
AllanKoder Jun 6, 2025
ff42801
Better looking show page
AllanKoder Jun 6, 2025
730f21e
Cat animation loader
AllanKoder Jun 8, 2025
aa36837
Profile Photo
AllanKoder Jun 10, 2025
d5a75aa
Profile picture and comments
AllanKoder Jun 10, 2025
a8dc289
Orange profiles
AllanKoder Jun 13, 2025
848d68a
More improvements
AllanKoder Jun 14, 2025
ab34f16
Yup validation errors solved
AllanKoder Jun 14, 2025
c681fd2
Comments changes, need to be refactored later or something
AllanKoder Jun 14, 2025
c236fce
Good start with observer fixes
AllanKoder Jun 14, 2025
41219c6
Fixing tests and general refactor
AllanKoder Jun 14, 2025
d599dd3
Working Tests
AllanKoder Jun 15, 2025
2b0fae1
Data Normalization and better review observability
AllanKoder Jun 15, 2025
926d73a
Dates in a helper function
AllanKoder Jun 15, 2025
17f0feb
Show users in comments
AllanKoder Jun 15, 2025
81a19ea
Stars and profile
AllanKoder Jun 15, 2025
16ccbb8
Comment controller and type refactor
AllanKoder Jun 17, 2025
ee1be6d
Fixed tests
AllanKoder Jun 17, 2025
08ea81b
Show user review and unified creating resources
AllanKoder Jun 19, 2025
0576796
Pagination
AllanKoder Jun 19, 2025
857a770
User profile
AllanKoder Jun 20, 2025
71889ff
Propose edits looks nicer
AllanKoder Jun 20, 2025
b91fbb8
UI Changes - Buttons not dependant on defered data
AllanKoder Jun 20, 2025
71dd329
Composable for Local storage
AllanKoder Jun 20, 2025
5ef1ef4
Tag Selector and Resource Edits
AllanKoder Jun 22, 2025
d43417c
Pagination for edits
AllanKoder Jun 22, 2025
68a2cac
Topic tags max width validation
AllanKoder Jun 22, 2025
1753f80
Resource edits validation
AllanKoder Jun 22, 2025
a2cad3d
Diff View
AllanKoder Jun 22, 2025
a1aae66
Added resourc edits more diff
AllanKoder Jun 25, 2025
c0c8792
Better toasting
AllanKoder Jun 26, 2025
8c8ff8f
Can reset the edits form
AllanKoder Jun 26, 2025
1db25f2
Color nicers
AllanKoder Jun 28, 2025
63e6671
Upload Photo instead now
AllanKoder Jul 1, 2025
79ec32f
Merging image files works
AllanKoder Jul 1, 2025
18408ad
Proposed Edits is now a json instead
AllanKoder Jul 3, 2025
a481218
Proposed edits refactor
AllanKoder Jul 3, 2025
75f3d8f
Big resouce edits improvements
AllanKoder Jul 6, 2025
9cda926
Code cleaning
AllanKoder Jul 6, 2025
ae84739
Good enough Validation on resource edits. I dont care anymore
AllanKoder Jul 6, 2025
68f02fd
Better merging process
AllanKoder Jul 8, 2025
1c3d37c
Create Resource
AllanKoder Jul 11, 2025
6664562
Validation
AllanKoder Jul 11, 2025
0b69b34
Tests updated
AllanKoder Jul 11, 2025
6f892c3
Refactoring the image system
AllanKoder Jul 11, 2025
a58ca58
Fixed tests and logo
AllanKoder Jul 13, 2025
86157ec
Tests refactor
AllanKoder Jul 14, 2025
091a56b
About us and Filter bar
AllanKoder Jul 16, 2025
d51afe2
Create resource reset form
AllanKoder Jul 16, 2025
dfd701e
UI is touched up for create resource
AllanKoder Jul 16, 2025
b72276a
Proposed Edits
AllanKoder Jul 16, 2025
fa40d82
Pint
AllanKoder Jul 18, 2025
9065ca2
Forgot to validate
AllanKoder Jul 18, 2025
2aaa8fc
CI/CD
AllanKoder Jul 18, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Set up PHP & Composer
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
php-version: 8.4
extensions: mbstring, pdo, mysql, bcmath, tokenizer
tools: composer

Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/review-dog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Laravel Pint Code Review

on:
pull_request:
paths:
- '**.php'

jobs:
reviewdog:
name: Laravel Pint Review
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: composer
extensions: mbstring, dom, curl

- name: Install Dependencies
run: composer install --no-interaction --no-progress --prefer-dist

- name: Install Pint
run: composer global require laravel/pint

- name: Run Pint with ReviewDog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
~/.composer/vendor/bin/pint --test --format=checkstyle \
| npx reviewdog -f=checkstyle \
-name="Laravel Pint" \
-reporter=github-pr-review \
-fail-on-error=false \
-level=info
2 changes: 1 addition & 1 deletion app/Actions/Fortify/UpdateUserProfileInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function update(User $user, array $input): void
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:1024'],
'photo' => ['nullable', 'image', 'max:400'],
])->validateWithBag('updateProfileInformation');

if (isset($input['photo'])) {
Expand Down
37 changes: 0 additions & 37 deletions app/Events/CommentCreated.php

This file was deleted.

7 changes: 2 additions & 5 deletions app/Events/ResourceReviewProcessed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Contracts\Events\ShouldDispatchAfterCommit;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
Expand All @@ -20,8 +17,8 @@ class ResourceReviewProcessed implements ShouldDispatchAfterCommit
*/
public function __construct(
public int $resource,
public array|null $oldReview,
public array|null $newReview,
public ?array $oldReview,
public ?array $newReview,
) {}

/**
Expand Down
5 changes: 1 addition & 4 deletions app/Events/TagFrequencyChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

Expand All @@ -17,7 +14,7 @@ class TagFrequencyChanged
/**
* Create a new event instance.
*/
public function __construct(public array|null $oldTags, public array|null $newTags) { }
public function __construct(public ?array $oldTags, public ?array $newTags) {}

/**
* Get the channels the event should broadcast on.
Expand Down
12 changes: 3 additions & 9 deletions app/Events/UpvoteProcessed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@

namespace App\Events;

use App\Models\Upvote;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Contracts\Events\ShouldDispatchAfterCommit;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Contracts\Events\ShouldDispatchAfterCommit;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class UpvoteProcessed implements ShouldDispatchAfterCommit
class UpvoteProcessed implements ShouldDispatchAfterCommit
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*/
public function __construct(public string $type, public int $id, public int $previousValue, public int $newValue)
{
}
public function __construct(public string $type, public int $id, public int $previousValue, public int $newValue) {}

/**
* Get the channels the event should broadcast on.
Expand Down
48 changes: 27 additions & 21 deletions app/Http/Controllers/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace App\Http\Controllers;

use App\Events\CommentCreated;
use App\Http\Requests\Comment\StoreCommentRequest;
use App\Http\Resources\CommentResource;
use App\Models\Comment;
use App\Services\ModelResolverService;
use App\Http\Resources\UserResource;
use App\Models\Comment;
use App\Services\CommentService;
use App\Services\ModelResolverService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
Expand All @@ -18,6 +17,7 @@
class CommentController extends Controller
{
protected $modelResolver;

protected $commentService;

public function __construct(ModelResolverService $modelResolver, CommentService $commentService)
Expand All @@ -31,10 +31,9 @@ public function __construct(ModelResolverService $modelResolver, CommentService
*/
public function store(StoreCommentRequest $request)
{
Log::debug("Called store on comment controller");
$validatedData = $request->validated();
Log::debug('Comment Controller Store', ['validated data' => $validatedData]);

Log::debug("Data validated and is " . json_encode($validatedData));
$comment = new Comment;
$comment->content = $validatedData['content'];
$comment->user_id = Auth::id();
Expand All @@ -44,18 +43,17 @@ public function store(StoreCommentRequest $request)

// Ensure that the model exists
$model = $this->modelResolver->resolve($validatedData['commentable_key'], $commentableId);
if (!$model) {
if (! $model) {
return response()->json(['message' => 'Model not found'], 404);
}
Log::debug("Resolved model class: " . $commentableType);

// Set the commentable type
$comment->commentable_type = $commentableType;
$comment->commentable_id = $commentableId;

// Top level comment
$parentCommentId = $validatedData['parent_comment_id'];
if (!$parentCommentId) {
if (! $parentCommentId) {
$comment->parent_comment_id = null;
$comment->depth = 1;
$comment->children_count = 0;
Expand Down Expand Up @@ -84,7 +82,7 @@ public function store(StoreCommentRequest $request)
'commentable_id' => $commentableId,
'commentable_type' => $commentableType,
'depth' => $new_comment_depth,
'replies_count' => $replies_count
'replies_count' => $replies_count,
],
[
'commentable_id' => [
Expand All @@ -99,14 +97,14 @@ public function store(StoreCommentRequest $request)
'depth' => [
'required',
'integer',
'lte:' . (config('comment.max_depth'))
'lte:'.(config('comment.max_depth')),
],
// Cannot exceed max replies
'replies_count' => [
'required',
'integer',
'lt:' . (config('comment.max_replies'))
]
'lt:'.(config('comment.max_replies')),
],
]
);

Expand All @@ -125,31 +123,39 @@ public function store(StoreCommentRequest $request)
}

$comment->save();
CommentCreated::dispatch(
$commentableId,
$commentableType
);

Log::debug("New saved comment is " . json_encode($comment));
Log::debug('New comment saved', [
'comment_id' => $comment->id,
'user_id' => $comment->user_id,
'commentable_type' => $comment->commentable_type,
'commentable_id' => $comment->commentable_id,
'depth' => $comment->depth,
]);

return response()->json([
'new_comment' => new CommentResource($comment),
'user' => new UserResource(Auth::user()),
]);;
]);
}

/**
* Display the specified comment, with pagination.
*/
public function show(Request $request, string $commentableKey, int $commentableId, int $index, int $paginationLimit = -1)
{
if ($paginationLimit == -1)
{
if ($paginationLimit == -1) {
$paginationLimit = config('comment.default_pagination_limit');
}

$sortBy = $request->query('sort_by', 'top');

Log::debug("Request is, commentable_type: " . $commentableKey . ". id: " . $commentableId . ". index: " . $index . ". Sorting: " . $sortBy);
Log::debug('Processing comment show request', [
'commentable_key' => $commentableKey,
'commentable_id' => $commentableId,
'index' => $index,
'sort_by' => $sortBy,
'pagination_limit' => $paginationLimit,
]);
$paginatedResults = $this->commentService->getPaginatedComments($commentableKey, $commentableId, $index, $paginationLimit, $sortBy);

return $paginatedResults;
Expand Down
Loading