Member Since 3 Years Ago

Hertfordshire / London

Experience Points

3,910 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
Best Reply Awards
Best Reply
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.


    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.


    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 3
11,090 XP
2 months ago
Activity icon

Started a new Conversation Cannot Get <details> <summary> In Laracasts Discussion

I cannot seem to get <details><summary> markdown blocks working in the Laracast's Discussion markdown. As seen here:

It would be really useful to hide massive stack traces / logs / code blocks and keep the attention on the issue.

Am I doing it wrong, or is it not supported?

Activity icon

Replied to ErrorException Stream_copy_to_stream(): Read Of 8192 Bytes Failed With Errno=21 Is A Directory

I have tried uploading the file locally ( Windows 10 / PHP 7.4 / Nginx ) and it works.

Therefore it's relevant that the server this is happening on is a Laravel Forge provisioned DO droplet.

I also tried using a new random test image from unsplash and it works on the production server. So there is something about this jpg on this server.

Also, I'd suggest this is better placed in Servers discussion.

2 months ago
Activity icon

Replied to Fread(): Read Of 8192 Bytes Failed With Errno=21 Is A Directory

Did you fix this? I'm experiencing the same issue.

Activity icon

Replied to ErrorException Stream_copy_to_stream(): Read Of 8192 Bytes Failed With Errno=21 Is A Directory

I'm here with the same question, so I'll reply with my answers. This is actually a Statamic V3 site I am running.

  • Not sure when I last updated.
  • Here my stack trace from /storage/logs/laravel.log:
[2020-06-23 18:53:13] production.ERROR: stream_copy_to_stream(): read of 8192 bytes failed with errno=21 Is a directory {"userId":"c09ea867-24cf-4dee-854b-ad0a273d3c40","exception":"[object] (ErrorException(code: 0): stream_copy_to_stream(): read of 8192 bytes failed with errno=21 Is a directory at /home/forge/
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /home/forge/ stream_copy_to_stream()
#2 /home/forge/ League\Flysystem\Adapter\Local->writeStream()
#3 /home/forge/ League\Flysystem\Filesystem->putStream()
#4 /home/forge/ Illuminate\Filesystem\FilesystemAdapter->put()
#5 /home/forge/ Statamic\Filesystem\AbstractAdapter->put()
#6 /home/forge/ Statamic\Assets\Asset->upload()
#7 [internal function]: Statamic\Http\Controllers\CP\Assets\AssetsController->store()
#8 /home/forge/ call_user_func_array()
#9 /home/forge/ Illuminate\Routing\Controller->callAction()
#10 /home/forge/ Illuminate\Routing\ControllerDispatcher->dispatch()
#11 /home/forge/ Illuminate\Routing\Route->runController()
#12 /home/forge/ Illuminate\Routing\Route->run()
#13 /home/forge/ Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#14 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#15 /home/forge/ Statamic\Http\Middleware\CP\Localize->handle()
#16 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#17 /home/forge/ Statamic\Http\Middleware\CP\Authorize->handle()
#18 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#19 /home/forge/ Illuminate\Routing\Middleware\SubstituteBindings->handle()
#20 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#21 /home/forge/ Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
#22 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#23 /home/forge/ Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#24 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#25 /home/forge/ Illuminate\Session\Middleware\StartSession->handle()
#26 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#27 /home/forge/ Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#28 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#29 /home/forge/ Illuminate\Cookie\Middleware\EncryptCookies->handle()
#30 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#31 /home/forge/ Statamic\Http\Middleware\SwapExceptionHandler->handle()
#32 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#33 /home/forge/ Illuminate\Pipeline\Pipeline->then()
#34 /home/forge/ Illuminate\Routing\Router->runRouteWithinStack()
#35 /home/forge/ Illuminate\Routing\Router->runRoute()
#36 /home/forge/ Illuminate\Routing\Router->dispatchToRoute()
#37 /home/forge/ Illuminate\Routing\Router->dispatch()
#38 /home/forge/ Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#39 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#40 /home/forge/ Statamic\Http\Middleware\PoweredByHeader->handle()
#41 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#42 /home/forge/ Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()
#43 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#44 /home/forge/ Fideloper\Proxy\TrustProxies->handle()
#45 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#46 /home/forge/ Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#47 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#48 /home/forge/ Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#49 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#50 /home/forge/ Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
#51 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#52 /home/forge/ Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#53 /home/forge/ Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#54 /home/forge/ Illuminate\Pipeline\Pipeline->then()
#55 /home/forge/ Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#56 /home/forge/ Illuminate\Foundation\Http\Kernel->handle()
#57 {main}
  • Is set to stack, but not used.
  • Not changed anything in that class.
3 months ago
Activity icon

Replied to Relationship Or Column?

@bugsysha I should have actually asked how do I run a query on the column when the data is stored as a cast?

If I understand properly you are proposing that I should to cast the column value as a json string like:

{"handle":"denim_blue","name":"Denim Blue"}

Then if I want to query that column, I do something like this?

$denimBlueProducts = Products::where('colour->handle', 'denim_blue')->get();


Then to access the property I can do:

{{ $denimBlueProducts->first()->colour->name }}

Am I on the right track here?

Activity icon

Replied to Relationship Or Column?

Wow 🤯 that video is really useful, thanks. I just wonder how that will affect query performance. But I'll have a proper look into it.

Activity icon

Replied to Relationship Or Column?

@bugsysha So what you're saying is that I could use a column on the products table then make an accessor for the value?


// Product.php
public function getColourAttribute($value)
    // $value = 'denim_blue';
    return ucwords(str_replace('_', ' ', $value); // "Denim Blue"
Activity icon

Replied to Relationship Or Column?

Thanks both, I am going to try the @martinbean way and see how I get on.

To confirm I would have a pivot that looks like this:

Schema::create('product_product_attribute', function (Blueprint $table) {
    $table->string('value'); // "denim_blue"
    $table->string('name'); // "Denim Blue"
    $table->primary(['product_id', 'product_attribute_id'], 'product_product_attribute');
Activity icon

Started a new Conversation Relationship Or Column?

I have a Product model with any number of attributes. Each product has one of each of these attributes. E.g. such as colour, size, gender, and say plus 8-10 more.

Can people tell me what seems more logical out of the following options:

Option 1 Eloquent relationship per attribute, e.g. models for every attribute: Colour, Size

Option 2 Use a column on the same table with snake cased value. Then use some sort of lookup array to get the human readable name per snake_cased attribute.

Option 3 An eloquent ProductAttribute which allow multiple attributes per product.

Option 1 seems like a lot of tables. Option 2 seems hacky. Option 3 seems convoluted and might cause unnecessarily slow queries.

Any opinions / best practices for this seemingly common situation?

3 months ago
Activity icon

Replied to Refactor Saving Many To Many Relationship

Thank you @michaloravec that's perfect.

Activity icon

Started a new Conversation Refactor Saving Many To Many Relationship

I know this can be refactored into something beautiful but don't have enough skill to know how to do it.

Would someone be able to help me get this code block looking a bit shorter and more readable?

    // [email protected]

    // $request->get('services') :
    // "services" = [
    //   "service_handle",
    //   "another_service_handle"
    // ]

    $serviceIds = [];
    if ($request->has('services')) {
      foreach ($request->get('services') as $maybeNewService) {
        $existingService = Service::where('handle', $maybeNewService)->first();
        if ($existingService) {
          $serviceIds[] = $existingService->id;
        } else {
          $newService = Service::create([
            'handle' => $maybeNewService,
            'name' => ucwords(str_ireplace('_', ' ', $maybeNewService)),
          $serviceIds[] = $newService->id;