Member Since 4 Years Ago


Experience Points 33,180
Experience Level 7

1,820 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 223
Best Reply Awards 15
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.

02 Jun
1 year ago

isaackearl left a reply on Registering Service Provider

@kaiden not really. PHP is till really fast especially 7.0+.

isaackearl left a reply on Registering Service Provider


That is how php works, it's not a specific problem with Laravel. Every php framework bootstraps the entire application for each request.

01 Jun
1 year ago

isaackearl left a reply on When Exactly Do I Use A Service Provider?


That is what I was trying to do when I gave the Api Service example. The api service is not really a data service or a repository, nor is it a 3rd party api implementation... It is just a collection of useful api methods to be used in a controller.

So, I created an ApiServiceInterface which has all the methods I want to have available, and then created an "implementation" of that interface. I then use the Service Provider to bind the ApiService implementation to the interface, so that I can type hint the interface in my controller and get the implementation.

Here is an example of one I did in an older project. I needed to send refund checks in the mail, and decided to use the api at to do that.

First thing I did was make an interface for sending checks:

interface CheckSendingContract

     * @param PendingRefund $pendingRefund
     * @param bool $forceSend
     * @return PendingRefund|bool
    public function sendCheck(PendingRefund $pendingRefund, $forceSend = false);

// a pending refund is just a model in this  application that stores refunds that are pending... I also wanted a way to force send it ahead of schedule...

Next thing I did was create an implementation for this interface using Lob so I called it the LobRefundService (I probably should have called it LobCheckSender or something like that but the Lob refund service implemented a few other interfaces such as address validation so I went with the more generic name)

