bufferoverflow

bufferoverflow

Member Since 1 Year Ago

Experience Points
15,380
Total
Experience

4,620 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
128
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 4
15,380 XP
Jan
05
1 week ago
Activity icon

Awarded Best Reply on Spatie Sluggable - Unexpected 'SlugOptions'

Found it.

For some reason, after running valet use php, the command php -v was returning 7.4 but the phpinfo() I dumped showed that 7.3 was used.

I manually stoped 7.3 and valet started using 7.4. Error gone.

Activity icon

Replied to Spatie Sluggable - Unexpected 'SlugOptions'

Found it.

For some reason, after running valet use php, the command php -v was returning 7.4 but the phpinfo() I dumped showed that 7.3 was used.

I manually stoped 7.3 and valet started using 7.4. Error gone.

Activity icon

Started a new Conversation Spatie Sluggable - Unexpected 'SlugOptions'

I'm using the Laravel Sluggable package from Spatie. This is not the first the time i use this package and i did the same setup as always. The only thing that's different is that now i'm using php 7.4.

I can not understand why is the following returned. I'm surely defining and returning that variable and function.

syntax error, unexpected 'SlugOptions' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)

I implemented the HasSlug trait in my Page model:

<?php

namespace App\Models;

use Spatie\Sluggable\HasSlug;
use Spatie\Sluggable\SlugOptions;
use Illuminate\Database\Eloquent\Model;

class Page extends Model
{
    use HasSlug;

And defined the required abstract method:

    public function getSlugOptions() : SlugOptions
    {
        return SlugOptions::create()
            ->generateSlugsFrom('name')
            ->saveSlugsTo('slug')
            ->slugsShouldBeNoLongerThan(50);
    }

Seems like a php 7.4 related thing: github similar issue

But if I revert my php version to php 7.3, the package requires me 7.4:

    - spatie/laravel-sluggable 2.3.0 requires php ^7.4 -> your PHP version (7.3.12) does not satisfy that requirement.
Oct
09
3 months ago
Activity icon

Replied to Improve ->whereHas() Query Performance

For anyone having the same performance issue, i post here the solution i found in とも-san article.

// Old
public function scopeCategoryOld($query, $category)
{
    return $query->whereHas('categories', function ($q) use ($category) {
        $q->where('categories.id', $category);
    });
}
​
// New
public function scopeCategoryNew($query, $category)
{
    return $query->join('categorizables', 'providers.id', 'categorizables.categorizable_id')
                ->where('categorizables.category_id', $category)
                ->select('providers.*')
                ->distinct();
}

Basically its joining from the polymorph table and keeping the distinct records.

Oct
08
3 months ago
Activity icon

Replied to Improve ->whereHas() Query Performance

Its used in a many to many polymorph table, i think i can not do that

table: categorizables

id|category_id(not unique)|categorizable_id|categorizable_Type

Activity icon

Replied to Improve ->whereHas() Query Performance

I think i can not cache. I'm passing the ::query() for the Laravel DataTables package and I can not serialize the query.

    public function datatable(Category $category = null)
    {
        $query = isset($category)
            ? Provider::category($category->id)->with('categories.children', 'tags', 'distributors')
            : Provider::with('categories.children', 'tags', 'distributors');

        return DataTables::eloquent($query)

...
Activity icon

Started a new Conversation Improve ->whereHas() Query Performance

I have a scope for querying the models that have a relationship with the passed category id. This scope returns all the models that have that category or subcategory relation.

    public function scopeCategory($query, $category)
    {
        return $query->whereHas('categories', function ($q) use ($category) {
            $q->where('categories.id', $category)
                ->orWhere('categories.category_id', $category);
        });
    }

Its working, but its too slow. Any tips on improving this query permormance?

Aug
20
4 months ago
Activity icon

Started a new Conversation PHP Multiple Class Import In A Single Line Of Code

I saw it in one of the Laracasts videos but i can't find it anymore and i don't remember the correct syntax. Also i can not find it in php docs.

It was something like: use App\Models\(User, Team, Project);

Which is the correct syntax?

Jul
23
5 months ago
Activity icon

Started a new Conversation Embed Laravel App To Hybrid App

I have a Laravel website which I want my users to be able to download an "app" version from the Play Store (Android) and App Store (iOS).

My idea was to build a hybrid app with Cordova/Ionic or similar framework. I would like to make a native "intro/tutorial" view and then redirect to a "webview/iframe/embed version of my website" when the introduction is finished. Also, I will need the phone to receive push notifications.

Which technology/framework is more optimal to achieve this kind of development. I would like to avoid Angular/React. Is it viable to achieve it with a plain cordova app?