Member Since 1 Year Ago

Experience Points

1,000 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
Best Reply Awards
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    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.

Level 4
19,000 XP
8 hours ago
Activity icon

Replied to Php Function Argument Passing Error

The error says Notice: Undefined variable: person while you have a variable called $persons (plural) in your code snippet. Check your syntax.

Activity icon

Replied to Nested Collection SortBy Is Reverted By ToArray

Have you tried doing what sortBy docs suggest? E.g.

$category->children = $category->children->sortBy('question_id')->values()->all();
Activity icon

Replied to Access Vue Component From External Js (from Blade)

You could make it nicer by wrapping the table into a component which allows you to communicate between components using events.

Activity icon

Replied to Horizon Jobs: Trying To Get Property Of Non-object

It appears that a relationship with Team is not loaded when it is supplied to your job. You can load it manually though with:

Activity icon

Replied to Default Authentication In Google API

If you're planning to use OAuth for user authentication then you have to go through it at least once to obtain a token. However, there are other options you can explore to avoid it. For example, you can create an OAuth service account and retrieve your lectures from Google Drive. Check out Google's documentation on using OAuth with service accounts.

1 day ago
Activity icon

Replied to Session Using The Database Driver

When using database driver for session storage all data is serialized using serialize() function and is stored base64-encoded in a single field payload.

Activity icon

Replied to Why Timestamps Are Not Used In Jobs Table?

Because Queue is designed to be used with different backend drivers it doesn't use storage-specific types but rather more abstract timestamps. Therefore it's an unsigned integer. Take a look at Queue class that DatabaseQueue extends and specifically the use of InteractsWithTime trait.

Activity icon

Replied to Example For "assertJsonMissing" ?

$request->assertJsonMissing(['name' => 'MISSING']);
Activity icon

Replied to How To Record Paypal Transaction?

The easiest way would be to create a webhook which gonna POST successful transaction data to your website where you can record the details you need.

Activity icon

Replied to Which Debit Card Work Perfectly With Laracast Subscription?

Any payment card capable of internet payments would do. It has to have a 16-digit number (this may differ in some countries), expiration date in form of the 2-digit month and 2-digit year, 3-digit CVV code on the back and your name on the front.

Activity icon

Replied to Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row

Both values in product_bundle_product_id and product_bundle_product_attribute_id have to have an ID of existing records in tables they reference.

Activity icon

Replied to Middleware - Terminate Method Not Called

Have a closer look at the documentation. It's described what exactly happens when terminate() method is called.

You don't see any output from dd() because it is ran after the response was sent to the browser.

Activity icon

Replied to Telescope Log Guzzle Outgoing Requests

I used this package to do the same with DebugBar. You can look into how it's done and come up with something similar for Telescope. I think many would find this kind of plugin useful.

Activity icon

Replied to 404 Routes Problem Laravel

You need to configure your webserver to route all requests to public/index.php. Otherwise routing will not work. There are instructions available on how to do that in Laravel documentation.

Activity icon

Replied to Use Uuid In Urls Instead Of Id

Primary key is there to enable you to easily identify a single record. You can use UUID additionally to an auto-incremental primary key as long as it doesn't create confusion to you or your teammates, however I would recommend choosing one, not both.

There are some packages around that add UUID support with a single line of code, however you might want to have a look on hashids. They are easy to integrate as well and will provide you with a useful alternative to putting primary keys in URLs. Check them out!

Activity icon

Replied to Explain The Way Please From Increments To ModifyIncrement

I guess this exists for the case when you want to modify your existing field in a table to be auto-incremental. I doubt that someone would use this but it's likely there to make Blueprint feature-complete.

Activity icon

Replied to Get Active(logged) Users List Laravel

There are many ways to achieve that depending on your application, for example:

  • Check active sessions
  • Listen for Login/Logout events and maintain a count in Cache or other types of storage
  • Utilize presence channels with Echo, etc.
1 week ago
Activity icon

Replied to Change @guest And @auth Actions After Changing Authentification Method

@pierre4854 Try to replace the word jwt-token with password and see if it makes sense. Say you have a form with a password field and by submitting the form you want to authenticate users. So it won't be enough if you just checked that a user simply fills out the password field. You probably would like to compare their input with a password stored elsewhere and only give access if they matched. The same goes for JWT token really.

