MichalOravec

MichalOravec

Member Since 4 Years Ago

Prievidza, Slovakia

Experience Points
644,180
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
956
Lessons
Completed
Best Reply Awards
918
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 50
644,180 XP
Oct
21
1 day ago
Activity icon

Replied to How To Filter Multidimensional Array

You have to set to the variable like

$filtered = $test->filter(function ($value) {
    return $value['TYPE'] == 'WORKSHOP';
});

And it $filtered you will have result.

Activity icon

Awarded Best Reply on Want To Return Tag Model At The End.

public function store(Request $request, $imageId)
{
    $image = Image::findOrFail($imageId);

    $request->validate([
        'tags' => 'bail|required|string'
    ]);

    $tags = $newCreatedTags = collect([]);

    foreach (explode(',', $request->tags) as $tag) {
        $model = Tag::firstOrCreate([
            'name' => $name = trim($tag),
            'slug' => Str::slug($name),
            'username' => auth()->user()->username
        ]);

        $tags->push($model);

        if ($model->wasRecentlyCreated) {
            $newCreatedTags->push($model);
        }
    }

    $image->tags()->attach($tags->pluck('id'));

    return $newCreatedTags;
}
Activity icon

Replied to Want To Return Tag Model At The End.

@automica Yeah I know, I edited it.

Activity icon

Replied to Want To Return Tag Model At The End.

public function store(Request $request, $imageId)
{
    $image = Image::findOrFail($imageId);

    $request->validate([
        'tags' => 'bail|required|string'
    ]);

    $tags = $newCreatedTags = collect([]);

    foreach (explode(',', $request->tags) as $tag) {
        $model = Tag::firstOrCreate([
            'name' => $name = trim($tag),
            'slug' => Str::slug($name),
            'username' => auth()->user()->username
        ]);

        $tags->push($model);

        if ($model->wasRecentlyCreated) {
            $newCreatedTags->push($model);
        }
    }

    $image->tags()->attach($tags->pluck('id'));

    return $newCreatedTags;
}
Activity icon

Replied to Pop Up Window + User Not Exist

No, it's opposite. If you don't have an user with email which you provided you get an error message.

So if the database is empty, you also get error message.

exists: The field under validation must exist on a given database table.

Activity icon

Replied to About $loop->iteration And Paginate

@sinnbeck Yes, but you've been it making it harder for me for the last last few months :D

Activity icon

Replied to Pop Up Window + User Not Exist

If the column option is not specified, the field name will be used.

So this is same

$this->validate($request, [
    'email' => 'required|email|exists:users',
    'password' => 'required|min:8'
]);  

as

$this->validate($request, [
    'email' => 'required|email|exists:users,email',
    'password' => 'required|min:8'
]);
Activity icon

Replied to About $loop->iteration And Paginate

@sinnbeck Yeah me to, but it's also good reference in CV :) And I want to be in TOP 3 :D

Activity icon

Replied to Pop Up Window + User Not Exist

Just display validation errors

You can add this to the blade

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

Or just use @error directive

@error('email')
    <div class="alert alert-danger">{{ $message }}</div>
@enderror

Docs: https://laravel.com/docs/8.x/validation#quick-displaying-the-validation-errors

Activity icon

Replied to About $loop->iteration And Paginate

@meglo Probably in the future there will be some rewards

Check this out.

Activity icon

Replied to About $loop->iteration And Paginate

When I saw reply by @sinnbeck I knew that is wrong, so I added my own reply but I really didn't know that something like that is in Laravel by default, what was provided by @rodrigo.pedra

Activity icon

Replied to About $loop->iteration And Paginate

@meglo Yeah you are really good in choosing a best reply...

The best reply is by @rodrigo.pedra

Activity icon

Replied to About $loop->iteration And Paginate

It has to be

<th scope="row">{{ ($attend->currentPage() - 1) * $attend->perPage() + $loop->iteration }}</th>

Docs: https://laravel.com/docs/8.x/pagination#paginator-instance-methods

Activity icon

Replied to Pop Up Window + User Not Exist

Just use exists validation rule for that

$this->validate($request, [
    'email' => 'required|email|exists:users',
    'password' => 'required|min:8'
]);  

Docs: https://laravel.com/docs/8.x/validation#rule-exists

Activity icon

Replied to Laravel Trying To Access Array Offset On Value Of Type Null

@mephisto In student model change relationship name to singlular form, because it is belongsTo relationship

public function adviser()
{
    return $this->belongsTo(Adviser::class);
}

