Member Since 3 Years Ago

Experience Points

3,150 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.

  • Community Pillar

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

Level 2
6,850 XP
2 weeks ago
Activity icon

Replied to Best Laravel Hosting Option

Using Intervention for the modifications / scaling / cropping functions.

Basically user uploads large image, keep the original and scale that image down 5 times using the previous scaled image to down size.

XL -> L -> M -> S -> XS

Activity icon

Replied to Best Laravel Hosting Option

I suppose also time lag could be attributed to the S3 upload and passed back to user, so image is adding extra milage on its journey

Activity icon

Replied to Best Laravel Hosting Option

@jlrdw Excellent point, I do have a spinner "one moment.... men @ work" type notification so user knows something is happening.

Probably I am trying to do much at once and refactor order of operations.

Activity icon

Replied to Best Laravel Hosting Option

@jlrdw very true indeed. Not going to get into to details about the code and such but basically user is expected to upload hi-quality images and the upload takes ~1-2 seconds based on a 3mb image, that image then gets resized down 5 times (using previous resized image) and thats taking ~12-15 seconds sometime and thats incredibly long (round trip from upload, processing and return images to front-end).

Hence the reason for the question. I tried dispatch a job to run it in the background after the fact but there are some cases on the site where each image is shown in 3 sizes after the upload so I can't really send it off to a job since its needed immediately. So i was looking for insight as to upping the CPU or the RAM which would be the go to option

Activity icon

Replied to Best Laravel Hosting Option

Thanks @snapey I currently have a decent dev setup 4 core / 8 RAM but just me simply testing the upload which makes 5 different sized images is rather slow. Code has been refactored over and over with different compression to none and still too slow for my liking. Fewer image manipulations makes things run faster but was hoping hardware could improve this process and just looking for insight from the community

Activity icon

Replied to Best Laravel Hosting Option

Thanks for your feedback, appreciate your time and insights

Activity icon

Replied to Best Laravel Hosting Option

Thanks for your feedback and time and i know there are unlimited cases that could come into play and endless options for theoretical uses of 10 user to 1 million users, and is the server Linux or Windows or AMD vs Intel and where are the users and whats their age and go on and on with endless if this or if that.

So make it simple and say an exam question => When selecting a server for a website thats will be heavy on graphic manipulation your best option would be to select:

A. General purpose use B. CPU-Optimized C. RAM-Optimized

Activity icon

Replied to Best Laravel Hosting Option

Thanks, I know that I can scale up, but scale up what? Should scale up RAM / CPU / Both?

Some sites say if your handling lots of image / batch manipulation its CPU demanding, other sites say its RAM intensive. I am looking for what the community has found in their experience on what works best for them and not some blog post about hyping up some VPS

Activity icon

Started a new Conversation Best Laravel Hosting Option

Not so much a question for help, more of a "what would you use or suggest" based on Laravel performing in this scenario.

Laravel is serving as a backend and basically a user will be uploading images, this will create various different sized images and also user will be cropping images which will also make 5 different sized versions. This will be the main use of the site and most taxing.

Question is what kind of server should one use? In regards specifically based towards DigitalOceans offerings. Go with a standard all around droplet? Would you want Shared / Dedicated or a CPU-Optimized or RAM-Optimized? What I am asking basically is when processing images / manipulation / re-size cropping is that process more CPU demanding or Memory demanding operation?

Thanks all.

Look forwards to hear your input!

3 months ago
Activity icon

Replied to Laravel API Security

Just a follow up.

Seems problem was the paths.

I set mine to

'paths' => ['v1/*'], //

    'allowed_methods' => ['GET, POST, PUT, PATCH, DELETE, OPTIONS'],

    'allowed_origins' => [env('APP_FRONTEND')], // beats changing this for dev / testing / production 
Activity icon

Replied to Laravel API Security

Adding in your suggestion blocks every request now.

cors.php // Using Laravel 7 fruitcake cors package

