Member Since 1 Year Ago

Experience Points

3,770 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 1
1,230 XP
3 months ago
Activity icon

Replied to In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

You should change the data structure of you academic_year table: add a starts_at and ends_at column with the type of date.

Then you are able to reference by id (which will return an academic year) or find the correct ID with a query like:

$today = now();
$class->acc_year_id = AcademicYear::where('starts_at', '<', $today)->where('ends_at', '>', $today)->first();

You can even specify a scope on the AcademicYear model (at least, I assume you do have a model related to your academic_year table) which will accept the date and returns the correct AcademicYear.

If that's not what you want, fetch all the records from the academic_year table and give that to the view. Create a select element which foreaches trough all the academic_years and give it a value of the ID and show the acc_year as visual representation, something like this:

<select name="academic_year">
@foreach($academic_years as $year)
<option value="{{ $year->id }}">{{$year->acc_year}}</option>

Good luck!

7 months ago
Activity icon

Replied to Swap Class When Running Test?

@TALINON - Thank you, very much! I've got it working now. Only, I had this line:

$this->app->bind(TicketInterface::class, TicketAPI::class);

placed in my AppServiceProvider::register() method. WRONG! When testing and dd() the bookings() method on both of my Classes, it keep going to the TicketAPI::class, where I wanted the FakeTicket::class to be called. Then, I remembered something about the method priorities in a ServiceProvider and thought: well, maybe I should put it in the boot() method of my AppServiceProvider...

BINGO It worked! Thanks a lot, Talinon!

7 months ago
Activity icon

Replied to Swap Class When Running Test?

@TALINON - Yes, thanks! What I said, I tried before the way I described earlier, but not like you suggested. I will try your way tomorrow morning and will come back to you to let you know if it worked (and mark your answer as best...).

Activity icon

Replied to Swap Class When Running Test?

@TALINON - Yikes! Didn't saw your edit: that's... Brilliant. I tried similar, but without the resolve() in my model. Will try that again... I'll let you know!

Thanks in advance!

Activity icon

Replied to Swap Class When Running Test?

@TALINON - Thanks! I'll will try this! About the interfaces: both classes (TicketAPI and FakeTicket) implement a TicketGatewayInterface. That holds two functions:


namespace App\Tickets;

interface TicketGatewayInterface 
    public function bookings();

    public function notes();

When I tried to use the interface like this:

$connection = (new TicketGatewayInterface)->bookings($attributes);

It shouted something like "can't instantiate interface" etc. I tried putting it in the models constructor (which before that didn't exist) and then it threw an error that the constructor attributes expected 2 arguments and only one was given.

Then I lost it and reversed everything back from where I started and asked Laracast for a bright light! ;-)

Activity icon

Started a new conversation Swap Class When Running Test?

In my Laravel 5.7 I want to 'fake' an API endpoint of a service we use. I've created a 'Fake class' which acts as the API. In my models I whip up a new connection to the external API like this:

$connection = (new TicketAPI)->bookings($attributes);

This works, like a charm.

Now, I want to replace, or 'swap' the TicketAPI::class when I'm running tests. So, I thought I could use

$fakeTicket = new FakeTicket;
$this->app->instance(TicketAPI::class, $fakeTicket);

But it still reaches the TicketAPI::class. Is someone able to point me in the right direction, or am I trying to use the $this->app->instance() method in the complete wrong way? Is it even possible to swap classes like this?

7 months ago
Activity icon

Replied to How To Export Database Table To Excel File In Laravel

@konrms Glad to see you've fixed it! Happy exporting!

Activity icon

Replied to How To Export Database Table To Excel File In Laravel

Well, first of all, you're not returning anything in UsersController export() method. Try to find out the source. What happens if you dd(new UsersExport); in your export method? Does it initiate a new UsersExport class? And what happens if you dd((new UsersExport)->collection);? Does it return an Eloquent Collection with all users? And if nothing is working, just die('Export Method on UsersController called'); on the export method to literally see the methods fail...

Apparantly, the missing 'method="GET"' on your form is OK, because it reaches the UsersController, I suppose?

For what I can see now, it should work OK...

7 months ago
Activity icon

Replied to How To Export Database Table To Excel File In Laravel

Please be consistent with lower- and uppercase. Classnames should be CamelCase and thus have a Capital letter at the beginning. Fix that, make sure you've imported the (right) classes and try again.

7 months ago
Activity icon

Replied to How To Export Database Table To Excel File In Laravel

It looks like that your <form> doesn't provide the correct method to reach the controller. First of all, it looks like a simple GET request to me and it would be a normal link; no form required.

What happens when you type in the URL directly into the addresbar of your browser?

1 year ago
Activity icon

Replied to Organize Polymorphic BelongsTo Save

@D9705996 Alright! I've figured it out. Because I already have a polymorphic relation between each Locomotive::class, Carriage::class etc. to my MaintenanceOrder::class and did a bit of searching on Google, I found out about Explicit Model Binding.

