Daxsis

Daxsis

Member Since 1 Year Ago

Experience Points
12,310
Total
Experience

2,690 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
121
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • 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.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    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
12,310 XP
Mar
15
3 weeks ago
Activity icon

Replied to Laravel 7 Cors Fails To Clear Cached

Actually @tray2 was correct. I was able to clear cache, but laragon was setting its own headers and messing up with laravel cors handling.

Activity icon

Started a new Conversation Laravel 7 Cors Fails To Clear Cached

Environment:

  • Laravel 7 latest
  • Laragon latest
  • Windows 10
  • Composer latest
  • PHP 7.4.3

cors.php

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

    'allowed_methods' => ['*'],

    'allowed_origins' => ['*'],

    'allowed_origins_patterns' => [],

    'allowed_headers' => ['*'],

    'exposed_headers' => false,

    'max_age' => false,

    'supports_credentials' => false,

Executed

php artisan clear-compiled
php artisan optimize:clear
php artisan cache:clear
php artisan config:clear
php artisan route:clear

I know it is repetitive, however I still get

Access to fetch at 'http://laravel.test/api/test' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, http://localhost:3000', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I was just testing all possibilities.

Restarted Laragon a few times between a few tests. Cleared bootstrap\cache\*.php

Even if I put just 'http://localhost:3000' into allowed origins, still the same answer. I'm kinda lost.

The most absurd thing is that laravel returns 204 https://gyazo.com/599991eb02ebdfbfcb57ed5a7d3c1a03

In advance thank you for the answers.

Mar
01
1 month ago
Activity icon

Started a new Conversation Cannot Reload After Save HasOne Relationship Both Ways

Is it possible to have a relationship hasOne() both ways on different models and reload them after the model Order has been saved?

For example: Purchaser:

    public function order()
    {
        return $this->hasOne(Order::class);
    }

Order

    public function purchaser()
    {
        return $this->hasOne(Purchaser::class);
    }

The idea is to have ids on both tables for reference. I have primary keys on both tables.

However if I $order->save() the relationships are gone. When I try $order->fresh([...relationships..]); I got null on every relation.

Even if I try to fetch it again it returns null

Order::where('id', $order->id)->with([
            'purchaser',
        ])->get();

I'm processing a payment in DB transaction to create save and then fetch again before the commit has been done. it might affect stuff because I tried all the options I know in Tinker and it returned loaded relations.

Feb
24
1 month ago
Activity icon

Replied to Model Select From Json Column Returns `json_unquote..`

It works!

>>> App\Activity::where('id', 1)->get(['id', 'name->en as name'])
=> Illuminate\Database\Eloquent\Collection {#3033
     all: [
       App\Activity{#3027
         id: 1,
         name: "46939egi4",
       },
     ],
   }

Can you explain why native doesn't solve it and I have to use alias?

Activity icon

Replied to Model Select From Json Column Returns `json_unquote..`

Sadly the same

>>> App\Activity::where('id', 1)->get('name->en')
=> Illuminate\Database\Eloquent\Collection {#3031
     all: [
       App\Activity {#3034
         json_unquote(json_extract(`name`, '$."en"')): "46939egi4",
       },
     ],
   }
Activity icon

Replied to Model Select From Json Column Returns `json_unquote..`

I'm using MySql 8.0.19 in Laragon, which I suppose has to be compatible with field->key notation :)

This is an example of the data in the table

>>> App\Activity::find(16)
=> App\Activity {#3028
     id: 16,
     name: "{"en": "8844ge32v"}",
     description: "{"en": "Rem necessitatibus aut perferendis commodi laborum ullam ut. Illum cumque itaque vel magnam perspiciatis vel alias."}",
     product: "{"en": "Et eum doloribus facere rerum rerum perferendis itaque. Omnis sequi animi perferendis atque. Est magni tempore eum deleniti eligendi. Quas repellat sit ab reprehenderit nobis aspernatur quis."}",
     updated_by: null,
     created_at: "2020-02-23 21:11:06",
     updated_at: "2020-02-23 21:11:06",
   }
Activity icon

Replied to Model Select From Json Column Returns `json_unquote..`

>>> App\Experience::whereIn('id', [16,25,50])->select('id', 'name->>en as name')->get();
=> Illuminate\Database\Eloquent\Collection {#3028
     all: [
       App\Experience {#3027
         id: 16,
         name: null,
       },
       App\Experience {#3026
         id: 25,
         name: null,
       },
       App\Experience {#3025
         id: 50,
         name: null,
       },
     ],
   }

weird :)

Activity icon

Replied to Model Select From Json Column Returns `json_unquote..`

Tried, the same. Just in case PHP 7.2.19

>>> App\Experience::whereIn('id', [16,25,50])->get(['id', 'name->>en'])
=> Illuminate\Database\Eloquent\Collection {#3019
     all: [
       App\Experience {#3040
         id: 16,
         json_unquote(json_extract(`name`, '$.">en"')): null,
       },
       App\Experience {#3039
         id: 25,
         json_unquote(json_extract(`name`, '$.">en"')): null,
       },
       App\Experience {#3038
         id: 50,
         json_unquote(json_extract(`name`, '$.">en"')): null,
       },
     ],
   }
Activity icon

Started a new Conversation Model Select From Json Column Returns `json_unquote..`

Hello everybody, long time lurker and found some awesome answers, however this time I encountered what seems unusual problem. My setup: Laravel 6.16 Mysql 8.0.19

I have an Activity table and model with json column name and when I try to query it I get this

>>> App\Activity::whereIn('id', [16,25,50])->get(['id', 'name->en'])
=> Illuminate\Database\Eloquent\Collection {#3034
     all: [
       App\Activity {#3035
         id: 16,
         json_unquote(json_extract(`name`, '$."en"')): "8844ge32v",
       },
       App\Activity {#3036
         id: 25,
         json_unquote(json_extract(`name`, '$."en"')): "21972qf55",
       },
       App\Activity {#3037
         id: 50,
         json_unquote(json_extract(`name`, '$."en"')): "700z48306",
       },
     ],
   }