Member Since 3 Years Ago

Buffalo, NY

Experience Points 17,620
Experience Level 4

2,380 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 83
Best Reply Awards 11
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.

29 May
3 months ago

kobear left a reply on Logging In Laravel

Can this info be discerned from the nginx/apache log files? If it can, then it is best to let request logging be done there.

If the data you want cannot be obtained there, then definitely decouple the logging action from your session views.

Log::info is fine in moderation. I would not have it all over the place in a production application.

21 May
3 months ago

kobear left a reply on Database Driver For Azure SQL

@dipakrataniagile Have you tried the regular Microsoft SQL driver? Depending on which Azure SQL platform you are using, it is just PaaS Microsoft SQL server.

kobear left a reply on Scaling Laravel - Required Infrasturcture For A PaaS Application

@ACE - DataDog and/or New Relic are your friend in this case. There are a couple of other options in this space, such as App Dynamics (now Cisco), and Dynatrace. If you want to stick with open solutions, you could look at using The Open Tracing Project ( https://opentracing.io/ )

re: App structure if you want to make sure you can scale it all:

  • load balance the app. (That is just because I prefer to have failover for user interface)
  • load balance your cache layer.
  • load balance your queue workers. (This is where you will get the most gains).

DB's are best left on a single node, unless you want to have Active/Passive fault failover.

Cron does not load balance - it is a local Unix utility. You could use a system like DKron ( https://github.com/victorcoder/dkron ), but that seems overkill.

So, your cron server could just kick off the job that seeds the queue workers to send the messages out, then when SMS messages are returned (via webhook presumably), other workers could process those. That way the load and magic happens on the load balanced queue worker layer.

Good luck!

kobear left a reply on Slow Queries/connections With Eloquent, Always Over 1600ms

@CRISTIAN9509 - Glad to hear that! Could you please mark my response as the answer? Thanks!

16 May
4 months ago

kobear left a reply on Slow Queries/connections With Eloquent, Always Over 1600ms

@Curious if you have tried either of my suggestions or if you found something else.

kobear left a reply on Prevent White Flash

@MADMAKS - I would bet that your setup is the culprit. It also depends on what browser you are using, how complex your blade templates are (nested, inherited, etc). Here are some things that I would try.

  • Turn on browser debugging. Look at your network transmissions from the page when you do a download. Is the time to first buffer/response taking 500ms, or is there a subcomponent that is taking a long time.

  • Make sure it is not the browser: Sometimes, depending on the browser, it will turn white while it is waiting for a response from the server.

  • Try running the Laravel server on a non-USB stick setup: I bet it will run faster.

kobear left a reply on Best Practice For Validation And Dry Principle

Check this out. Looks like it would do what you want:


  • Automatic creation of Javascript validation based on your Validation Rules or FormRequest, no Javascript coding required.
  • Supports other validation packages.
  • AJAX validation for ActiveURL, Unique and Exists Rules, Custom Validation Rules and other validation packages
  • Unobtrusive integration, you can use without Laravel Form Builder
  • The package uses Jquery Validation Plugin bundled in provided script.
  • Uses Laravel Localization to translate messages.
07 May
4 months ago

kobear left a reply on Slow Queries/connections With Eloquent, Always Over 1600ms

@CRISTIAN9509 - Some things you could try in AWS:

  1. Move the EC2 instance and the RDS into their own VPC. That should give you more control over the IP addressing.

  2. On your EC2 instance, setup a resolving/caching DNS bind server. It will cache responses from the AWS DNS servers so it is faster, but receive zone updates when the TTL expires on the DNS record.

30 Apr
4 months ago

kobear left a reply on Dynamic Number Of Workers

Sorry for the late response. What I do is I have a pool of workers that are managed by Horizon. The Horizon config has the 'balance' value set to auto. That way when the queues are idle, it splits the workers assigned between the queues that are defined, but when there is work to do in one queue, and not others, it dynamically changes those workers to process the other queues that have work ready.

For example, I have 2 queues and 40 workers defined. At idle, each queue has 20 workers assigned, but when items are assigned to the queue (generally there is a 100/1 ratio of items in the queues), it dynamically moves the queue workers to where the work needs to be done.

I hope that helps you.

21 Mar
5 months ago

kobear left a reply on Dynamic Number Of Workers

@snare Do you have more than one queue that needs workers assigned?

21 Dec
8 months ago

kobear left a reply on Adding New API Endpoint

@stevecove my bad, you are absolutely right. Missed that detail. Thanks

kobear left a reply on How To Check Database Every Second With Laravel

@k0tkin thinking about this more, what I would do is use an event dispatcher right in your controller when you get a trade created.

Here is what I would do right off the top of my head:

  1. User creates a trade request in a form, posts to a controller, and the controller creates a trade record.
  2. Controller also dispatches a 'TradeExecute' job specifying the time the trade window (start/end).
  3. You can have as many job execution processes running in the background as you think you would need to handle all the load.
  4. Once the TradeExecute job is complete, just have it update the trade record with the status of the trade execution.

This way, your processing queue is acting as your keepalive. If there is something to process in that timeframe, then you execute it.

Check out https://laravel.com/docs/5.7/horizon as it helps you manage the queue executions

kobear left a reply on Adding New API Endpoint

Model class namespace is correct

In your code Snippet you have

namespace App\Http\Models;

If that is the case, then your use statement should reflect that:

use App\Http\Models\MovieResource;

As for where you reference the table, that is in the model class. By default, Laravel tries to find the table by pluralizing the class name. In this case, the table name would be movieresources

But you can hard code what table it is by including the following after your class declaration

protected $table="<table_name>";

See https://laravel.com/docs/5.7/eloquent#eloquent-model-conventions for more info

kobear left a reply on Adding New API Endpoint

Are you including the reference to the MovieResource model in your controller?

use App\MovieResource;

Also, your namespace for the model class is wrong, I think. It should be

namespace App;

kobear left a reply on Data Available On Every Page

+1 for @talinon's answer

kobear left a reply on Are Long Waiting Times A Must Or Bad Development?

In my experience, sadly, the "...may take up to 7 days to process..." means that some poor human has to click a button to process that request. That may be due to lack of automation, or on purpose to make leaving a list painful ;)

kobear left a reply on Best Practice For Checking Relationship Between Models?

Try this:

$p = Auth::user()->has('posts')->with('posts')->first();

kobear left a reply on How To Check Database Every Second With Laravel

Depending on what DB platform you are using, you could alternatively create triggers on insert into that table that then calls a script that dispatches a job to handle the record.

04 Dec
9 months ago

kobear left a reply on Is Docker Good For A Real Time System?

I need a 1:1 performance for my app...

If you mean that you want to extract every bit of performance that a server compute environment has, the only way you will achieve that is to have your own colocated hardware in a datacenter with no virtualization at all.

However, there are very few instances in which I would think that would be advantageous. You would get better performance and scalability by leveraging virtualization paired with horizontal scaling using either docker an elastic compute stack like AWS Beanstalk.

Or am I incorrect in the assumption of what your question is?

01 Dec
9 months ago

kobear left a reply on What Am I Missing Out If I'm Not Using A VM/Container For My Development Setup?

One of the advantages of using docker is that you can have a docker image file for each version of software you are using and swap them out for testing and upgrades. Imagine being able to test on Laravel 5.4 then on 5.8 just by changing one line in a YAML file. Or with PHP. Or mysql. Or redis.

On the other hand, it makes managing things a little more complicated than those that are used to setup_and_install_everything_i_need.sh

29 Nov
9 months ago

kobear left a reply on Need Help With Big Query For Family Tree

@TOMMY001 - try using artisan tinker to load that query, but instead of running it with ->get(), use ->toSql(). That will output the query that Laravel uses. Then try running that query in phpmyadmin to see what it is doing wrong.

kobear left a reply on Ajax

@SHEZ1983 - In most implementations, yes, Ajax is a wrapper for XMLHttpRequest. But XMLHttpRequest is in turn "just a wrapper" for socket connections over HTTP/S connections to a webserver without the overhead of a full browser page reload.

There are alternatives out there, like Fetch API ( https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API ). But YMMV when stepping away from XMLHttpRequest.

kobear left a reply on Laravel New Files Missing Index.html, Index.php, And .htaccess

@davestead Reverse proxy is useful for many instances. Technically, a "load balancer" is a reverse proxy with logic that spreads the incoming load across proxied assets.

For an API, you can use a reverse proxy to have your API code highly available with two instances of Laravel. If you upgrade code, you just do them one at a time, removing the "under maintenance" instance out of the load balancer temporarily.

17 Nov
9 months ago

kobear left a reply on How Do You Guys Organize Your Assets?

For organizing, I generally leave standalone scripts in assets/js. If it is a library that I download and upgrade, I put those in subfolders with a symbolic link to the library I am using.

For conditionally including code, I use @stack("scripts"). Stack allows you to include code from all the templates you are using.

kobear left a reply on How To Monitor Status On Dependent Api Systems

As @shez1983 says, there are those options. Another option is to check if the service has a status page that shows any service impacting issues. I know AWS has the AWS Health API.

You could leverage those service dashboards, and depending if they have a RSS feed, API, or just a web page, you could gather that info and set expectations for you own users through your own status page.

kobear left a reply on Ajax

@cronix You are absolutely right. As a matter of fact, in 1999 I wrote a site that used XMLHttpRequest for most of the page loading. A couple of years later I saw an article about how Google was using this new shiny thing called "AJAX" and I was pissed off and started calling it "KJAX" because I was using it way before they were. lol

25 Jul
1 year ago

kobear left a reply on Which Laptop To Buy?

Get a Linux or MacOSX based laptop. Mac's are expensive, and if you are not already in the Apple ecosystem, not sure it is worth it. And with the recalls going on, along with other people's experiences, maybe stay away from new product for a while.

I personally got an early 2017 MBP that does not have the butterfly button keyboard and I love it. Works great with Valet, and much more comfortable to use the terminal than Microsoft WSL.

But honestly, if you are budget minded, get a refurbished laptop, load it up with memory, and install your favorite flavor of Linux on it.

20 Jun
1 year ago

kobear left a reply on Calculate Dates In Mysql Using Carbon And Laravel

You can do a raw DB query using MOD() on the original hire date

Assuming EMPLOYEES table that has a datetime field named HIRE_DATE


kobear left a reply on How Do I Join Two Queries And Then Paginate

@ashitvora as long as you have some kind of primary/foreign key relationship between the the two tables, you could use a JOIN statement, then paginate those results.

21 Dec
1 year ago

kobear left a reply on UpdateOrCreate Does Not Insert Anything Within My Db

Do any exceptions get caught when you try ... catch that code?

20 Dec
1 year ago

kobear left a reply on Very Very Slow Query...how To Speed Up

@gstoa Laravel Debugbar is particularly useful because it lists the individual SQL query response times. This is extremely valuable when you have a page that has many different DB queries, and therefore you can focus on the exact queries that are taking longer than optimal.

kobear left a reply on Is It Hurt To Give Every Page A Controller?

Buck the trend - "Everyone shall use closure functions!" ;-)