Activity icon

Replied to Factories

The factory is used to define how a Model is created and the seeder is the way of creating models using factories. You can run the command php artisan db:seed --class:ProductTableSeeder to execute a specific seeder. Your code looks fine. The line in the seeder you're wondering about is for creating a Post model which is related to Product.

Activity icon

Replied to Best Way To Host API Routes And Client App On Same Domain

The easiest way I think would be to use subdomains, so your API is hosted on, for instance, with Forge while your website is on with Next. Another option would be to reverse proxy the API server. There's an example project that shows how to do it with Next specifically.

Activity icon

Replied to Testing Videos

They are usually located in tests folder. Usually, there would be also a phpunit.xml file in the root directory of the project which has test directories location set within <testsuites> section.

1 week ago
Activity icon

Replied to Which Open Source CMS Based On Laravel For A Web Agency Customization?

Check out Statamic. Based on Laravel it offers a powerful CMS feature set and is extensible through addons which can modify almost any aspect of the system.

Activity icon

Replied to How To Access And Manipulate JSON Array Elements

$json = request()->json();
$likes = $json['likes']['data'];
Activity icon

Replied to How To Implement API Of Google Classroom??

There is nice package that integrates Google Client library into Laravel. There are examples of usage in the readme file. Check it out.

Activity icon

Replied to Is It Possible To Search In Json Data?

Check out this part of Laravel documentation. Note that database server has to support this, so, say, MySQL version should be 5.7 and up.

1 week ago
Activity icon

Replied to Laravel Through Error When Using API Resources

I don't know what you do inside of UserCollection class, so can't really tell.

Activity icon

Replied to Change @guest And @auth Actions After Changing Authentification Method

You're checking for jwt-token key to be present in the session with your middleware but this is not enough to have proper authentication. Why don't you have a look at this sample project with the full setup for JWT?

Activity icon

Replied to Multiple Custom .js Files

Script tags are processed one after another, so in your case, adminapp.js won't be loaded before guestapp.js is done. There are additional attributes that change the way script tags are processed, you should read about that here, for instance.

Activity icon

Replied to What Is Your Vue Folder Structure Like?

Think of it like your bookshelf. It's ultimately up to you how you choose to put your books inside. You can group them by topic, you can categorize them by whether you finished reading them, etc. The same goes for the folder structure. You can put all components in a single folder but if there are too many of them maybe it makes more sense to group them by their function or your app's structure. You can start with the approach that Laravel has set by default and then modify it as you develop your app.

Activity icon

Replied to Laravel Through Error When Using API Resources

Here's a generic example:

$users = DB::table('users')->selectRaw('CONCAT(name, email) as foo')->paginate();
foreach ($users as $user) {
    dump($user); // This produces a stdClass
    dump(get_object_vars($user)); // This produces an array
Activity icon

Replied to Left Join With Distinct Query

Introducing GROUP_CONCAT() SQL function! :) Do the same query but put your campaign.code inside this thing and get PROFIT!

Because relational databases work with tables both for storage and display you have to think of your data like a table. So if you have a one-to-many relationship it has to be either displayed with a row of a parent for each child, so to say or as a single row with children put into one row, which GROUP_CONCAT does.

Activity icon

Replied to Saving An Array Of Data To Cache

The same way but by putting the array as a value. If you put two values under the same key the latter one will obviously overwrite the former.

Activity icon

Replied to Pass Variable From One Middleware To The Next

You can use Request as a transfer medium! Set a property on the Request and read it in the next middleware or controller.

Activity icon

Replied to Laravel Through Error When Using API Resources

When you're using DB facade to query the database you're not getting your data wrapped into a Model but rather delivered as stdClass. A quick fix would be to convert it to an array with get_object_vars().

The question is why do you switch to DB facade if you have a Model already?

Activity icon

Replied to Driver

This thing supports several authentication providers like Google, Facebook, etc. They all use OAuth2 but have different URLs for obtaining tokens, for instance. That's why each of them has a driver which reflects these differences. You're accessing this controller with a route like /auth/provider where the provider part is responsible for picking the right driver to perform the further redirect, token retrieval, etc.

1 week ago
Activity icon

Replied to Get Diffindays Split By Year

Like this:

$t1 = now();
$t2 = now()->addMonths(6);

