sohrabsaboori

Member Since 1 Year Ago

Experience Points
6,360
Total
Experience

3,640 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
61
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.

  • Community Pillar

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

Level 2
6,360 XP
Feb
23
1 month ago
Activity icon

Started a new Conversation Alphine JS Missing Item When Paginating

I manipulated a table with livewire and use alpine js to get some info from the table. when I use @click, when press on paginate to the next page I got this error

Uncaught (in promise) DOMException: Failed to execute 'setAttribute' on 'Element': '@click' is not a valid attribute name.

I fixed this problem by using x-on:click instead of @click but now the problem is that for example, I have 100 items on page one when I log the key in alpine js state it works fine but when I paginate to page 2, although the code is changed correctly alpine still get the same index of page 1,(if I click on item 199 it shows item 99)

https://i.stack.imgur.com/JKCys.png https://i.stack.imgur.com/By5BX.png https://i.stack.imgur.com/QADbT.png https://i.stack.imgur.com/J5C71.png

Dec
15
3 months ago
Activity icon

Replied to How Paginate Result Of Http Response With Laravel Livewire

Solution: needs to convert to the collection and then using a macro to paginate over Collection

 public function render()
    {
        $this->response = Http::timeout(30)->get('http://127.0.0.1:8000/api/lines')->body();

        $collection = collect(json_decode($this->response));
        return view('livewire.line-index', ['lines' =>$collection->paginate(20)])->layout('layouts.app', ['header' => 'Line Management']);
    }
<?php

namespace App\Providers;

use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        /**
         * Paginate a standard Laravel Collection.
         *
         * @param int $perPage
         * @param int $total
         * @param int $page
         * @param string $pageName
         * @return array
         */
        Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page') {
            $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);

            return new LengthAwarePaginator(
                $this->forPage($page, $perPage),
                $total ?: $this->count(),
                $perPage,
                $page,
                [
                    'path' => LengthAwarePaginator::resolveCurrentPath(),
                    'pageName' => $pageName,
                ]
            );
        });
    }
}

reference:https://gist.github.com/simonhamp/549e8821946e2c40a617c85d2cf5af5e

Activity icon

Started a new Conversation How Paginate Result Of Http Response With Laravel Livewire

Hi I want to populate a table by calling an HTTP request and fetch a JSON fine, I set up live wire like this which can properly populate the table:

  public function render()
    {
        $this->response = Http::timeout(30)->get('http://127.0.0.1:8000/api/lines')->body();


        return view('livewire.line-index', ['lines' =>json_decode($this->response)->paginate(25)])->layout('layouts.app', ['header' => 'Line Management']);
    }

but when I add paginate like this:

  public function render()
    {
        $this->response = Http::timeout(30)->get('http://127.0.0.1:8000/api/lines')->body();


        return view('livewire.line-index', ['lines' =>json_decode($this->response)->paginate(25)])->layout('layouts.app', ['header' => 'Line Management']);
    }

I see this error:

Error
Call to a member function paginate() on array

and Idea how can I fix it?