kobear left a reply on How To Prevent Malicious Scripting When Using WYSIWYG Editor?

Couple things I would do....

  1. Write some code that sanitizes any <script> ... </script>, <iframe> ... </iframe>, etc. blocks both when inserting into database and prior to rendering.
  2. Most WSIWYG editors allow you to disable any kind of manual editing of HTML. Make sure you do that.
18 Dec
1 year ago
13 Dec
1 year ago

kobear left a reply on Very Very Slow Query...how To Speed Up

@deansatch My bad. I got the chaining incorrect for toSql().

toSql() replaces the get() function in the chain, and only returns the SQL query without running it.

So you code would be

 $studios = \App\Studio::
        withCount(['classes' => $subQuery])
        ->withCount(['bookings' => $subQuery2])

kobear left a reply on Very Very Slow Query...how To Speed Up

@deansatch Check my updated answer

kobear left a reply on Very Very Slow Query...how To Speed Up

What database platform is it?

Some general steps that I use to troubleshoot database performance issues (on MySQL):

  • In artisan tinker chain your select statement into ->toSql() like so:
 $studios = \App\Studio::
        withCount(['classes' => $subQuery])
        ->withCount(['bookings' => $subQuery2])

This will output the raw SQL that is sent to the DB server from Eloquent.

  • Run that raw SQL statement directly against the mySQL database, but prepend EXPLAIN. This will give you an idea of the indexing that is used for the query.