'paths' => ['*'],

    'allowed_methods' => ['GET, POST, PUT, PATCH, DELETE, OPTIONS'],

    'allowed_origins' => ['*'], //local testing currently

    'allowed_origins_patterns' => [],

    'allowed_headers' => [
    'exposed_headers' => [

    'max_age' => 0,

    'supports_credentials' => false,

Dev tools simply says CORS error InvalidAllowOriginValue

Request URL: Referrer Policy: strict-origin-when-cross-origin

Activity icon

Started a new Conversation Laravel API Security

I have a Laravel back-end API which is meant / intended for my website application to use. Its a public API in the sense that parts of the website will be accessing the API without login requirements.

So for example anyone can go to the site click"rates" and it will make the API call and return rates, in the sense its public / no auth needed since this part of the site is public.

But how can i prevent other people / sites from simply making the same request to that API endpoint and highjacking the data from my server for their use?

Basically I would like to API accept requests that only come from my website.

The secured API endpoints are protected when a user logs in and JWT's come into play.

3 months ago
Activity icon

Started a new Conversation Odd CORS Issues

I am building an image uploader. Pretty straight forward.

Odd thing that makes no sense is it only works maybe 10% of the time.

I can upload an image, repeat the process and next time I get CORS error => Cross Origin Resource sharing error: MissingAllowOriginHeader

I am simply testing with 3 images on both a server and localhost. Issue happens on both servers, using same images.

Frontend is a Vue app ( ) makes request to laravel backend ( )

Laravel has the CORS package => composer require barryvdh/laravel-cors

And config set like:

'supportsCredentials' => false,
    'allowedOrigins' => ['*'],
    'allowedHeaders' => ['*'],
    'allowedHeaders' => ['*'],
    'allowedMethods' => ['*'],
    'exposedHeaders' => ['*'],
    'maxAge' => 0,
    'hosts' => ['*']

This is frustrating since it works then it wont and I am not changing any code. Upload works, upload exact same image again it fails so I have no clue where to begin so any help, insight would be greatly appreciated.

Thanks all

3 months ago
Activity icon

Started a new Conversation Images And Sizes Database Structure

Just a question on what is best approach, not how to actually do the functionality.

Scenario: User uploads image and details are stored in "media" table ( path to S3, file details and such)

Now this image gets resized to various sizes (main, thumb, original) so the question is where to store these records?

Option / idea 1: Add a parent_id to media table so the resized / children records are stored in same table referencing the id as parent_id.

Option / idea 2: Create a new table "media_files" or some name which hold the resized images records and references back to media_id.

Both pretty much same idea but use 1 table or 2?

Side note, the media might be a morph since it could in theory hold users avatar, gallery images, videos, and so on so the table could be a universal storage table so I might have answered my own question since Scenario 1 seems more scalable.

But still I ask the community.

Thanks :)

3 months ago
Activity icon

Started a new Conversation Cache API Resource

I am wondering how can I use 'Cache::remember' on an API Resource?

My setup is pretty modular for the example of a users Profile in the sense that the Profile is made up of 10 - 15 separate Models

So basic idea is from UsersController:

public function show(Request $request, Profile $profile)
    return new PublicProfileResource($profile);

And the resource is:

$response = [
      'type' => 'bio',
      'attributes' => $attributes,
      'relationships' => [
        'rates' => new PublicRatesCollection($this->rate),
        'contact' => new PublicContactResource($this->contact),
        .... and 15 other as above making up the users complete profile

return $response;

Everything in terms of fetching the data and returning the resource is working, but since the profile is viewed about 1000:1 update it only makes sense to Cache the full PublicProfileResource($profile);

I thought to before passing $profile to the Resource to manually build a full complete $query, Cache the results then pass that to the Resoure but each individual query still gets executed when calling as above

So second attempt controller method looked like:

public function display(Request $request, Profile $profile){

	$key = $profile->slug . '_profile_cache';

	$data = Cache::remember($key, 60, function () use($request, $profile){
	   // getPublicProfile is a hardcoded query that already includes all the individual Models ( rates, contact and the other 15)
		return $profile->getPublicProfile($request, $profile);

    return new CachePublicProfileCollection($data);


But the problem, is the individual queries still get executed inside the Resource even when the data is cached and passed

        'rates' => new PublicRatesCollection($this->rate), // triggers a query yet the rate has been passed
        'contact' => new PublicContactResource($this->contact), // triggers a query yet the contact has been passed

Any ideas?

4 months ago
Activity icon

Replied to Add UUID To All Records

Yes that worked, now problem is saving fails!


My guess is because it has no id / primary key. Even though this works for all my other models with UUID as primary key in BaseModel:

	$model->{$model->getKeyName()} = (string)$model->generateNewId();
Activity icon

Replied to Add UUID To All Records

I will just do it direct with a SQL query.... much easier.

UPDATE profile_attribute SET id = UUID();
Activity icon

Replied to Add UUID To All Records

its a pivot table (currently working, as a request I now need to add the id to the existing table)

profile_id (CHAR36) attribute_id (CHAR36) question (VARCHARS) and timestamps

I am not running migration. ID added via mySQL workbench.

Its finding the ID col addition since its adding the UUID, problem is every ID is exactly the same

So basically i want to get all records and add a UUID to the ID col for each record.....

Activity icon

Started a new Conversation Add UUID To All Records

Not sure why this is not working. I need to add an id to existing pivot table. So there is currently no "id" column so I add that to the db.

I added "id" to the relations ->withPivot('id', 'question')

Now this set all id's to the same value

$records = ProfileAttributes::all();
	foreach($records as $record){
                $record->id = Uuid::uuid4();
} catch(Exception $e){

  // foreach ($records as $record) {
  //     $record->id = Uuid::uuid4();
  //     $record->save();
  // }

How can I simply add a column to the db and then run a function to set the id as a UUID?

Should not take hours of trying to sort this foolishness out......

Help please :)

4 months ago
Activity icon

Started a new Conversation Pivot Table Morph Issue

I have a "Reviewables" Trait that simply keeps track of items a user has updated / changed and then a moderator can review these changes for approval / dismiss type thing.

So basically the reviewable table saves a review_id (record in question to review) and review_type (what model is the record for)

All works fine as it stores the review_type as expected like so:

App\Models\Profile App\Models\Posts App\Models\Tasks and so on so thats all good and dandy until it hits a pivot table.

I have a areas_posts (yes it coded in the belongsToMany since it is not standard naming, and has additional fields of data) but anyways when it saves a Reviewable the review_type is => Illuminate\Database\Eloquent\Relations\Pivot

It should be I would hope to be App\Models\Posts or App\Models\Areas so it could be tracked back to the correct record but Illuminate\Database\Eloquent\Relations\Pivot is of no use since it has no defining name to reference.

Code is realy of no use since it only shows the function used to save a "reviewable" but perhaps might be of some use:

Reviewable::new($record->area_id, $record, $profile->id, $note = null);

Reviewable::new($id of association, $record is full Model object, other referencing id if passed, $note = null);

Any ideas how to get the referencing model name as the rest?

4 months ago
Activity icon

Replied to Laravel 6 Image Validation Failure

Oddly enough it turns out my version is different.

On my v 6.0.4 some of the types are missing....

My source code looks like:

public function validateImage($attribute, $value)
        return $this->validateMimes($attribute, $value, ['jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']);

while original GitHub source has the 'jpg' type included

public function validateImage($attribute, $value)
        return $this->validateMimes($attribute, $value, ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']);

Good looking out!

Activity icon

Replied to Laravel 6 Image Validation Failure

For the sake of it this is the data / log of the info before the rules() in the formRequest

array (
  'media' => 
     'test' => false,
     'originalName' => '17033.jpg',
     'mimeType' => 'image/jpeg',
     'error' => 0,
     'hashName' => NULL,

The front-end completely separate and is working 100% on live site using laravel 5.8 API backend and its been running for 2 years with zero issues. Its only now after upgrading to 6.0 are the uploads no longer accepting the image rule. I upload the exact same image over and over, it will upload if i remove "image" from the rules, tells me its not an image when its added back in. Its clearly an image. The front-end has file validation in place also so if i select a pdf, doc, anything other than an image the upload will not process and will not even attempt to send the file to the server unless its a valid image format. Its only when image rule is left inplace does it now fail.

I will simply stick with mimes array and consider this closed because its rather foolish to investigate this any further

Activity icon

Replied to Laravel 6 Image Validation Failure

not using jQuery or anything like that, but still should not make any difference since if I remove image from the rules or skip the formRequest it works 100% and the 5.8 version works fine, 6.0 untouched fails so has noting to do with frontEnd since Laravel is simply an API backend so the data being sent has not changed, same format, same form sending the data so thats not the issue, but thanks all the same for your time

Activity icon

Replied to Laravel 6 Image Validation Failure

Correct on the redundancy fact, I was just wondering if there was a specific failure based on the code. Just because it is as you stated it redundant, but still so it worked unchanged in 5.8 then fails in 6.0 yet simply putting the redundancy fact aside and possibly being sloppy code, it should work. If I remove the mimes type it still tells me my jpg, or png is invalid and not an image.

return [
      'media' => [

Same error Is not an image.

Proper coding format:

return [
      'media' => 'required|image'

Same error still telling me my jpg image is not an image

Activity icon

Started a new Conversation Laravel 6 Image Validation Failure

I just recently upgraded an existing app to Laravel 6 and testing everything out and my image upload validation now fails.

Its currently working fine on live production site, zero changes to existing controller and formRequest but getting error => The media must be an image

I am uploading an image and the formRequest rules are:

public function rules()
    return [
      'media' => [

So it worked in 5.8 but fails in 6.0

If I simply by-pass the formRequest and skip that step the controller handles the upload with no errors so the upload functionality / saving / resizing all works fine.

Its simply when passing the request thru the formRequest it fails. If I remove "image" from rules array Laravel detects the file is or is not an specific mime type, size and dimensions but will fail if the image rule is added.

Any ideas?