Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MerddinEmrys's avatar

MerddinEmrys liked a comment+100 XP

6d ago

React from Scratch: Ep 26, Persisting New Puppies via the API

The issue was that the uploaded image was saved in storage/app/public, but Laravel serves files from the public/ directory.

Controller / Route

Route::post('/puppies', function (Request $request) {
    $validated = $request->validate([
        'name' => 'required|string',
        'trait' => 'required|string',
        'image_url' => 'required|mimes:jpg,jpeg,png|max:2048',
    ]);

    $path = $request->file('image_url')->store('images', 'public');

    $puppy = Puppy::create([
        ...$validated,
        'image_url' => $path,
    ]);

    return new PuppyResource($puppy);
});

Resource

use Illuminate\Support\Facades\Storage;

public function toArray(Request $request): array
{
    return [
        'id' => $this->id,
        'name' => $this->name,
        'trait' => $this->trait,
        'imageUrl' => url(Storage::url($this->image_url)),
        'likedBy' => $this->likedBy->pluck('id'),
    ];
}

⚡ Result

Now your React frontend receives:

{
  "data": {
    "id": 1,
    "name": "Tommy",
    "trait": "Loves running",
    "imageUrl": "http://127.0.0.1:8000/storage/images/abc123.png",
    "likedBy": []
  }
}
MerddinEmrys's avatar

MerddinEmrys liked a comment+100 XP

1w ago

React from Scratch: Ep 13, TypeScript is Your Friend. Really!

@puck_hb Hey!

I think I ommitted this in the video because I have TypeScript installed globally.

You can fix this by installing it as a dev dependency:

npm install --save-dev typescript

This will give you access to the tsc command locally (which is what npm run check relies on). After that, npm run check should work as expected!

MerddinEmrys's avatar

MerddinEmrys liked a comment+100 XP

1w ago

Crafting Vue Modals : Ep 12, E2E Testing With Laravel Dusk

@Maruu I think the brief delay in updating the URL is what's causing the issue. This test is functioning correctly with a manual 100ms pause inserted ...

it('can open a modal and close it', function () {
    $this->browse(function (Browser $browser) {
        $user = User::orderBy('name')->firstOrFail();
        $browser
            ->loginAs(1)
            ->visit(route('users.index'))
            ->waitFor('table')
            ->press('@edit-user-'.$user->id)
            ->waitFor('@modal-content')
            ->assertUrlIs(route('users.edit', $user->id))
            ->within('@modal-content', function(Browser $browser) {
                $browser->press('CANCEL');
            })
            ->waitUntilMissing('@modal-wrapper')
            ->pause(100)
            ->assertUrlIs(route('users.index'));
    });
});
MerddinEmrys's avatar

MerddinEmrys liked a comment+100 XP

2w ago

Build a Forum With Laravel: Ep 51, Let Scout Do the Searching

Great series, hope you do more in the future.

In relation to this episode now Scout is installed you can try other drivers. For example, https://github.com/teamtnt/laravel-scout-tntsearch-driver is very easy to setup and uses a local .sqlite database. That will give you fuzzy searching and searches where the spelling is incorrect in a similar manner to Meilsearch.

I'd say Meilsearch is definitely better if you have the facility /access to install it on your hosting. However, TNT search works anywhere, even on shared hosting.

The other point this lesson didn't touch on too much was speed. Like queries in MySQL is slow and will become slower as your database increases in size. Scout drivers (certainly TNT search and Meilsearch) are lighting fast. IN the video note the response times in the Meilsearch dashboard - 9ms. Insane.

As an example, I have a site uses TNT Search, that has indexed 1.4 million products. I get search results within 80ms, where I've indexed 9 columns of my Eloquent model.

The fastest driver I've come across in Agolia, for a hosted solution I have no idea how they return results so fast.

I digress :)

MerddinEmrys's avatar

MerddinEmrys liked a comment+100 XP

3w ago

Laravel From Scratch (2026 Edition): Ep 25, Tailwind Theme Setup And Initial UI

Thank you @MerddinEmrys I had problems running npm run build and had to change form.css from @media (min-width: var(--breakpoint-md)) { to be @media (min-width: 48rem) {

MerddinEmrys's avatar

MerddinEmrys liked a comment+100 XP

1mo ago

Laravel From Scratch (2026 Edition): Ep 25, Tailwind Theme Setup And Initial UI

Color theme for those looking to copy:

    --color-background: oklch(0.12 0 0);
    --color-foreground: oklch(0.95 0 0);
    --color-card: oklch(0.16 0 0);
    --color-primary: oklch(0.65 0.15 160);
    --color-primary-foreground: oklch(0.12 0 0);
    --color-border: oklch(0.24 0 0);
    --color-input: oklch(0.24 0 0);
    --color-muted-foreground: oklch(0.6 0 0);
MerddinEmrys's avatar

MerddinEmrys wrote a comment+100 XP

3mos ago

Laravel From Scratch (2026 Edition): Ep 25, Tailwind Theme Setup And Initial UI

Here are the full CSS component files for those looking to copy:

resources/css/components/btn.css

resources/css/components/form.css