In my RouteServiceProvider::boot method I declared every possible 'unit type', and in my routes/web.php I did it as well. Therefore I'm able to fetch the complete model in the MaintenanceOrder::create($unit) method.

It looks like this:


public function boot() {
    Route::model('locomotive', \App\Locomotive::class);


Route::get('maintenance/order/locomotive/{locomotive}', '[email protected]');

1 year ago
Activity icon

Replied to Organize Polymorphic BelongsTo Save

Holy, thanks for your time! And the great answer! I'm going to read it all again once more and I think I've found the right solution. Especially about the hint for extracting to a base class. As long as I'm able to work with one 'base model' like Locomotive, I'm able to rerun back to the maintenanceorders, one way or another.

I'll let you know what the results are! Thanks - a lot! Fresh eyes on this piece of magic is much appreciated!

Activity icon

Replied to Organize Polymorphic BelongsTo Save

@D9705996 Hi! Yes, it can have (and certainly will) have multiple orders.

  1. Is more complicated. It is about rolling stock. You have locomotive, carriages and multiple units as models that will require maintenance. Every model of that particular type, hasMany units. Units share the same table, as the information there is the same across all the units. So there is already a polymorphic relation between unit types and individual units.

As the maintenance orders are based on a type and not on a singular unit, but all the maintenance shares the same base, but on a lower level is split up into several maintenance tasks and so on.

Because of the unit types share the same maintenance order class, but are completely different as types itself, the only way of letting these talk 'together' in my imagination was to use polymorphism.

Is it clear, or should I describe in more depth? Thanks for your help and interest anyway!

Activity icon

Replied to Organize Polymorphic BelongsTo Save

Allright! So, I've to figure out how that thing will work then.

Activity icon

Started a new conversation Organize Polymorphic BelongsTo Save

OK, here's the deal. I have a situation were there are 3 models, which can have one relation to another model. Let's say we have 3 producttypes and every producttype has a maintenance order.

What is the best way to attach a new maintenance order to one of the producttype models? At first the most 'easy' solution that I could've think of is to create one MaintenanceOrderController which hold the 'create' method. But... How is that controller going to find out to which related model it belongs, if I can only give an ID?

So my table of maintenance_orders looks like this:

id producttype_id producttype_type
1  1                              App\Wasmachines
2 1                             App\Computers

Any good advice how to fix this, without having the need to create 3 methods in every prodducttype controller to be able to save those maintenanceOrders?

1 year ago
Activity icon

Replied to Getting All Objects If The Latest Status Is E.g. '100'

Probably you have to put ->get() before last() because the last() method is a collection method and not a query builder method.

$query->where('status', 100)->get()->last();

Activity icon

Replied to Getting All Objects If The Latest Status Is E.g. '100'

$passes = Pass::select([
        ])->whereHas('processes', function ($query){
            $query->where('status', 100)->last();

Wouldn't it be just this easy?

1 year ago
Activity icon

Replied to Using Registered() Method In Illuminate\Foundation\Auth\RegistersUsers

@alexpgates Yes, that's exactly what you must do. As @Snapey said, you shouldn't make any changes in the vendor folder.

The \Auth\RegisterController.php uses the RegistersUsers trait from Illuminate\Foundation\Auth\RegistersUsers.php and thus will call all the methods in there and in your RegisterController.php.

In your routes\web.php you'll also point at that controller for registering a user.

Ahhh, @Cronix was faster...

Activity icon

Replied to Using Registered() Method In Illuminate\Foundation\Auth\RegistersUsers

In App\Http\Controllers\Auth\RegisterController.php you can just override the default registered() method by creating it in the Registercontroller.php

In that way, it'll be in your repo (as the whole App dir is) and you won't touch the core library.

1 year ago
Activity icon

Replied to Handle Multiple Unknown Relations

Thinking days about how to solve this issue... And while I'm sending this question to the forums, I came up with a solution myself, I think... Will try the following and keep ya'll updated:

Create a Setting Model (with corresponding migration file) and create the following table structure:

id - integer
setable_id - unsignedInteger
setable_type - string
key - string
value - string

Then, every model you want to store specific settings, use the key as the 'group' for settings, value for it's result.

public function Settings()
    return $this->morphMany(\App\Settings::class, 'setable');

This will do the job, I guess...

Activity icon

Started a new conversation Handle Multiple Unknown Relations

OK, so here's the deal... I'm building a webapp with Laravel 5.5 and so far I'm running OK. Just some default relations, including polymorphic. But I'm uncertain how to handle the following.

I have a App\RollingStock model and that has a (one) Type() Polymorphic relation. The deal is, I want to track certain measurements. Think about if the machine has already had a daily checkup, how much diesel is still in the tanks, et cetera.

I was planning on using one column on my rolling_stocks table, which held 'certain' attributes as a comma-separated list or something, but then... How to handle this data? And by that, not every Rolling Stock has diesel (there are electrical locomotives as well, but they will need a daily checkup, for example).

Is there someone around here who has a genius solution?