Member Since 3 Years Ago

Bloemfontein, South Africa

Experience Points

4,070 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 5
20,930 XP
4 months ago
Activity icon

Started a new conversation Add A Trait To A Class As A Private Variable

Hello there!

I've got a trait that wish to use in an abstract way inside a class, my objective is to use the trait in the following manner,


I've attempted the following, but it does not work as expected,

trait NumberFormatter
    function toCurrency($float)
        return number_format($float, 5 , '.', ' ');

class Sales {

    use NumberFormatter;

    private $format;

    public function __construct()
        $this->format = NumberFormatter::class;

    public function getSalesAmount()
        return $this->format->toCurrency('123456.3210');

Is it possible to do something like this in PHP?


5 months ago
Activity icon

Replied to Count Distinct Children Within Relationship


Your objective is "count how many distinct keys are in a session", thus this should theoretically work, I haven't tested it out.

$count = Session::->whereBetween('end_time', ['2018-05-19 04:42:00', '2019-05-19 04:42:00'])->events->pluck('key')->unique()->count();


Activity icon

Replied to Integrity Constraint Violation: 1052 Column 'id' In Where Clause Is Ambiguous


You could spend time to hack that function to possibly work, but it would probably still be a hack and look messy. Why don't you try this instead.

On your Group model, add the inverse of the relation,

public function members() {
    return $this->hasMany('App\User');

Then you can easily find the members of multiple groups by passing the as an array into the model's find() method,

$members = Group::find([1, 3, 9, 35, 8])->members; // non-distinct

$unigueMembers = Group::find([1, 3, 9, 35, 8])->members->unique(); //distinct

Just a note, the $members variable will hold a Collection instance and if I'm right, the user may be listed in the collection multiple times, depending on how many groups the user is a member off. Thus you can use the unique() method on the collection to get only unique users.

Activity icon

Replied to Laravel + Vue.js: [Vue Warn]: Failed To Mount Component: Template Or Render Function Not Defined.

Hi there!

Have you tried moving these two "require" lines up so that the files are loaded before the "import" statement is called?

5 months ago
Activity icon

Replied to Date Format In Laravel Controller

Awesome! Happy to help.

Activity icon

Replied to Date Format In Laravel Controller

Pleasure man!

This line will return a string,

$d = DB::table('student_data')->value('date_of_birth');

Now lets overwrite $d with a Carbon instance from the string $d and reformat it like so,

$d = Carbon::createFromFormat('Y-m-d H:i:s', $d)->format('d/m/Y');

Then you can pass $d to the view/blade as before,

...['mydate' => $d]...

Then in blade you can do,

{{ $mydate }}
Activity icon

Replied to DataTables Error

I had the same issue late last year.

Open your composer.json file and add "yajra/laravel-datatables": "^1.2",

"require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.8.*",
        "laravel/tinker": "^1.0",
        "yajra/laravel-datatables": "^1.2"

Then update your project dependencies,

composer update


Activity icon

Replied to Date Format In Laravel Controller

@KONRMS - It is a bit difficult to see without the code for retrieving the entity.

Lets work on a cleaner approach. are we still talking about the "student_data" table and is there a StudentData model?

Activity icon

Replied to Date Format In Laravel Controller

Yes, or I completely forgot about about date casting:

You can add this to your StudentData model:

protected $casts = [
    'date_of_birth' => 'datetime:d/m/Y',

Casting works with serialization, thus this should work,

$objStudent = StudentData::first(); // get the first row
$arrStudent = $objStudent->toArray(); //serialize to an array
$d = $arrStudent['date_of_birth']; //15/05/2019

// can also string it together
$d = StudentData::first()->toArray()['date_of_birth']; //15/05/2019

But it is too long and messy.

I would rather just create an accessor on the StudentData model:

public function getBirthDateAttribute()
        return $this->date_of_birth->format('d/m/Y');

Then in Blade you can simply do,

{{ $student->birth_date }} //15/05/2019

Anyhow, hope this helps.

Activity icon

Replied to Date Format In Laravel Controller

Hi there,

Please try as per the following:

$d = DB::table('student_data')->first()->date_of_birth //returns a string value via the query builder

$d = App\StudentData::first()->created_at //returns a Carbon instance via Eloquent

$d->format('d/m/Y'); // "12/05/2019"

Then in you blade template you can do somethong like,

{{ $student->date_of_birth->format('d/m/Y') }}


Activity icon

Replied to In Axios Request I Got Has Been Blocked By CORS Policy Error

This CORS thing again! I've tripped over it many times.

Checkout this Laracast where Jeffery discuss VueJS and CORS in detail.


Activity icon

Replied to Date Format In Laravel Controller

I believe when retrieving a datetime value from your DB via Eloquent, the returned property would be a Carbon instance, and thus the following should work.


Carbon Docs


Activity icon

Replied to DataTables Sorting & Searching Not Working

Hello there,

I believe there is a missing parameter true when setting the defaults.

Try changing your code as follow:

$.extend(true, $.fn.dataTable.defaults, {
    ordering: true,
    select: true,
    "order": [[ 0, 'desc' ], [ 1, 'desc' ], [2, 'desc'], [3, 'desc']]
} );

Checkout this package, makes server-side pagination, sorting etc. a breeze!



Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'product_id' Cannot Be Null (SQL: Insert Into `category_product`

Hi Irankhosravi,

I encountered a similar issue before, and then realized that I was testing without a valid user login. If there is no user logged in, then auth()->user()->id is null and saving a null value to the DB in a table column with a foreign key or relation would break. At the time I was manually testing by hand, and simply registering a user and logging in, and then navigating to the page I was working on resolved the issue for me. I also fixed my code by validating that a user was in fact authenticated using a guard or middleware.

Hope this helps,


5 months ago
Activity icon

Started a new conversation Where To Store Your JWT Token

Hello there!

I'm consuming a RESTful API using Guzzle and initially do an authentication request to JWT authorization token that is to be included in the header of all subsequent requests.

This token is typically valid for a predetermined period of time, 24 hours in this case, and thus I wish to store the token somewhere and optimally reuse it. I don't want to store it in a DB as this means that have to query the DB each and every time I call the class. Secondly I aiming to find some database / platform agnostic solution that I can apply to all my projects, as I'm consuming various APIs that works in a similar manner.

I am currently storing the token in a ".token" file in the root of my app, and then read the file each time the class is instantiated, but I am a bit concerned for security and performance.

How do you store your API tokens and is there some other efficient solution that I can implement over all my projects?


1 year ago
Activity icon

Replied to Slug


make sure your model use the Sluggable and SluggableScopeHelpers trait, then you can do:


Route::get('/posts/{slug}', '[email protected]');


public function show($slugString)
    $post = Post::whereSlug($slugString)->get();

    // OR

    $post = Post::findBySlug($slugString);

    // OR

    $post = Post::findBySlugOrFail($slugString);
    return view('')->with('post',$post);

And for retrieving the slug in your view:

<h2><a href="{{ route('',$post->slug) }}">{{ $post->title }}</a></h2>
Activity icon

Replied to Laravel Mimes Validate Not Fully Working. Pleaes Help

It may be that your OS is hiding the actual file extension, I've seen it happen on Windows when you rename a file the file explorer actually hide the actual file extension so you may end up with "test.asd.jpg" instead of the intended "test.asd".

You can also supplement your validation logic with the mimestype rule ('mimetypes:image/jpeg') for additional confidence that the file under validation is really an image.

Activity icon

Replied to Changing From MySQL To MSSQL

No, certainly not hassle free.

The built in Laravel support for MSSQL works great, and running migrations against MSSQL worked perfectly in my experience. I believe that mostly your raw and custom DB queries may potentially hit errors, as some SQL operators and functions differ between MSSQL and MySQL. If you have stored procedures and views in your DB, that would likely have to be reworked also.

Activity icon

Replied to Laravel Authentication With Microsoft Active Directory


Yes, it works great!

A few enterprise apps of mine authenticates using AD, I used a 90 day trail version of Windows Server 2012 to test whilst developing. I installed Windows Server in a local VirtualBox VM on my laptop and then promoted the freshly installed Windows Server to a domain controller.

I use the Adldap2/Adldap2-Laravel package to bind to AD and Auth against AD.

I also employ AD Security groups and Laravel policies for access control to resources within the app.

Download Windows Server 2016 here. Its the new 2016 version, but it should offer the same 90 day trial.


Activity icon

Replied to Pagination And Search

It appears you're using JQuery Datatables.

I recommend you use a Laravel package like yajra/laravel-datatables. The documentation is clear and the package easy to implement.


1 year ago
Activity icon

Replied to Issue With Mix Install On Centos 6

As @amitbhatia said,

installing build-essential on Ubuntu 8.04 using npm v5.60 and node v8.11.3 resolved the issue for me.


2 years ago
Activity icon

Replied to Posting XML Data To A Web Service

I haven't personally made use of these, but try one of the Packagist SOAP wrappers for Laravel. The package artisaninweb/laravel-soap looks like a good place to start.

3 years ago
Activity icon

Replied to Yet Another Mailgun Question. Please Help.

Do each and every email message fail, or is the failure intermittent? It may be that the driver connects to but does not necessarily mean that it is making an SMTP connection.

Since you've used it previously without issue, and if each and every email message fail, it may be a good idea to go over the mail.php file and check your connection parameters. It may also be possible that your AV or firewall proxy the connection, or that there may be DNS related issue.

You could also try using the IP of the host, as opposed to the FQDN, although I recommend this for testing and faultfinding only.