shone83

shone83

Member Since 3 Years Ago

Kragujevac

Experience Points
2,810
Total
Experience

2,190 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
0
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 1
2,810 XP
Sep
13
1 month ago
Activity icon

Replied to Query Optimisation

Great, I reduce number of Models from 38340 to 1063 and queries from 60 to just 3. Page is loading much faster. Thanks @ismaile ;)

If you have some nice tutorial about optimization like this I would be grateful if you could send me link. Thanks.

Activity icon

Replied to Query Optimisation

If I do that, and change view like this:

                @if ($headquarters)
      
                  @foreach ($headquarters as $headquarter)

                    @if (($headquarter->members_count) > '0')
        
                        <tr>
                        <td>{{$headquarter->name}}</td>
                        <td>{{$headquarter->members_count}}</td>
                        <td>{{$headquarter->confirmed_members_count}}
                        ({{round(($headquarter->confirmed_members_count/$headquarter->members_count) * 100,1)}}%)</td>
                        <td>{{$headquarter->othercity_members_count}}
                        ({{round(($headquarter->othercity_members_count/$headquarter->members_count) * 100,1)}}%)</td>
                        </tr>

                    @endif
      
                  @endforeach
      
                @endif

I get

 (1/1) FatalThrowableError

Type error: Argument 1 passed to App\Http\Controllers\HeadquartersStatisticController::App\Http\Controllers\{closure}() must be an instance of App\Http\Controllers\Builder, instance of Illuminate\Database\Eloquent\Builder given, called in C:\xampp\htdocs\kapCMS\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php on line 955
Activity icon

Replied to Query Optimisation

I don't want page to have pagination. Even if I want to, still I have too many Models in debugbar, it is only divided by pages...

Activity icon

Started a new Conversation Query Optimisation

I'm trying to find a way to more optimize queries. I found that instead of $headquarters->members->count() > 0 in foreach loop in view much better is to add ->withCount('members') in controller and then $headquarter->members_count) > '0' in view.

What interest me is, how to do that if I have {{$headquarter->members->where('confirmed', '1')->count() in view in more that one line so I can't use that in controller first. Like this:

Controller:

        $headquarters = Capillary::where('town_id', Auth::user()->town_id)
            ->withCount('members')
            ->orderBy('members_count', 'desc')
            ->get();

View:

                  @foreach ($headquarters as $headquarter)

                    @if (($headquarter->members_count) > '0')
        
                        <tr>
                        <td>{{$headquarter->name}}</td>
                        <td>{{$headquarter->members_count}}</td>
                        <td>{{$headquarter->members->where('confirmed', '1')->count()}}
                        ({{round(($headquarter->members->where('confirmed', '1')->count()/$headquarter->members_count) * 100,1)}}%)</td>
                        <td>{{$headquarter->members->where('other_city', '!=', '')->count()}}
                        ({{round(($headquarter->members->where('other_city', '!=', '')->count()/$headquarter->members_count) * 100,1)}}%)</td>
                        </tr>

                    @endif
      
                  @endforeach

In this case, I have 38340 Models on that page. I use debugbar to inspect. So, what is the best practice for this?

Apr
25
5 months ago
Activity icon

Awarded Best Reply on When I'm Using Laravel Vue Pagination I Can Only Load First Page Of Relationship Table

I figured it out. I made new method along side index() where I use pagination called all_data:

public function allData()
{
    return Settlement::all();
}

then make new route along settlements apiResources route:

Route::apiResources(['settlement' => 'API\SettlementsController']);
Route::get('all_settlements', 'API\[email protected]');

and only then when I call loadSettlements function like this:

loadSettlements() {
  axios.get('api/all_settlements').then(({ data }) => (this.all_settlements = data));
},

all settlements is fetched ;)

I was using wrong logic in the beginning.

Activity icon

Replied to When I'm Using Laravel Vue Pagination I Can Only Load First Page Of Relationship Table

I figured it out. I made new method along side index() where I use pagination called all_data:

public function allData()
{
    return Settlement::all();
}

then make new route along settlements apiResources route:

Route::apiResources(['settlement' => 'API\SettlementsController']);
Route::get('all_settlements', 'API\[email protected]');

and only then when I call loadSettlements function like this:

loadSettlements() {
  axios.get('api/all_settlements').then(({ data }) => (this.all_settlements = data));
},

all settlements is fetched ;)

I was using wrong logic in the beginning.

Apr
22
5 months ago
Activity icon

Replied to When I'm Using Laravel Vue Pagination I Can Only Load First Page Of Relationship Table

Now I get settlements:Object (empty) and can't load table.

Before this was settlements:Array[10]

If I do this for example:

loadSettlements(page = 2) {
  axios.get('api/settlement?page=' + page).then(response => { this.settlements = response.data.data; });
},

I get page 2 just fine, but I don't need separate pages, I need all data from table.

Activity icon

Started a new Conversation When I'm Using Laravel Vue Pagination I Can Only Load First Page Of Relationship Table

I'm using gilbitron/laravel-vue-pagination and I can only fetch first page of relationship table as select or a list if that table is paginated, I can't fetch all data. In controller I return data like this:

public function index()
{
    return Settlement::with('town')->paginate(10);
}

and in Vue I fetch like this:

loadSettlements() {
  axios.get('api/settlement').then(response => { this.settlements = response.data.data; });
},

and I called this.loadSettlements();

I assumed that is another way to do in controller because I tried everything that I can find for fetching in Vue...