In Adviser model don't use same prefix as model name in accessor, instead use for example full name

public function getFullNameAttribute()
{
    return "{$this->first_name} {$this->last_name}";
}

Then in blade it should be

{{ optional($student->adviser)->full_name }}

// or

{{ $student->adviser->full_name ?? '' }}
Activity icon

Replied to Want Add More Where Cluase

7644 views on this thread?! Who did refresh this thread too much?

I guess owner of thread. And the site fell down for a second.

Don't do that anymore.

Activity icon

Replied to Want Add More Where Cluase

Use whereIn if you want to check more values on same column.

$attendance_worker = Attendance_worker::where('attendance_id', $id)->whereIn('information', [
    'present', 
    'halfattend'
])->count();

Docs: https://laravel.com/docs/8.x/queries#where-clauses (look for whereIn)

Activity icon

Replied to Its About Count()

In controller

$absensiKaryawanCount = Absensi_karyawan::where('absensi_id', $id)->count();

In the blade

Total kehadiran : {{ $absensiKaryawanCount }}

By the way use just English everywhere.

Activity icon

Awarded Best Reply on Sort Desc

You have to use column name there, for example id

$list = WebPortfolio::orderByDesc('id')->get();
Activity icon

Replied to Sort Desc

You have to use column name there, for example id

$list = WebPortfolio::orderByDesc('id')->get();
Activity icon

Replied to Sort Desc

Use orderByDesc where you have to paste column name, or latest() which is ordered by created_at

public function web_portfolio()
{
    $list = WebPortfolio::orderByDesc('column_name')->get();

    // or 

    $list = WebPortfolio::latest()->get();

    $blogs = Blog::limit(3)->get();

    PageSeen::where('menu', 'Web Portfolio')->increment('view');

    return view('web_portfolio', compact('list', 'blogs'));
}

Docs: https://laravel.com/docs/8.x/queries#ordering-grouping-limit-and-offset

Activity icon

Awarded Best Reply on Laravel 8 Syntax Error?

No because it's the same as this

/**
 * Get the mockable class for the bound instance.
 *
 * @return string|null
 */
protected static function getMockableClass()
{
    $root = static::getFacadeRoot();

    if ($root) {
        return get_class($root);
    }
}

So it's a directly assigned variable in the if statement.

Oct
20
2 days ago
Activity icon

Replied to Laravel 8 Syntax Error?

No because it's the same as this

/**
 * Get the mockable class for the bound instance.
 *
 * @return string|null
 */
protected static function getMockableClass()
{
    $root = static::getFacadeRoot();

    if ($root) {
        return get_class($root);
    }
}

So it's a directly assigned variable in the if statement.

Activity icon

Awarded Best Reply on How To Check What Middlewares A Particular Route Has?

use Illuminate\Support\Facades\Route;

$middlewares = Route::getCurrentRoute()->middleware(); // it returns an array
Activity icon

Replied to How To Check What Middlewares A Particular Route Has?

@ravish Could you mark this thread as solved? Thanks.

Activity icon

Replied to Laravel 8 Forms Build Library

Use pure html for forms.

You probably meant https://github.com/laravelcollective/html

Activity icon

Awarded Best Reply on How To Check DifInMinute Between Two Timestamp?

So use createFromTimestamp to create a carbon instance.

abort_if(Carbon::createFromTimestamp($request->expires)->diffInMinutes(now()) > 2, 419);
Activity icon

Replied to How To Check DifInMinute Between Two Timestamp?

So use createFromTimestamp to create a carbon instance.

abort_if(Carbon::createFromTimestamp($request->expires)->diffInMinutes(now()) > 2, 419);
Activity icon

Replied to How To Check DifInMinute Between Two Timestamp?

now()->diffInMinutes(now()->copy()->addMinutes(2));

But with now() it will be everytime 2.

Activity icon

Replied to Search In Json Column With Laravel For Duplicate

So change it to back to array. It's a problem?

And you will need probably reorder keys in that json. And also save it with ordered keys in paramjson.

Activity icon

Replied to Search In Json Column With Laravel For Duplicate

If you want to check a whole json field then use classic where

->where('paramjson', $request->paramjson)

So

 $duplicateTasks = Task::where('name', $request->name)
    ->where('field', $request->field)
    ->where('paramjson', $request->paramjson)
    ->get();
Activity icon

Replied to Search In Json Column With Laravel For Duplicate

It has to be something like this

->whereJsonContains('paramjson->a', 'yes')

What do you have in $request['paramjson']?

Activity icon

