Jacey

Jacey

Member Since 1 Year Ago

Experience Points 20,170
Experience Level 5

4,830 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 195
Lessons
Completed
Best Reply Awards 1
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.

09 Aug
1 month ago

Jacey left a reply on Eloquent Help...

But then I get an array. I would like a Collection.

Jacey started a new conversation Eloquent Help...

Does anybody know how to convert the following raw SQL into an eloquent query?

SELECT p.*
 , COALESCE(y.sold,0) sold
  FROM products p
LEFT
JOIN 
 ( SELECT product_id
        , SUM(quantity) sold 
     FROM order_items oi
     JOIN orders o
       ON o.id = oi.order_id 
      AND o.paid is not null 
    GROUP 
       BY product_id
 ) y 
ON y.product_id = p.id
 WHERE p.product_type_id = 1 
 AND DATE(p.visible_date) <= '2019-08-08 17:10:12' 
 AND p.active = 1 
 AND (p.end_date >= '2019-08-08 17:10:12' OR p.end_date IS NULL)
28 Apr
4 months ago

Jacey left a reply on Naming Convention For Models With Relationships

I think UserLoginHistory is redundant. Since only users will be logging in, LoginHistory is plenty descriptive. If you had a model named Photo and there was only one kind of photo, that would be enough. If not, maybe you need a UserPhoto and a ProductPhoto, etc, so the differentiation makes sense. But not with logins.

Applying that same logic, is there more than one Device? People might say that it's logical to assume that nobody but a user will have a device. You don't need a UserDevice, DogDevice, CupcakeDevice? If not, Device makes sense.

Personally, I try to keep my model names as short as possible without being confusing because I'm lazy and don't like to type any more than necessary. A UserLoginHistory now needs a UserLoginHistoryController and boy does that get long.

27 Apr
4 months ago

Jacey left a reply on Querying Relationship Existence

What are dispatches? Are they another model? Is it a colum in the same table?

Jacey left a reply on Default Register Route To Put Middleware. How To Do It

In App\Http\Controllers\Auth\RegisterController, modify the constructor:

Change

public function __construct() { $this->middleware('guest'); }

to

public function __construct() { $this->middleware('superadmin'); }

Jacey left a reply on Naming Convention For Models With Relationships

Convention would dictate that you call the first model User, not Users.

I think I would have just the one additional model, LoginHistory, would would have a table that includes the user_id, device they logged in with and the datetime of the login. It avoids the duplication of the datetime of the login that would be present in both tables if you had both a LoginHistory and a UserDevce.

Jacey started a new conversation Eloquent Relationships

Episodes 4 and 5 don't seem to be loading. I can see all others, but these two just keep spinning. Can anybody confirm?

Jacey left a reply on Laravel - How To Calculate The Sum Of Objects In An Array In Blade View

In MySQL, you can select an item or items and give them an alias. Let's say you have a column in your table called "subtotal" but you don't want to call it that once you start using the data in your views. Your query might look like, "SELECT subtotal FROM table as sub" and then you could start using order->sub in your views, for example. Well, MySQL can also perform calculations as part of the query. I have an "orders" table that has a subtotal column and a tax column, but no total column. When I want to grab all the data from the orders table and also have the total be a part of the Eloquent collection, I can write this query in my controller:

$orders = Order::where('user_id', $id)->selectRaw('*, subtotal + tax as total')->get()

This gets me every order associated with a given user with the total cost of the order too. So now I can do:

@foreach($orders as $order) {{ $order->total }} @endforeach

Maybe this is something that can help you.