MichalOravec

Member Since 5 Years Ago

Bojnice, Slovakia

Experience Points
1,127,390
Total
Experience

0 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
1208
Lessons
Completed
Best Reply Awards
1656
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.

  • Community Pillar

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

Level 50
1,127,390 XP
Jun
14
11 hours ago
Activity icon

Awarded Best Reply on Add Active Class With Slug In Laravel

@foreach($categories as $category)
    <a href="{{ route('category', $category->slug) }}" 
        class="list-group-item list-group-item-action {{ route('category', $category->slug) == url()->current() ? 'active' : '' }}"
    >{{ $category->name }}</a>
@endforeach
Activity icon

Replied to Add Active Class With Slug In Laravel

@foreach($categories as $category)
    <a href="{{ route('category', $category->slug) }}" 
        class="list-group-item list-group-item-action {{ route('category', $category->slug) == url()->current() ? 'active' : '' }}"
    >{{ $category->name }}</a>
@endforeach
Activity icon

Replied to Call To Undefined Method StdClass::update()

You have to work with model and not with DB facade.

And I don't think it will faster.

Add index to created_at column.

Activity icon

Replied to Call To Undefined Method StdClass::update()

public function setCodeToEmptystring()
{
    DB::table('sometables')->where('created_at' '<=', today()->subDays(2)->toDateString())->update([
        'code' => ''
    ]);
}
Jun
13
1 day ago
Activity icon

Awarded Best Reply on Groping Users Comment By User_id Inside HasMany Relshionship

It's similar what I posted above

$article->comments->pluck('user')
    ->where('id', '<>', auth()->id())
    ->where('disable_article_notifications', false)
    ->unique()
    ->each
    ->notify(new NewCommentNotification($article));

Or you can use filter instead of where.

https://laravel.com/docs/8.x/collections#method-filter

Activity icon

Replied to Groping Users Comment By User_id Inside HasMany Relshionship

By the way I would change it to this, so no null column.

$table->boolean('disable_article_notifications')->default(false);

Even better in the opposite way

$table->boolean('enabled_article_notifications')->default(true);
Activity icon

Replied to Groping Users Comment By User_id Inside HasMany Relshionship

It's similar what I posted above

$article->comments->pluck('user')
    ->where('id', '<>', auth()->id())
    ->where('disable_article_notifications', false)
    ->unique()
    ->each
    ->notify(new NewCommentNotification($article));

Or you can use filter instead of where.

https://laravel.com/docs/8.x/collections#method-filter

Activity icon

Replied to I Have Error When Run Npm Install And Npm Run Dev

Remove node_modules folder and package-lock.json file and then run npm install.

Activity icon

Replied to Groping Users Comment By User_id Inside HasMany Relshionship

I have to show you your original query? If so

$article = Article::with('comments.user')->find($article_id);

$article->comments->pluck('user')->unique()->each->notify(new NewCommentNotification($article));
Activity icon

Replied to Groping Users Comment By User_id Inside HasMany Relshionship

$article->comments->pluck('user')->unique()->each->notify(new NewCommentNotification($article));

I guess you want exclude the current user as well so

$article->comments->pluck('user')
    ->where('id', '<>', auth()->id())
    ->unique()
    ->each
    ->notify(new NewCommentNotification($article));
Activity icon

Replied to Goutte Returns The Current Node List Is Empty.

Element with id ex-1-buy-price is not inside [data-coin] element.

<ul>
    <li class="exp-right-items" data-coin="usdt">
        <a aria-controls="usdt" data-toggle="tab" href="#usdt" role="tab">
            <!-- svg -->

            <span>تتر</span>
        </a>
    </li>
</ul>

id should be unique on the page so

$c = $client->request('GET', 'https://mihanblockchain.com/exchange-prices');

$result = $c->filter('#ex-1-buy-price')->text();
Jun
12
2 days ago
Activity icon

Awarded Best Reply on One To May Relationship Query

$items = Admin::select('id', 'first_name', 'last_name', 'uuid', 'email', 'employer_id')
	->with('employer:id,name')
    ->get();

Docs: https://laravel.com/docs/8.x/eloquent-relationships#eager-loading-specific-columns

When using this feature, you should always include the id column and any relevant foreign key columns in the list of columns you wish to retrieve.