I am betting that you are missing some kind of index in the database, probably on the datetime field.

12 Dec
1 year ago

kobear left a reply on Query Vs ForEach Loop, Which One Has The Better Performance?

IMHO, I always try to make the database do as much of the work for me as possible. It is designed for this purpose, so if you design your schema properly, including indexing, whatever work you can do at the database layer will always speed up your application.

So, with that in mind, #1 is the more efficient, faster method.

kobear left a reply on Why Do I Get This Error - Trying To Get Property Of Non-object

@tundeogunde I second what @Snapey said. Even if you eager load the related records, if it is null it will throw this error.

Another way to do this with a blade directive would be to use @isset

 @foreach ($enrolments as $enrolment)
        <div class="row">                                   

Anytime I render a related model from inside a blade document, I ALWAYS use logic similar to this to ensure that if there is no related record returned, no exceptions are thrown.

11 Dec
1 year ago

kobear left a reply on What Is Correct Placement Of Js And Css In Blade View?

Page specific CSS could be put in another section in the head element (after the include)

Js I usually put in the “end-scripts” push area

09 Dec
1 year ago

kobear left a reply on Remove Unwanted Text From Database

@mlazuardy I would reverse those. Strip the html tags first, them string limit.

$post->body = str_limit(strip_tags($requset->body));

