Member Since 5 Years Ago

Experience Points 65,860
Experience Level 14

4,140 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 431
Best Reply Awards 34
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.

11 Sep
4 days ago

sid405 commented on Eloquent Subquery Additions

Wait, what? Edit mode?

30 Mar
2 years ago

sid405 left a reply on Homestead `share` Command Not Available

hey @jaypvd did you ever figure this out?

14 Jan
2 years ago

sid405 left a reply on Eager Loading All Over The Place

@lars6 That's strange. If you dd() from the transform function, do yo have the messages data there?

12 Jan
2 years ago

sid405 left a reply on Caching Data Which Is Frequently Updated

In the store method you are caching a single post. And on the second one you're caching all of them.

If you mean to modify only the single post on the cache, you could look up tagging the cache items but for that first you'd need Memcached. And then cache all items separately and tag them with a 'posts' tag as well.

On another note. Your show() method should really be index() if you're showing a list of posts and you want to respect the whole restful controller paradigm.

Additionally on the listing method you are running the query regardless of wether there is a cache or not. The query should be in the cache conditional.

That being said, if you thing you'll have more requests for the listing then the update, then the following code should do what you need.

class PostController extends Controller

   public function index() {


            $posts = Cache::get('posts');


            $posts = Cache::put('post', Post::all(), 60);

        return view('index', compact('post'));

    public function store(Request $request) {

        $post = Post::find(1);
        $post->name = $request['name'];

    $posts = Post::all();

        Cache::put('posts', $posts, 60);

        return view('index', compact('post'));


Hope this helps.

sid405 left a reply on Dynamic View Folder Destination In Laravel 5.3

is "Nitseditor\System\Resources\Views\Themes\" actually a path or is this a namespace of sorts?

sid405 left a reply on TokenMismatchException Only On Certain File Upload?

No, not really. What are you using to Import it? is it LaravelExcel or something? Also, is there really nothing particular about this file?

Could you export its data into another file and try that? Sometimes excel files have some nasty-a** formatting that gets in the way.

sid405 left a reply on How Can I Get The Data Input When Sending Emails In Laravel 5.3?

In your WelcomeEmail you should be able to accept the user. As specified here.

so first

namespace App\Listeners;
use Illuminate\Auth\Events\Registered;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class NewUserRegistered
    public function __construct()
    public function handle(Registered $event)
        // dd($event);
        $event->user->notify(New \App\Notifications\WelcomeEmail($event->user));

and then


namespace App\Notifications;

use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class WelcomeEmail extends Notification
    use Queueable;
    protected $user;    

     * Create a new notification instance.
     * @return void
    public function __construct(User $user)
        $this->user = $user;

     * Get the notification's delivery channels.
     * @param  mixed  $notifiable
     * @return array
    public function via($notifiable)
        return ['mail'];

     * Get the mail representation of the notification.
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
    public function toMail($notifiable)
        return (new MailMessage)
                ->subject('You have new follower')
                ->greeting('Hello '.$this->user->name.'!')
                ->line('Welcome to my application')
                ->line('Thank you');

     * Get the array representation of the notification.
     * @param  mixed  $notifiable
     * @return array
    public function toArray($notifiable)
        return [

This should be it.

Works fine on my end.

Hope that helps

sid405 left a reply on TokenMismatchException Only On Certain File Upload?

It happens only with this one file? Even on consecutive attempts but it's ok if you change files? Is this the idea?

sid405 left a reply on Eager Loading All Over The Place

@lars6 You don't have to. I had a conversation about back in the day with @philsturgeon when the Build Apis You Won't Hate book came out.

If you already feed to fractal a collection with models already eager loaded, fractal won't make the call again but use the collection instead. Just like Laravel does.

Hope that helps.

sid405 left a reply on Is There A Practical Max On The Number Of Tables/models?

For the past few months i've been working on an ERP with about 300 tables. 200 and so are actual model tables and the other ones relationship tables of sorts.

If you build your relationships correctly, avoid n+1 problems with eager loading and optimise by caching where you can, nothing particular should stand out in the performance aspect.

At least this in my experience.


sid405 left a reply on Getting Errors While Running The Php Artisan

You have an error in one of the files in the config folder on in the .env. Most likely a syntax error.

Spend a good half hour on this a few days ago.

Hope it helps.

02 Nov
2 years ago

sid405 left a reply on Laravel And Laravel-echo-server TokenMismatch

@jimmck I had it like that while i was debugging but since it's not passing the auth'ed session, it's not passing the user either and the ACL check on the BroadcastServiceProvider will forever fail.

sid405 left a reply on Laravel And Laravel-echo-server TokenMismatch

Hi @pentacorp .

I do have it in fact and it's being passed on correctly. The problem is that Echo or laravel echo server are not passing the auth'ed user instance so Laravel thinks it's another session and regenerates the token.

Works correctly with pusher though. I have no idea what to debug anymore...

01 Nov
2 years ago

sid405 left a reply on Broadcasting With Laravel Echo, Laravel-echo-server And Won't Work

@halloei apparently you have to prefix your event with a dot. Like so.

        .listen('.myevent', (e) => {
            console.log('Hello World!', e);
31 Oct
2 years ago

sid405 started a new conversation Laravel And Laravel-echo-server TokenMismatch

Hi all.

I started yesterday working on a project using Laravel echo and i wanted to use instead of pusher. So as suggested by Taylor on the official documentation, i went ahead and pulled in

Doing this on Homestead.

Got everything working fine with public events.

The issues started with private channels.

As expected, and defined in the BroadcastServiceProvider, i need to send auth requests to /broadcasting/auth. The problem is i get a constant token mismatch exception.

Investigating further in Illuminate\Foundation\Http\Middleware\VerifyCsrfToken and specifically in the tokensMatch function, i notice that

$sessionToken = $request->session()->token();


 $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');

have two different values. The one in the headers being the one of the authenticated session (so the correct one).

Moving further i was initially using redis as session store. Then i moved into file and noticed that for every request to /boadcasting/auth a new session was being generated.

In the end starting storing sessions into the database. Here's where the final clue came.

For every request coming from homestead (where node and laravel are, thus Echo is running) I am getting a new session generated with Homestead's ip for every time i load the page. So naturally the sessions would not match but i can't figure out how to avoid it.

I've cleared all caches, dumped autoload, cleared compiled, even rebuilt the vendor folder a couple of times.

At this point i have no idea anymore. I'd really appreciate if someone could shed some light.

Ps. I've already gone couple of times through the relevant issues on both Echo's and laravel-echo-server's github. There are a couple of references but fixes suggested there were not relevant to the matter.

Thanks in advance

26 Oct
3 years ago

sid405 left a reply on L5.1 Spatie Media Library How To Work With It?

Hey @kickthemooon .

Why do you think you need to specifically work with that package? It really depends on what you are trying to build.

Take the issues one at a time.

First of course have e look at the readme on Once you clarify your ideas this is all you should be needing to start implementing, but idk how junior that material actually is.

then when it boils down, to plugging it into your app in forms and whatnot, that's a lot of code to give as an example.

A lot of people will try help here by correcting your code and givin a hand if you're stuck and provide code details, but don't think you'll find anyone to write a full blown implementation for you.

I hop that helps mate.


sid405 left a reply on Autoloading

@gintare "why i shall add "use" statements""? Do you really want to load every class present in each and every folder by default? And make sue no two classes are ever called the same? Ever?

Anyhow, in L5 there is no need to use View as a class. Just return view(). You should be good to go.

sid405 left a reply on Class 'App\Commands\Command' Not Found

@malhayek You don't really generate handlers like that for jobs. Jobs are generally intended to be pushed into the Queue.

This may help

If you by any chance are referring to commands, then what you are looking for is

php artisan make:command MyCommand --handler

This si the most i can tell without knowing exactly what you're trying to achieve.

As far as your original problem goes, yes Command.php is not there by default on 5.1 and making a command does not create it. Create the file app/Commands/Command.php and place this into it:

<?php namespace App\Commands;

abstract class Command {



best of luck, sid

sid405 left a reply on Mail::queue Vs Send On Delivery Episode.

Hey @TheGlenn88

like @jaewun said, is your queue set to sync on both .env file and config/app.php ? If you have an .env file and a host that supports env variables then you should be good, but check anyway.

That being said, if it is indeed set to sync, then there should be no need to make the queue listen.

can i see the "...Mail::queue to Mail::send..." snippet you're referring to?

sid405 left a reply on Suddenly Getting This Error: Failed To Open Stream Nikic/php-parser

Hey @resmall.

this seems either an issue with composer ( packagist maybe) or something to be brought up in

Good luck

sid405 left a reply on How To Build A Questionnaire Application With Laravel 5.1?

@gocevskam A separate table for each questionnaire? Why?

Use a table for the questionnaires. All questionnaires. One for the choices available referencing the questionnaire_id. And one for the choices made, referencing the choice_id (which is unique now to a given questionnaire, since the choice itself has a questionnaire_id).

Id you're having logged in users fill the survey, then reference the user_id on the table where you store the choices made.

This should be able to help you

best, sid

sid405 left a reply on Route Not Defined Error

@technogenes You're referring to a named route, but your route is not named.

Try this-

Route::get('main', ['as' => 'main', function () {
    return View::make('main');
09 Oct
3 years ago

sid405 left a reply on Check If User Belongs To The Moderators List Before Allowing Him To Edit

@ufodisko Strange. when i click the link it works. moderation_relation was just a term i used to refer to the moderator relation on your user model.

Try that link again as it would help you , and then to solve the two link issue, include it in the 'can-update' check, so that for either of the reasons the link i returned only once.

08 Oct
3 years ago

sid405 left a reply on Check If User Belongs To The Moderators List Before Allowing Him To Edit

@ufodisko i'm gonna go ahead and safely assume you're trying to achieve this in the scope of

and i see you are storing your acl logic on AuthServiceProvider. Personally i would extend the 'update-post' permission and define on the user model a method that checks the user-moderator relation and returns a truth value if such a thing exists.

ps. this suggestion perhaps can be implemented with an efficient Count. Basically if a truthy value is returned from counting the times the current user is in the moderator relation

have a look at this

If you can't get it to work i can help later with some actual implementation but the idea would be this

public function boot(GateContract $gate)

    $gate->define('update-post', function ($user, $post) {
        // Check if user is subreddit owner
        if ($user->id === $post->subreddit->user->id) {
            return true;

        // Check if user is the post author
        if ($user->id === $post->user_id) {
            return true;

        return false;

    $gate->define('update-sub', function($user, $subreddit) {
        if($user->id === $subreddit->user->id) {
            return true;

        return false;

$gate->define('update-whatever-as-moderator', function($user, $subreddit) {
        if($user->moderator_relation) { //or perhaps you could just see if once you've logged in the user and eager-loaded 
                                //the relationship, it has a truthy value instead of counting
            return true;

        return false;
06 Oct
3 years ago

sid405 left a reply on Database Access Denied From Controller But Works With Artisan Tinker

@gg2015 hmm, did you store your mysql access data in the .env file or the config/database.php file? is the APP_ENV the same on both or did you modify it manually?

01 Oct
3 years ago

sid405 left a reply on New To Laravel. Q: How Can I Avoid Reset Of Dynamic Connection To Multiple MySQL?

@bach cool. thank link i posted should put you on the right path though. i've used that technique a couple of time with no hitches.

sid405 left a reply on New To Laravel. Q: How Can I Avoid Reset Of Dynamic Connection To Multiple MySQL?

anything in laravel.log? Should've logged something if ANY queries are actually made.

sid405 left a reply on New To Laravel. Q: How Can I Avoid Reset Of Dynamic Connection To Multiple MySQL?

@bach Any errors? Put this in your routes.php to see if any queries are even being made

Event::listen('illuminate.query', function($query, $params, $time, $conn) 
    Log::info(array($query, $params, $time, $conn));

sid405 left a reply on L5 Library Not Found On Live Server

@markandrewkato "App\Library\Common" ? There's nothing with that name on the L5 codebase. Did you create that file in app/Library/Common.php ?

sid405 left a reply on Complexity Of The Code Of Laravel And Its Performance

@justtest it's been iterated few times hare from @pmall and in a crasser way from @bashy and others that you're overthinking this. Why are you counting the function calls to begin with?

Laravel is not lightweight. No one, ever, has said it was. What it is, is well structured, complete, clear, adherent to modern web development standards in the year 2015.

Here's some benchmarking

If you think your application needs a better throughput on 71 requests per second, then you are asking the wrong question in the wrong place. A good, framework is not necessarily "simple", but it makes it very simple to work with for a variety of projects and requirements if you study it well.

It could be that ppl here got a little worked up because of the language barrier, but fact is you are in fact at a Laravel-centric forum having this conversation.

@vedmant "For example, try to remove remember_token field from users database table, and it will stop working" ? Seriously? Show me another function, anytime anywhere, where you remove fields from the db, expect it to write, fail silently and call that good practices. How does that make sense?

"So that means if you need to change some small things in existence module you'll better write your own from scratch, otherwise it just will not work" - proper oop concepts knowledge solve that problem rather easily.

sid405 left a reply on Ajax Post Console Log Error

@nanadjei2 glad you solved it. the only advice i can give you (since the fix you marked is an extremely common one with ajax and a lot of ppl here could have given you and the solution straight-away) is to be a little bit more descriptive in your questions. Show some error logs, where you getting them, where, and what is the code you execute to cause the error.

Best of luck.


sid405 left a reply on Getting Errors In Production Only

@Man reverse engineering laravel? why? i think it would have been substantially easier to go the other way and implement the front. Anyhow, your domain. :D

to iterate of the similar ones

<?php foreach($sidebar->similar as $post): ?>

Although then you fetch them with

$sidebar = Post::with('similar')->find($some_post_id);

You need to pass that some_post_id some other way in your structure, since you're using L5 'unconventionally' ( ;) ) i don't know your file structure to be able to suggest how

sid405 left a reply on Organizing A Multi Site App

Have a look for 'multi tenancy' or 'multi tennant' around the forum for a starter idea. It's been discussed at length.

sid405 left a reply on Ajax Post Console Log Error

ok, because i feel like i'm pulling info from you against your will.

Do this first and see if you are getting the correct data.

request.done(function(msg) {

sid405 left a reply on Getting Errors In Production Only

@Man the following code goes in your Post.php and not the controller.

public function similar()
        return $this->hasMany('Posts', 'post_category_id', 'post_category_id')->orderBy('created_at', 'DESC')->take(6);

Let me ask you. Are you porting this code from another project? because that clearly does not look as blade syntaxing and you're calling the model in your view.

Id you don't mind me asking, how are you structuring this thing?

sid405 left a reply on Composer Autoload Doesn't Seem To Work

Then given the circumstances i don't know what else to suggest. It's either something extremely contorted or extremely overlooked, because from the replies of all the peeps here, you say you tried the common solutions. :/

sid405 left a reply on Duplicate Key While Seeding

@nobreferreira I think i would look for the answer of that on the the relationship between Region and Ad.

It's fair you are checking wether it contains it, but you are feeding it only an id. I would log in one iteration the id returned randomly, the entity returned in 'return $this->regions' and the result. This is the only way to find out why that is failing to find an existing key.

Best, sid

sid405 left a reply on Getting Errors In Production Only

@Man What was the problem? i don't mind walking you through it :)

sid405 left a reply on Integration Of Dynamic High Chart With Laravel 5

@finsok333 I think i understand your problem but it would be useful to see how you set up the 'donationcategory' in the Donations model.

sid405 left a reply on Composer Autoload Doesn't Seem To Work

When you removed the vendor folder, did you also remove composer.lock and then run

composer install

There's also the option

artisan clear-compiled

sid405 left a reply on Ajax Post Console Log Error

and where are you getting this '"Request failed: parsererror"' error? is it in L5? is it on your js?

Responses are already using the Jsonable trait so no need to be explicit about it really.

sid405 left a reply on Getting Errors In Production Only

@Man excellent. though i do have to mention that the second one is a better approach. You already have fetched the post. Why not get related posts then as opposed to run a second query fetching with a key you already could have used in the first place?

Anyhow, :)

sid405 left a reply on Getting Errors In Production Only

@Man In the post model define something like this

public function similar()
        return $this->hasMany('Posts', 'post_category_id', 'post_category_id')->orderBy('created_at', 'DESC')->take(6);

And then when you call the post

$post = Post::with('similar')->find($some_post_id);

Of course then watch out on the sidebar view and make sure you check that $post->similar contains anything, otherwise you will get errors like now.

sid405 left a reply on Ajax Post Console Log Error

@nanadjei2 import at the top

use Illuminate\Http\Request;

sid405 left a reply on Composer Autoload Doesn't Seem To Work

@roeben and the package on the other server is installed through composer as well? Because of the code is fine, then you're dealing with other factors, which could be the missing package.