Activity icon

Awarded Best Reply on Get A Relationship With Count When Using SetRelations Helpers

I don't understand why not like this

$product = Product::with(['photos', 'attributes'])
    ->withCount('reviews')
    ->findOrFail($id);

$reviews = $product->reviews()->paginate(3);

If you care about queries, then use cache

https://laravel.com/docs/8.x/cache

Activity icon

Replied to Get A Relationship With Count When Using SetRelations Helpers

I don't understand why not like this

$product = Product::with(['photos', 'attributes'])
    ->withCount('reviews')
    ->findOrFail($id);

$reviews = $product->reviews()->paginate(3);

If you care about queries, then use cache

https://laravel.com/docs/8.x/cache

Jun
11
3 days ago
Activity icon

Awarded Best Reply on When User DB::transaction Cant Return Object

return DB::transaction(function () use ($request) {
    // other code
 
    return new showUserResource($user);
});
Activity icon

Replied to One To May Relationship Query

$items = Admin::select('id', 'first_name', 'last_name', 'uuid', 'email', 'employer_id')
	->with('employer:id,name')
    ->get();

Docs: https://laravel.com/docs/8.x/eloquent-relationships#eager-loading-specific-columns

When using this feature, you should always include the id column and any relevant foreign key columns in the list of columns you wish to retrieve.

Activity icon

Replied to When User DB::transaction Cant Return Object

return DB::transaction(function () use ($request) {
    // other code
 
    return new showUserResource($user);
});
Activity icon

Awarded Best Reply on Help Generating An Array / Json Object

$items = [];

foreach ($this->basket->sku as $sku) {
    $items[] = [
        "name" => $sku->product->name,
        "description" => $sku->name,
        "sku" => $sku->sku,
        "unit_amount" => [
            "currency_code" => "GBP",
            "value" => $sku->price,
        ]
        "quantity" => $sku->pivot->quantity,
        "category" => "PHYSICAL_GOODS",
    ];
}

$payload['purchase_units'][0]['items'] = $items;

// or

data_set($payload, 'purchase_units.0.items', $items);

Docs: https://laravel.com/docs/8.x/helpers#method-data-set

Activity icon

Replied to Redirect After Email Verification

Do you have App\Http\Controllers\VerifyEmailController in your app?

Activity icon

Replied to Redirect After Email Verification

It's same process like for login response

$this->app->singleton(
    \Laravel\Fortify\Contracts\LoginResponse::class,
    \App\Http\Responses\LoginResponse::class
);

Here you have a list

https://github.com/laravel/fortify/tree/1.x/src/Contracts

So create your own VerifyEmailViewResponse

$this->app->singleton(
    \Laravel\Fortify\Contracts\VerifyEmailViewResponse::class,
    \App\Http\Responses\VerifyEmailViewResponse::class
);

or It's PasswordConfirmedResponse I don't know.

I've never used Fortify.

Activity icon

Replied to Help Generating An Array / Json Object

$items = [];

foreach ($this->basket->sku as $sku) {
    $items[] = [
        "name" => $sku->product->name,
        "description" => $sku->name,
        "sku" => $sku->sku,
        "unit_amount" => [
            "currency_code" => "GBP",
            "value" => $sku->price,
        ]
        "quantity" => $sku->pivot->quantity,
        "category" => "PHYSICAL_GOODS",
    ];
}

$payload['purchase_units'][0]['items'] = $items;

// or

data_set($payload, 'purchase_units.0.items', $items);

Docs: https://laravel.com/docs/8.x/helpers#method-data-set

Activity icon

Awarded Best Reply on Same URI Different Named Routes

Of course it's not possible, add prefix for your routes.

Routes work from top to bottom.

When you visit /dashboard you always get dashbord from RegistrarController.

Activity icon

Replied to Same URI Different Named Routes

Of course it's not possible, add prefix for your routes.

Routes work from top to bottom.

When you visit /dashboard you always get dashbord from RegistrarController.

Activity icon

Replied to Undefined Property: Illuminate\Database\MySqlConnection::$name

@bobdebower You have to use User model instead DB facade, if you want to use an accessor.

So instead this

 $users = DB::table('users')
    ->whereNull('db_name')
    ->limit(10)
    ->get();