kobear left a reply on Database Design Advice

@mjoc1985 Glad that worked for you. Good luck.

08 Dec
1 year ago

kobear left a reply on Global $user Data Across All Controllers?

Session variables are ok, imho. Other ways you could accomplish it involve extending the Controller class, or other such shenanigans. Which then cause problems when you upgrade, etc.

kobear left a reply on Global $user Data Across All Controllers?

You could store it in a session variable

$_SESSION["user"] = Auth::user();

kobear left a reply on What Is Correct Placement Of Js And Css In Blade View?

@dreamxyz Placement of CSS and JS resources usually depends on what the library prescribes, but I usually put CSS first, then JS.

Also, what I do most times is include some @stacks in my master blade template at the top and bottom. Then, when I make my individual blade templates with sections, I @push Javascript or CSS that is specific to that template into a @stack on the master template.

Below is a typical master blade template (index) that I use for a project.

<!DOCTYPE html>
<html lang="en">

      <!-- Begin CDN Content for frameworks -->
      <!-- End CDN Content for frameworks -->

      <!-- Begin Stacked Libraries  -->
      <!-- End Stacked Libraries  -->

      <!-- Begin Stacked JavaScripts from template heirarchy -->
      <!-- End Stacked JavaScripts from template heirarchy -->


And on a typical subtemplate


   <!--  blah blah blah, fancy HTML to impress folks -->

      <script src="https://code.jquery.com/jquery-3.2.1.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/patternfly/3.27.5/js/patternfly.js"></script>
      <script src="https://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
      <script src="/assets/js/c3.min.js"></script>
      <script src="/assets/js/d3.v3.js"></script>
      <script src="/assets/js/jquery.matchHeight-min.js"></script>

    $(document).ready(function() {
        // blah blah blah, fancy jQuery stuff to impress other folks

kobear left a reply on HTML Forms Vs Laravel-form-builder Vs Forms & HTML

I am with @robrogers3. Maybe I am just old school, but I do not see the big advantage of having Form builders. Forms are easy enough to manage without all the extra baggage of builder code.

kobear left a reply on Could Not Find Driver Error In Laravel 5.5

What is the output of running the php-mysql install command?

07 Dec
1 year ago

kobear left a reply on Could Not Find Driver Error In Laravel 5.5

@afoysal MySQL support did not get installed with PHP.

Try running the following command

sudo apt-get install php-mysql

Then restart apache and try again.