if($t2->year > $t1->year) {
    $diff1 = $t1->diffInDays($t1->copy()->endOfYear());
    $diff2 = $t2->diffInDays($t2->copy()->startOfYear());
} else {
    $diff = $t1->diffInDays($t2);

Notice copy() call when calculating difference. This is to avoid changing the original date.

Activity icon

Replied to Get Smallest Price Of Category's Products Taking Into Account Products' Discount

@geowrge I would say the cleanest way would be to update a product when a discount for it is created. It's really just a few lines which will save you a lot of SQL work and in the end will look much cleaner.

Activity icon

Replied to Foreach Is Only Returning The First Value

@mykelcodex You're getting a collection, so the loop should work fine unless you are interrupting it. There are many other options to inspect variable contents: dump() or debug() if you're using DebugBar.

Activity icon

Replied to How To Append A Variable To A Model In Laravel

You could create a new relationship between Room and Room Price that has the cheapest price only. For example:

public function prices()
    return $this->hasMany(RoomPrice::class);

public function lowestPrice()
    return $this->hasOne(RoomPrice::class)->orderByPrice();

Activity icon

Replied to Get Smallest Price Of Category's Products Taking Into Account Products' Discount

The general direction would be to join Discounts table to Products picking up the biggest discount and then create a virtual field with the discount amount applied to the product's price, then get the lowest value of this field. You would need to do some raw SQL to achieve that. Another approach could be that you have a minimum price field in your Product model and update it every time a new discount is created (listening for the saved event, for instance). This way you could continue to use min() on this new field.

Activity icon

Replied to Foreach Is Only Returning The First Value

@mykelcodex I'm not familiar with Laravel Shopping Cart. Can you show me what dd(Cart::content()) produces?

Activity icon

Replied to Unable To Authenticate My Private Channel Using Redis And And X-CSRF-TOKEN

channel.php is the place where you would authenticate access to your private channel. To be able to listen to events you need to be able to connect to the channel first.

Activity icon

Replied to Foreach Is Only Returning The First Value

dd means dump and die, so your code stops executing after the first iteration. Try using dump() instead. It also dumps the content of a variable but doesn't stop the execution (so no die).

2 weeks ago
Activity icon

Replied to How To Get Upcoming Events In Laravel Eloquent

You could retrieve all events, paginate them and in the view add a specific markup that will distinguish between past and upcoming. You need to remove the starting date condition:

$events = Event::whereIn('id', $ids)->with('country')

Just a simple example of what can you do in the view:

    @foreach($events as $event)
    @if(!isset($upcomingStarted) && $event->ccStartingDate > now())
    @php $upcomingStarted = true; @endphp
    <li>{{ $event->title }}</li>

Of course, it's very dumb & simple but you gotta understand some fundamentals about the data and how is it represented in the view. There are no right and wrong ways strictly speaking and it's up to you want you gonna do eventually to represent you data.

2 weeks ago
Activity icon

Replied to How To Get Upcoming Events In Laravel Eloquent

The query you've posted will not get you past events as it filters them out. If you want both past and future events you need to distinguish them after you get them from the database. One way to do it would be to group a collection by date:

$events = Event::orderBy('eventdate')
->groupBy(function($event) {
    return $event->eventdate >= now() ? 'upcoming' : 'past';
1 month ago
Activity icon

Replied to Laravel And Thermal Printers

You can go with the route of printing a page from the browser as well. For termal printers, however, you'll need to carefully design a view that will produce a meaningful output on your particular printer model. This will probably require a bit of experimentation.

Activity icon

Replied to Sum With Group By Throws Error Function Month(timestamp Without Time Zone) Does Not Exist

It looks like you are using PostgreSQL which doesn't have MONTH() function like MySQL. Try date_part('month', created_at) instead.

Activity icon

Replied to Multiple Forms On Single Page Laravel.

Why do you think you need multiple forms for this? Just place all of these elements into a single form and process them in a single controller method. These two lists you have can be unrelated so you might think of them as two separate forms. But from the standpoint of your application, this is a single set of input elements that user has to fill in and submit therefore a single form will do.

Activity icon

Replied to Send Automatical Email After Save To Database

@martin_k Check out the link @tykus has linked above. It describes what you have to do to send e-mails from Laravel. Or check out this episode.