wwweston

wwweston

Member Since 9 Months Ago

Experience Points 80
Experience Level 1

4,920 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-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.

11 Dec
8 months ago

wwweston left a reply on ResourceCollection Throwing An 'Undefined Property ($map) Error'

I can't find a DELETE QUESTION action... Sorry, but I found the problem. I was attempting to use the ResourceCollection::collection($collection) (like with a singular resource) static call, when it should have been new ResourceCollection($collection).

Sorry- if anyone knows how to remove your own questions, I'd like to delete this.

wwweston started a new conversation ResourceCollection Throwing An 'Undefined Property ($map) Error'

I'm pretty new to the Resources stuff... I'm getting an Undefined property: Illuminate\Database\Query\Builder::$map error thrown when I try to implement this collection resource...

I read: https://laracasts.com/discuss/channels/eloquent/undefined-property-illuminatedatabasequerybuildermap

But this doesn't seem to apply to me, as I can confirm that $this->leads is in fact a collection.

I'm attempting to Nest a collection inside a singular resource class...

/* JSON Resource*/

class FormResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  33
     * @return array
     */
    public function toArray($request)
    {
        return [
            'relationships' => [
                'owner' => new User($this->owner),
                'leads' => Leads::collection($this->leads), /* CULPRIT */
            ],
            'attributes' => parent::toArray($request)
        ];
    }

}


/* Here's the Resource Collection */


class Leads extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return parent::toArray($request);
    }

I'm sure I'm doing something wrong, just can't figure what it is. I seem to be following the specs in the docs: https://laravel.com/docs/5.7/eloquent-resources

Here's the full Error/Stack: https://paste.laravel.io/56f4d01b-e349-49bd-81ea-7075ecd94c40

23 Oct
9 months ago

wwweston left a reply on Prevent SQL Injection In DB:raw

Hey @pascal83 - I just joined the site recently. I know this is an old post. But I thought I'd help you re-write that DB::raw query using DB::select (with bindings). So, similar to using something like $modelQueryBuilder->where($x, $y)->setBindings((array) $dataBindings)->get();. Your query would look a little like this;


$sql_statement =
"SELECT
       Users.name,
       profiles.cities,
       profiles.firstlanguage,
       ATAN2(
            SQRT(
                POW(
                    COS(
                        RADIANS(:session_lat))
                        * SIN(RADIANS(Y(gm_coor) - :session_lng)), 2)
                        + POW(COS(RADIANS(X(gm_coor)))
                        * SIN(RADIANS(:session_lat))
                        - SIN(RADIANS(X(gm_coor)))
                        * COS(RADIANS(:session_lat))
                        * COS(RADIANS(Y(gm_coor) - :session_lng)), 2)),
                        (SIN(RADIANS(X(gm_coor)))
                        * SIN(RADIANS(:session_lat))
                        + COS(RADIANS(X(gm_coor)))
                        * COS(RADIANS(:session_lat))
                        * COS(RADIANS(Y(gm_coor)
                        - :session_lng))))
                        * 6372.795 AS distance
        from
            Users
        inner join
            Profiles
        on
            Users.id = Profiles.userid
        where
            Profiles.Active = 1
         and
            Profiles.firstlanguage = :firstlanguage
      HAVING
            distance < 250
    order by
            users.id desc,
            distance asc
       limit
            10";

$profiles = DB::select($sql_statement, [
    'session_lng'  => Session('lng'),
    'session_lat'  => Session('lat'),
    'firstlanuage' => $firstlanguage,
]);```