class LobRefundService implements CheckSendingContract, VerifiesAddressesContract

     * @var Lob
    protected $lob;

     * @var string
    protected $bank;

     * @var string
    protected $fromAddress;

     * LobRefundService constructor.
    public function __construct()
        $this->lob = new Lob(Config::get('services.lob.key'));
        $this->bank = Config::get('');
        $this->fromAddress = Config::get('services.lob.address');

     * @param PendingRefund $pendingRefund
     * @param bool $forceSend
     * @return PendingRefund|bool
     * @throws InvalidAmountException
     * @throws MismatchedRefundTypeException
     * @throws NotReadyException
    public function sendCheck(PendingRefund $pendingRefund, $forceSend = false)
        if ($pendingRefund->type !== RefundTypes::MAIL) {
            throw new MismatchedRefundTypeException();

        // are we forcing it to send before the send_after date?
        if (!$forceSend) {

            // check if the date is ready...
            if ($pendingRefund->send_after_date > Carbon::today()) {
                throw new NotReadyException();

        if ($pendingRefund->getAmount() <= 0) {
            throw new InvalidAmountException('Refund amount must be greater then 0');

        $amount = $pendingRefund->getAmount();

        $response = $this->lob->checks()->create([
            'description' => 'Refund Check',
            'to[name]' => $pendingRefund->user->name,
            'to[address_line1]' => $pendingRefund->user->address,
            'to[address_city]' => $pendingRefund->user->city,
            'to[address_state]' => $pendingRefund->user->state,
            'to[address_zip]' => $pendingRefund->user->zip,
            'from' => $this->fromAddress,
            'bank_account' => $this->bank,
            'amount' => $amount,
            'memo' => 'Refund for ' . $pendingRefund->user->name,

            'check_number' => $response['check_number'],
            'status' => 'sent',
            'amount_sent' => $amount,
            'is_sent' => true,
            'sent_at' => Carbon::now(),
            'lob_check_identifier' => $response['id'],
            'expected_delivery_date' => $response['expected_delivery_date']

        return $pendingRefund;
// ... more stuff below 

Finally, I created a Service provider so I can use this newly created service wherever... through dependency injection.

// service provider file....

public function register()
        $this->app->bind(CheckSendingContract::class, function ($app) {
            return new LobRefundService();

// other things here....

Then all I had to do was use it wherever I want... Here is an example of using it in a constructor:

// some controller or other class

    function __construct(CheckSendingContract $checkSender)
        $this->checkSender = $checkSender;


    public function sendACheck($pendingRefund)
    $this->checkSender->sendCheck($pendingRefund, true) // force immediate send

Anyway, I kinda rushed through the last part of the example. I hope this gives you an idea how how they work.

isaackearl left a reply on When Exactly Do I Use A Service Provider?

I use service providers mainly for things like: repositories, data services, 3rd party api implementations, and any other custom functionality which I think makes sense wrapped up in a service.

For example I made an "ApiService" which provided functions I could use in my controller such as

// api helpers all bundled up in a nice service
$this->apiService->respondWithError('hey something went wrong!'); 
07 May
1 year ago

isaackearl left a reply on I Need Some Socket Server Education.

This thread has become 100% spam.

28 Aug
1 year ago

isaackearl left a reply on Laravel Eager Loading Problem

which query is being being repeated. maybe you missed an eager load

12 Aug
1 year ago

isaackearl left a reply on Does Laravel Knows That The Plural Of Country Is Countries ?

Yup. You can test things like this using tinker too.

>>> str_plural('country');
=> "countries"

isaackearl left a reply on Refresh A DIV In Laravel Every 5 Seconds

This would be a good opportunity for you to use broadcasting instead of refreshing a div over and over... which probably would cause allot of strain on your server.

Read a little bit about this here. It was made specifically for this use case.

05 Aug
1 year ago

isaackearl left a reply on Laravel 5 API + AUTH For A Mobile App Or Another Web Application


What version of JWTAuth and Laravel are you using? This thread and the examples I wrote up are from some time ago.

You might try and make sure that your User model has the AuthenticatableContract and uses the Authenticatable trait. That adds a getAuthIdentifierName() method to the user Model.

Maybe I can help if I know what versions you are on.

Also, that middleware I was using I don't use anymore. I'm on the latest dev branch of JWTAuth now and my middleware looks more like this:

     * Handle an incoming request.
     * @param  Request $request
     * @param  \Closure $next
     * @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
     * @return mixed
    public function handle($request, Closure $next)

        return $next($request);

     * Attempt to authenticate a user via the token in the request.
     * @param  Request $request
     * @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
     * @return void
    public function authenticate(Request $request)

isaackearl left a reply on Need An Opinion: Include Laravel Package In My Package Or Make My Own Implementation?

thanks @ryantbrown for the response. I think I am leaning towards including the package in my package. It's not really required as I could implement the things it does myself, however the laravel-fractal package is really nice and has a nice api/syntax etc for using Fractal. I think in the end it makes sense for me to include it since I am essentially building the package the way I would like to use it. If others want to use it that would just be a bonus.

31 Jul
1 year ago

isaackearl left a reply on Queing Jobs From Within A Job.

Maybe you need an event with multiple listeners instead?

Or maybe you can launch an event at the end of the CreateDB job called "DBCreated" and have listeners that do stuff you want done after.

you can simply do

event(new DBCreated( /** whatever your constructor needs */ ));

Also in Laravel 5.5 coming out in a month or so you'll be able to queue up multiple jobs in a row.. Can't remember the specifics of how it works, but during Laracon US Taylor talked about it as a new feature.

isaackearl left a reply on How To Use Authorization Policy/Gate With Tymon JWT?


Try it without the JWTAuth facade.


Otherwise there doesn't seem to be enough information here to fix.

Try install xdebug and stepping through the code line by line to see what is missing/not working. Put some breakpoints on your policy etc see if it is ever going in there.

isaackearl left a reply on Some Help With Forge Please, Losing My Mind

not sure @zync09, maybe try re-provisioning the server?

I have several sites deployed with forge now and I've never had any issue like that.

From your error message, it seems like the command is trying to access a database called forge. Is that what it is called in your database.php config file/.env file etc ? In other words are you pointing at the correct database?

Sorry at this point I can't think of much else to try. You could try to reprovision and see if you can ssh into the new server and manually deploy just to find out if all the environment stuff is setup right like php/mysql etc. Might give you some clues as to what is going on.

isaackearl left a reply on Need An Opinion: Include Laravel Package In My Package Or Make My Own Implementation?

Sorry to bump my own question, any idea on best practice with this situation?

30 Jul
1 year ago

isaackearl started a new conversation Need An Opinion: Include Laravel Package In My Package Or Make My Own Implementation?


Need some opinions! I'm creating an API package similar to something like Dingo/api except for a bit lighter.

I've created many APIs etc the past couple of years and I've developed my own set of tools for it, and I thought I would make it available so I'm rewriting some of it as a proper package now.

One portion of it uses laravel-fractal the great package here from spatie:

I'm wondering if I should include that as a dependency in my package and register the service provider for it in my own service provider etc? Or should I make my package more generic and implement my own Fractal provider/service ?

I really like laravel-fractal and the extra goodies it already provides, but I want registering my service provider to be easy as possible, and I also like the idea of people being able to use whatever phpleague/fractal package they want (for example for a project that already uses fractal and is adding my package on top of it).

Might be a silly question but I appreciate any feedback and which route I should take. Thanks!

isaackearl left a reply on Cannot Use My Artisan Console. It Simply Just Says Php Command Not Found

Sounds like you don't have php setup properly for your command line.

I'm not sure how to set it up, but you probably have to add the location of php to your PATH environment variable

Once you add the php location to your path, then you should be able to type

php -v

and it will show you the php version you are running.

isaackearl left a reply on Know Token Based Authentication

They will have to re-authenticate. Your request should return a 401 , and then you can redirect them to a login screen etc.

29 Jul
1 year ago

isaackearl left a reply on How To Use Authorization Policy/Gate With Tymon JWT?

Hm... No errors or stacktrace right?

There are 2 things I can think of:

Did you make sure to register your policy in the AuthServiceProvider? You have to do something like this:

class AuthServiceProvider extends ServiceProvider
     * The policy mappings for the application.
     * @var array
    protected $policies = [
        Post::class => PostPolicy::class,

     * Register any application authentication / authorization services.
     * @return void
    public function boot()


Also, since your 'update' method doesn't seem to take any parameters you might have to pass in the class that the policy applies to as a second parameter. like this:

if ($user->can('create', Post::class)) {
    // Executes the "create" method on the relevant policy...

Where are you trying to use the policy? In a controller method?

28 Jul
1 year ago

isaackearl left a reply on How To Use Authorization Policy/Gate With Tymon JWT?

I think once you authenticate with JWTAuth you can then use the regular Auth facade



You might also try something like this (though I haven't checked)

// or

isaackearl left a reply on Where To Trace This Error ?

where are you seeing this? Is there a larger stack trace? Are you getting that when you try and run a command?

If you are getting only that when you run a command, then add --v onto the command and it will give a full stack trace. That should help you get to the right spot.

27 Jul
1 year ago

isaackearl left a reply on Best Practice For Multi Auth?

You can use 1 database with multiple tables representing your different models.

Laravel has some built in functionality with this.

Here is a good tutorial I found

The important part is this:

return [

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        'api' => [
            'driver' => 'token',
            'provider' => 'users',
        'admin' => [
            'driver' => 'session',
            'provider' => 'admins',
        'admin-api' => [
            'driver' => 'token',
            'provider' => 'admins',
    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        'admins' => [
            'driver' => 'eloquent',
            'model' => App\Admin::class,

In your config you setup multiple providers and guards. Then you can have separate logins and use the guard method to specify who you are trying to login..

if (Auth::guard('admin')->attempt($credentials)) {
    // etc...

isaackearl left a reply on Some Help With Forge Please, Losing My Mind

@zync09 so it seems like it is pulling in your repo just fine from bitbucket based on the fact that it is trying to install it etc... It just isn't picking up your password :(.

Have you looked at your database.php file to make sure that DB_PASSWORD isn't hardcoded for the database type you are using. Had a friend who had set that up accidentally and so it wasn't reading the DB_PASSWORD from his .env file.

Have you been able to ssh in yet? If I were you I might ssh go to the directory for your site and see if you can tinker with it to get it to work. That would get you the clue you need to fix the deployment.

Are you on windows or mac/linux ? If you are on mac/linux then do this:

cat ~/.ssh/

then copy the entire thing into the SSH tab on for for that server. then you should be able to connect to it simply by doing this:

ssh [email protected] // whatever your ip address is

Once you are in there, then i would go to the folder and try and do a composer install and try and connect to the database using the command line mysql tool etc, and figure out what is going on.

isaackearl left a reply on I Don't Get A Session On Production Server

do you have an .env file where you are accidentally setting the session driver to array ? how is your prod environment setup? Have you verified your environment variables?

If not, then are you seeing rows put into the database when you make requests ?

isaackearl left a reply on Some Help With Forge Please, Losing My Mind

@zync09 You have to set your environment variables on forge so that it uses the proper database credentials etc. In forge click on the site, then on the left you'll see "Environment". Then you can set your environment variables. This is the same thing as your .env file that you set in your local. You'll need to set DB_DATABASE, DB_USERNAME, DB_PASSWORD etc so it uses the forge username and password etc. You should have recieved that password when you provisioned the server on forge (it emails to you).

Let me know if you get stuck.

26 Jul
1 year ago

isaackearl left a reply on Multitenant Multidatabase Restful Application

So this got launched literally TODAY.

Check it out, it's from Tom Schlick who gave a great presentation about multi tenant apps yesterday at Laracon.

isaackearl left a reply on I Don't Get A Session On Production Server

I don't fully understand your question, but you need to make sure your SESSION_DRIVER is set in the session.php config file.

    'driver' => env('SESSION_DRIVER', 'file'),

You can set these values in your .env file as I'm sure you know...

If it is set to 'array' then it will lose the session value between requests.

Sorry if this doesn't help you, I didn't fully understand your question.

isaackearl left a reply on Multitenant Multidatabase Restful Application

If I were you I would use a package to help me. There are a few modern packages that are supposed to be pretty good.

Single Database:

Multiple Database:

Tom Schlick gave a great presentation today on this at Laracon, and it will be available to watch for free (not sure when) here:

22 Jul
2 years ago

isaackearl left a reply on Social Integration Without Using The Session?

@pmventura So I went ahead and setup an implementation of Socialite with Lumen, and got it working etc. Can you tell me a little bit more about your problem?

Are you on the newest version of Lumen and Socialite?

What are you using to handle authentication after you get back a valid authentication with socialite? JWT, Passport or something else?

For me it was pretty easy, Here is what a socialite facebook login looks like in my very basic demo

     * Redirect the user to the Facebook authentication page.
     * @return Response
    public function redirectToProvider()
        return Socialite::driver('facebook')->stateless()->redirect();

     * Obtain the user information from Facebook.
     * @return Response
    public function handleProviderCallback()
        // this user we get back is not our user model, but a special user object that has all the information we need
        $providerUser = Socialite::driver('facebook')->stateless()->user();

        // we have successfully authenticated via facebook at this point and can use the provider user to log us in.

        // for example we might do something like... Check if a user exists with the email and if so, log them in.
        $user = User::query()->firstOrNew(['email' => $providerUser->getEmail()]);

        // maybe we can set all the values on our user model if it is new... right now we only have name
        // but you could set other things like avatar or gender
        if (!$user->exists) {
            $user->name = $providerUser->getName();
            $user = $user->save(); // just because I want it to return the user id in my example

         * At this point we done.  You can use whatever you are using for authentication here...
         * for example you might do something like this if you were using JWT
         * $token = JWTAuth::fromUser($user);
         * return new JsonResponse([
         *     'token' => $token
         * ]);

        // since I'm not actually using JWT or something in this demo, then I'll just return the user:

        return $user;

I can't reproduce your issue.

18 Jul
2 years ago

isaackearl left a reply on Social Integration Without Using The Session?

Hey @pmventura, It has been a couple of years since I originally wrote up these solutions etc. To be honest my memory is a bit dim and I'm not working on that particular project anymore that used the stateless socialite authentication.

I think I'm going to spend a bit of time this weekend refreshing my memory and building a demo application. I will try and write up a guide on how to use stateless authentication and I will post back here once I do so.

If you cannot wait that long, then in the meantime I would recommend to you creating a new thread with your question. Include as much detail as possible and some of your code so it is easier to help you find your issue.

also @Sams_sound Sorry I never responded to your question! I plan on doing exactly what you asked (write up a guide), sorry it is a year late!

09 Jul
2 years ago

isaackearl left a reply on How To List All The Currently Logged In Users In Laravel 5.4?

As a side note, you could setup google analytics or something to track users currently on the system. There are lots of monitoring tools out there that, once setup, can tell you how many active users you have etc.

isaackearl left a reply on Confirm Post Sending Pop Up

If you are using bootstrap, then you can use a bootstrap modal.

28 Jun
2 years ago

isaackearl left a reply on Hoping For Advice! Want To Allow Users To Create There Own Data Storage Structure... Meta Or Scaffold?

@insanealec wow! thanks for the detailed response. I think I'm going to end up doing something exactly like this. Now I need to research my storage options.


isaackearl left a reply on Hoping For Advice! Want To Allow Users To Create There Own Data Storage Structure... Meta Or Scaffold?

@insanealec . The user wouldn't define methods. They would essentially get basic crud operations for the object, and also some options they can turn on and off for the object as a whole, and for each property.. such as making the object read only, or making it cacheable and setting a cache time... Or setting a property so it is not nullable etc.

Thanks for the suggestions... I haven't used a NoSQL database before and this might be a good opportunity for me to give it a shot... I'll go look up some pros and cons of storing the data this way.

26 Jun
2 years ago

isaackearl started a new conversation Hoping For Advice! Want To Allow Users To Create There Own Data Storage Structure... Meta Or Scaffold?


I essentially am thinking of creating a tool that will allow some users to store data... essentially allow them to store objects. This is mainly an experiment but I want to do it as if it were a really important project.

Use case would essentially be that a user would Name and describe an Object in the browser... and then information into that object via normal crud operations.

The tricky part is figuring out the proper way to store and scale this... Essentially I see two options.

#1 Create an objects table that essentially contains all the meta data for an object and then another table that stores the object information in json format... This would potentially end up being very slow because one table could end up representing many different types of entities etc. If I were in a real world scenario I could end up with millions of rows in a table with semi expensive operations since everything would be stored as json...

#2 Whenever a user creates a new account, run some scaffolding behind the scenes that actually creates a new database for that particular user... then when they create these "objects" I could actually create a table for each object etc. Cons are that this would be hard and I don't know how practical it is for each user to get there own database... But it would be faster to access data etc because it wouldn't be from a shared table with all the other users, and it wouldn't be so abstract... having to query the metadata for what the data should be etc.

#3 3rd option is something similar except maybe just make a new table in the database for each user instead of making a new database...

#4 ? Any other ideas?

This is all purely an exercise for me, and not something very important. Just don't have anybody around to discuss or brainstorm with so I'm wondering if anybody has thoughts.


26 Apr
2 years ago

isaackearl started a new conversation Deployment Process That Includes Running Functional Tests?


I've been using envoyer for quite some time now and I love it for it's simplicity etc... however I'm now building some functional tests using Laravel Dusk and I would like to incorporate these tests into my build process so that it won't deploy unless functional tests pass...

This doesn't work because you can't test the app by hitting the browser etc until after the release is activated.

I've been considering switching to a different tool for doing my deployments like Jenkins or Teamcity... but was hoping I could get some recommendations or tips from somebody who has setup a good deployment process that includes functional tests (webdriver etc).

Another detail about my application is that I have 2 separate "projects" on envoyer... One for the frontend (which is a react application) and one for the API (which is a laravel api).

each project runs its own unit tests etc when they are deployed.. and now I'm having trouble figuring out how to include functional tests somewhere in the deployment process.

18 Apr
2 years ago

isaackearl left a reply on Unit Testing Repository Save Method


You ever figure out the best way to test that? I want to do the same thing and would rather not actually hit the database with my unit tests.

15 Apr
2 years ago

isaackearl left a reply on Architecture Question, Best Approach For SSO With Multiple Apps And Some OAUTH

@gandra . I'm not sure what you are asking. You can configure jwt-auth to work that way if you wish, but most likely separate instances will have different keys and therefore the same credentials won't work across multiple applications.

25 Mar
2 years ago

isaackearl left a reply on [L5.4] Slack Message With Markdown Content Has Some Problem

if someone could help with this that would be great... been trying to get markdown to display in my slack messages for a couple hours today.

14 Mar
2 years ago

isaackearl started a new conversation Any Tips On Creating Functionality For Mail Merge Or Batch Email Sending?


I have an app with a user base that I occasionally have to send batch emails out to. I've created a simple email tool on my admin panel which will allow me to select users to send the email (via query)... Then it loops through and sends out an email for each one.

I'm using mailgun (mailgun driver) for all the emails being sent for my app.

What I would really like is the ability to send personalized messages in bulk... Do things like replace a variable in the message with the name of each user... and in general be very flexible with the messages I send from my admin panel.

Has anybody built anything like this and/or have any tips on a good approach?

If not then I may just end up building individual templates for each type of message I need to send, with a dynamic content section that I include from the admin panel.

Anyway, any thoughts are appreciated.

27 Feb
2 years ago

isaackearl started a new conversation Is There A Way To Make My Queue Run Slower.. ?

I realize this is sort of a dumb/awkward question, but I have a job I'm dispatching that hits a 3rd party service, and right now I'm getting dangerously close to getting throttled... becaues the job run really quickly and sometimes I can have a few hundred of them queued up.. I had to switch my queue worker from running as a daemon because it was running to quickly...

I'm wondering if there is a practical way to put a sleep between queue jobs? have it wait a second before processing the next one etc.

Sorry it's late at night and I'm rambling a bit and also I'm very tired so I'm sorry if my question doesn't make alot of sense. Any thought would be appreciated.

05 Feb
2 years ago

isaackearl left a reply on Cannot Download Excel Files... (maatwebsite) Even Though They Generate Fine.

thanks @koerel I'll give it a try and let you know how it goes.

18 Jan
2 years ago

isaackearl left a reply on Cannot Download Excel Files... (maatwebsite) Even Though They Generate Fine.

@Dan I appreciate the suggestion, however I have already tried this. Thank you though!

I have a workaround for now.. until I can figure out the real reason why it fails for me. I just put this before the download:


and everything works fine... However I don't like using something that seems like a workaround for a problem elsewhere in my code... So I'm hoping Ill eventually figure out what the issue is.

13 Jan
2 years ago

isaackearl left a reply on Cannot Download Excel Files... (maatwebsite) Even Though They Generate Fine.

@koerel Good thought. I checked to make sure, and there aren't any.

I've read some threads about it being trailing whitespace in a configuration file after <?php or something, but they seem fine to me.

isaackearl left a reply on Cannot Download Excel Files... (maatwebsite) Even Though They Generate Fine.


I have made a web endpoint GET request... which downloads the file, but when I open it, it is garbled.


yes I gave that a try and it does the download only but it is still garbled the same way.

I've tried simplifying my file and I've realized that it literally doesn't seem to matter what file I generate.. it is messed up every time (the file is fine on the local filesystem, but if I try and download it then it is borked).


So I managed to finally get a working file... However I don't understand the solution and I would rather it work normally like it does for everyone else.

I added ob_end_clean right before the download.. and this works whether I use laravel's response()->download($filePath)... or if I use laravel-excel's ->download() command.

   ob_end_clean();  // I don't know why I need this or if it screws other things up...
        return response()->download($filePath, $filename, $headers);

I have no idea why this suddenly works now, but if I could avoid using this then that would be great.

as a side note I have this in composer.json

        "maatwebsite/excel": "^2.1",

isaackearl left a reply on Cannot Download Excel Files... (maatwebsite) Even Though They Generate Fine.


Yes I've switched to that now but I actually get the exact same result. I should have been more clear.

isaackearl started a new conversation Cannot Download Excel Files... (maatwebsite) Even Though They Generate Fine.


I'm having serious trouble downloading files that I've generated. Right now I'm using maatwebsite/laravel-excel to generate excel docs and everything works great until I try and download the file!

Here is the function I created that generates my file:

public function generateFileForInvoice($withholdingInvoice)
        /** @var LaravelExcelWriter $file */
        $file = Excel::create($withholdingInvoice->name, function ($excel) use ($withholdingInvoice) {

            /** @var LaravelExcelWriter $excel */
            $excel->sheet('Withholdings', function ($sheet) use ($withholdingInvoice) {
                /** @var \Maatwebsite\Excel\Excel $sheet */
                $sheet->loadView('withholding.invoice', ['withholdingInvoice' => $withholdingInvoice]);

            $excel->sheet('Totals', function ($sheet) use ($withholdingInvoice) {
                /** @var \Maatwebsite\Excel\Excel $sheet */
                $sheet->loadView('withholding.totals', ['withholdingInvoice' => $withholdingInvoice]);



When I hit my endpoint it download a file but it is all garbled and busted and what not.

The crazy part is that the file that gets generated looks perfect if I just open it from the file system where i store it (developing locally).

This has lead me to believe that my headers are messed up or something but I'm fairly certain they are all correct.. this is what I have:

Cache-Control:cache, must-revalidate
Content-Disposition:attachment; filename="1_2017-01-01.xls"
Content-Type:application/; charset=UTF-8
Date:Fri, 13 Jan 2017 08:27:05 GMT
Expires:Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified:Fri, 13 Jan 2017 08:27:05
Server:nginx/1.10.0 (Ubuntu)

I've been messing with this stuff trying to get it to work for awhile now and any help would be appreciated. Another tactic I'm trying is to use the built in laravel function for downloading the file...

        return response()->download($filePath, $filename, $headers);

So I know the file is already generated properly.. I just need to figure out a way to download it through browser where it won't be garbled...

As you can see I can pass in custom headers etc so any tips would be appreciated.


isaackearl started a new conversation Sorting And Paginating Transformed Data... (Fractal API).. Anybody Do This ?

This question may be somewhat advanced and it is a longshot type of question by I'll give it a shot anyway.


I have an api. My api uses Fractal to return transformed data because many of my database tables are complex and I enjoy the power I get with fractal to map out fields and create responses.

Many of the responses I send back are paginated with 1000s of rows.

Naturally I want the user to be able to sort the columns on the table so they can see the data the way they want to.

I must handle the sorting on the backend since I'm paginating the data I must sort it before it gets paginated.


I've realized I don't have a good way to sort since the transformed responses I send out often have data from multiple tables, and/or have column names that differ from the database column name.

One way I've figured out how to do it (badly)... is to do a query that captures all the possible rows (non paginated) and once I have the full collection... I transform the data into a Fractal Collection... then convert that to a laravel collection... and then finally sort it and then manually paginate the result.

Obviously this isn't ideal because it defeats the purpose of paginating to help the performance... essentially makes is so I have to query all the rows every time I change things or sort etc.


Anyway, honestly this seems like it is probably a unique scenario, but if someone is specifically using Fractal with an API and has created a good solution for sorting transformed data efficiently, then any ideas would be appreciated.

Final thought: Right now i'm thinking that for any view that I want to be able to do sorting by multiple columns etc... I'll have to finely craft a custom query using joins and other things... maybe some custom local scopes to apply the sorting...

Anyway just wanted to brainstorm a little Thanks in advance for any thoughts you may have.

04 Oct
2 years ago

isaackearl started a new conversation Extended Mail Notification Channel?

I have a request that I think would be really great but I don't have the time or resources at the moment to do it myself.

The notifications in 5.3 are really great but I think there is definitely room for improvement in the mail notification channel. My request is that someone makes a new notification channel that is essentially an extended mail notification channel.

here there are all sorts of new notification channels being created for laravel 5.3, but I was REALLY surprised that nobody is working on more functionality for the regular mail channel.

The type of features that I think would be really cool are things like:

  1. ability to add attachments
  2. other ways to present data other then just ->line... ie displaying tables or other things. So you can create things like invoices etc.
  3. adding images?
  4. maybe a way to have multiple buttons instead of just 1 action.

Anyway, obviously this is a "request" if anybody else thinks it is a good idea that would be cool if they ran with it. I might get to working on something like this eventually but I would be surprised if nobody else wants to do so notifications can be more of a full email solution.

08 Sep
2 years ago

isaackearl left a reply on What Is The Best Way To Get Large Amount Of Data?

I agree that caching is probably the best idea since the country list won't change often.