Awarded Best Reply on Required_if Rule Not Showing Any Error.

Instead of required_if use required_with

'policyTitle1' => 'required_with:policyLink1|string'

Docs: https://laravel.com/docs/8.x/validation#rule-required-with

Activity icon

Replied to Required_if Rule Not Showing Any Error.

Instead of required_if use required_with

'policyTitle1' => 'required_with:policyLink1|string'

Docs: https://laravel.com/docs/8.x/validation#rule-required-with

Activity icon

Awarded Best Reply on Query With Where + Where Or + Where In Not Working

$teamIds = Team::where('options->stage', 'Subscribed')->pluck('id');

$documents = Document::where(function ($query) {
    $query->where('stage', '!=', 10)->orWhere('error', '!=', '');
})->whereIn('team_id', $teamIds)->get();
Activity icon

Replied to Query With Where + Where Or + Where In Not Working

$teamIds = Team::where('options->stage', 'Subscribed')->pluck('id');

$documents = Document::where(function ($query) {
    $query->where('stage', '!=', 10)->orWhere('error', '!=', '');
})->whereIn('team_id', $teamIds)->get();
Activity icon

Replied to Display The Results In A Table Format

Also show method of RoleController change to this

public function show($id)
{
    $role = Role::with(['permissions', 'users'])->findOrFail($id);

    return view('admin.roles.show', compact('role'));
}
Activity icon

Awarded Best Reply on Call To Undefined Relationship [booking_service] On Model [App\BookingEvent].

In BookService model it has to be bookingEvents and not bookingevents

public function bookingEvents()
{
    return $this->hasMany(BookingEvent::class);
}
Activity icon

Replied to Call To Undefined Relationship [booking_service] On Model [App\BookingEvent].

In BookService model it has to be bookingEvents and not bookingevents

public function bookingEvents()
{
    return $this->hasMany(BookingEvent::class);
}
Activity icon

Awarded Best Reply on Property [ ] Does Not Exist On This Collection Instance

With get() you get a collection.

$anggota = Anggota::with('hadiah')->get();

so it has to be

@foreach ($anggota as $something)
    @foreach ($something->hadiah as $ab)
        // 
    @endforeach
@endforeach

But if you retrieve just one item of anggota

$anggota = Anggota::first();

Then your code will work.

By the way use only English for variable names, model names etc. In the short in everything.

Oct
19
3 days ago
Activity icon

Replied to Property [ ] Does Not Exist On This Collection Instance

@meglo Did you solve it by yourself? I don't think so.

Activity icon

Awarded Best Reply on Configuration Of Routing With Guard In Laravel

Route::group(['middleware' => ['role:superadmin|admin|seller|telemarketer']], function () {
    //
});

or

Route::middleware(['role:superadmin|admin|seller|telemarketer'])->group(function () {
    //
});

Docs: https://spatie.be/docs/laravel-permission/v3/basic-usage/middleware#package-middleware

Activity icon

Replied to Property [ ] Does Not Exist On This Collection Instance

With get() you get a collection.

$anggota = Anggota::with('hadiah')->get();

so it has to be

@foreach ($anggota as $something)
    @foreach ($something->hadiah as $ab)
        // 
    @endforeach
@endforeach

But if you retrieve just one item of anggota

$anggota = Anggota::first();

Then your code will work.

By the way use only English for variable names, model names etc. In the short in everything.

Activity icon

Replied to Configuration Of Routing With Guard In Laravel

Route::group(['middleware' => ['role:superadmin|admin|seller|telemarketer']], function () {
    //
});

or

Route::middleware(['role:superadmin|admin|seller|telemarketer'])->group(function () {
    //
});

Docs: https://spatie.be/docs/laravel-permission/v3/basic-usage/middleware#package-middleware

Activity icon

Replied to How To Check What Middlewares A Particular Route Has?

use Illuminate\Support\Facades\Route;

$middlewares = Route::getCurrentRoute()->middleware(); // it returns an array
Activity icon

Awarded Best Reply on No Videos Playing...

Vimeo is down right now. So you have to just wait.

https://www.vimeostatus.com/

Activity icon

Replied to No Videos Playing...

Vimeo is down right now. So you have to just wait.

https://www.vimeostatus.com/

Activity icon

Replied to How To Add Background Image After @extends('layouts.app')

In layout

@hasSection('body-class')
    <body class="@yield('body-class')">
@else
    <body>
@endif

In the view

@extends('layouts.app')

@section('body-class', 'with-background')

@section('content')
    // your content
@endsecton

Personally I prefer this way.