use

 $users = User::whereNull('db_name')
    ->limit(10)
    ->get();
Activity icon

Awarded Best Reply on Laravel 8 Fortify Redirect Based On Roles Without Jetstream

In the provider it has to be

$this->app->singleton(
    \Laravel\Fortify\Contracts\LoginResponse::class,
    \App\Http\Responses\LoginResponse::class
);

and not

$this->app->singleton(
    \App\Http\Contracts\Contracts\LoginResponse::class, // this is wrong
    \App\Http\Responses\LoginResponse::class
);
Activity icon

Replied to Where Date Filter In Auth User Time Zone

Fix your github and twitter links on Laracasts profile.

Activity icon

Replied to Undefined Property: Illuminate\Database\MySqlConnection::$name

@automica This is the result when people don't read the documentation.

By the way $this->name in accessor :)

Activity icon

Replied to Too Few Arguments To Function Illuminate\Http\Request::has(), 0 Passed

I have seen many similar questions but most of the answers look complicated and does not seem to similar to my issues. Again, I am new in Laravel and would need the simplest form of explanation.

https://stackoverflow.com/questions/58568078/too-few-arguments-to-pass-to-a-function-in-laravel

I am new in Laravel

Sure with 3 years account, right?

Activity icon

Replied to Return The List Of Data Which Found And Not Found

Example by @automica

$collection = collect([1, 2, 3, 4, 5]);

$diff = $collection->diff([2, 4, 6, 8]);

$diff->all();

Your not working solution

$datacollection = collection($data);
 
$diff =$datacollection->diff($idsArray);

What is different?

Activity icon

Replied to Return The List Of Data Which Found And Not Found

@emfinanga Do you have something with your eyes?

Activity icon

Replied to Spatie Query Builder Ignores My With

Try to add select('table.*')

$availableIntegrations = QueryBuilder::for(AvailableIntegration::class)
    ->select('available_integration_category .*')
    ->join('available_integration_category', 'available_integrations.id', 'available_integration_category.available_integration_id')
    ->with(['categories''])
    ->paginate();

Note: I've never used spatie query builder.

Jun
10
4 days ago
Activity icon

Awarded Best Reply on How To Select Column In Relationship And Paginate?

$categories = Category::with(['subcategories:id,name,category_id', 'products:id,name,category_id'])
    ->orderBy($column, $order)
    ->paginate(10)
    ->onEachSide(1); 

Docs: https://laravel.com/docs/8.x/eloquent-relationships#eager-loading-specific-columns

When using this feature, you should always include the id column and any relevant foreign key columns in the list of columns you wish to retrieve.

Activity icon

Replied to Laravel 8 Fortify Redirect Based On Roles Without Jetstream

In the provider it has to be

$this->app->singleton(
    \Laravel\Fortify\Contracts\LoginResponse::class,
    \App\Http\Responses\LoginResponse::class
);

and not

$this->app->singleton(
    \App\Http\Contracts\Contracts\LoginResponse::class, // this is wrong
    \App\Http\Responses\LoginResponse::class
);
Activity icon

Replied to Laravel 8 Fortify Redirect Based On Roles Without Jetstream

Don't use intended. Just classic redirect to route or path.

Activity icon

Awarded Best Reply on How To Make Foreach For All Records Of Model

I always prefer o use collection

return Report::all()->map(function ($report) {
    return new CreateTurnover($report);
})->toArray();

or with arrow funtions

return Report::all()->map(fn ($report) => new CreateTurnover($report))->toArray();
Activity icon

Replied to How To Make Foreach For All Records Of Model

I always prefer o use collection

return Report::all()->map(function ($report) {
    return new CreateTurnover($report);
})->toArray();

or with arrow funtions

return Report::all()->map(fn ($report) => new CreateTurnover($report))->toArray();
Activity icon

Replied to Database: Query Builder

The same issue over the last month.

https://laracasts.com/@bobdebower

Activity icon

Replied to Filter By Parent Of Parent Relationship

whereHas is very slow, use join instead.

It depends how many rows you have in the tables, if a lot then definitely use join.

https://laravel.com/docs/8.x/queries#joins

Activity icon

Replied to Filter By Parent Of Parent Relationship

@amitshahc You want to get issues by project_id. If you know project id then you know project...

Community Pillar

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