Member Since 5 Years Ago

Portland, OR

Experience Points 934,840
Experience Level 50

0 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 1029
Best Reply Awards 1258
Best Reply
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement


    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement


    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

21 Feb
1 day ago

Cronix left a reply on 30Gb Of Mysql Temp Files And Can't Figure Out Why

Another possibility is temp tables are created per connection. If you have 50 open connections using a query that needs a temp table, that's 50 temp tables it creates. It could also have to do with the number of indexes you have, and whether those are used in temp tables.

There might be some useful info in here for you as well:

Cronix left a reply on How Did It End As An Array?

You can't assume people will only be clicking on links you provide. Some will mess with the url to try to hack in. Some will mess with it using their browser dev tools and change form inputs and stuff. Never trust any user supplied data, that includes get requests (the id is user supplied data - anyone can change the number in the url) and all data entered in forms. It all needs to be verified and validated before processing, or you will get owned. Security first. Always.

Cronix left a reply on How To Get A File Size

If you find one, let me know! One of my projects does a heck of a lot of audio/video conversion. I haven't found anything that is nearly as powerful or has all of the needed features and keeps up with newer codecs, which are coming out all of the time. It's definitely a swiss army knife kind of tool. Those are always pretty complicated with lots of options, most of which you'll never use. The actual app is a commandline tool. There are a lot of php (and other language) wrappers for it, but it's a binary under the hood. You could just use exec() and manually use the CLI tool. That's basically all the wrappers are doing.

Cronix left a reply on How Did It End As An Array?

@lestah You're welcome. I'd still highly advise you to use firstOrFail() instead of first() in this case.

To see why, go to the url with an id that doesn't exist, like

Your app will blow up and get undefined property errors, because you don't ever check wither the ID exists. You assume you will always get a result, and then use the result in the view. A user should never see your errors.

If you use firstOrFail(), you'd get a 404 error when the $id doesn't exist, which is appropriate. It can't find the thing you're telling it to find - 404 - not found.

Cronix left a reply on Laravel Login Doesn't Seem To Work - Laravel 5.7

@george1 I'm glad you got it working by taking my advice, but not sure why you marked your solution as the answer though?

Had you not been in such a hurry and read the documentation, this would have been a lot easier for you. It literally takes like a minute to get default auth working (php artisan make: auth followed by php artisan migrate assuming your db connection is set up properly). I'd highly suggest reading the docs cover to cover before using laravel. The steps for creating the auth system are pretty clear, and it already has migrations to create the users table and other things needed:

Cronix left a reply on Get Only The Values From The Array

$collection = collect([0 => 2, 1 => 3, 2 => 4]);


Cronix left a reply on Forge Deployment Issue

It's probably temporary. SSH into the server and see if you can ping Do you get a response with their IP?

Cronix left a reply on How To Get A File Size

@nYou can use FFMpeg to get video lengths, frame dimensions, audio lengths, etc., in addition to being able to convert files between just about any format.

It's complex, but I don't think you'll find a better tool for the job. It supports about all video/audio codecs so it works on just about anything.

There are laravel wrappers for it as well, but it doesn't do everything the main library can do.

Cronix left a reply on Cleaner Controllers

Of course validation wasn't discussed here, are you validating the data.

@jlrdw Nope, it wasn't asked about. I was answering the question that was actually asked.

20 Feb
2 days ago

Cronix left a reply on Standard Deviation Funtion?

@fbc Cool :) After looking at the code in the article again, I'd check if the array count was 0 and immediately return 0 to prevent a division by 0 error further down.

I guess just pass an empty array to the method and see if it blows up. It looks like it would.

Cronix left a reply on Standard Deviation Funtion?

Indeed, I misspoke.

Cronix left a reply on Standard Deviation Funtion?

@roborobok I was thinking of catch (\Exception $ex) where you do have to prefix it with the global prefix operator.

Cronix left a reply on Standard Deviation Funtion?

You'd think, but I have encountered situations where that is not true and base commands needed a . Just thought I'd throw it out there as it's something I've encountered about 2 years ago in a strange situation.


Cronix left a reply on Why Does This Website Go Back In Time When I Refresh It?

Hmm, well I've been refreshing it for a few minutes now and I'm not seeing any counters updating one way or the other. Been trying on the homepage as well as a few articles. The comment count seems to be consistent for me.

Cronix left a reply on Why Does This Website Go Back In Time When I Refresh It?

I don't remember ever seeing a site with that situation, so I wouldn't say it's common at all. It could be a lot of things including cache, multiple servers and they're not in sync and stuff like that. What site? You've got me curious. Is this something anyone (anonymous) can see without having to create an account?

Cronix left a reply on Standard Deviation Funtion?

You can make a helper function for determining the standard deviation. There might be some packages as well, but it's pretty small to add in. No, there's nothing native in laravel for it.

Cronix left a reply on Query Where On Latest Row In Relationship Table?

Yes, you can use whereHas, and only return users where the user_log relationship has active=false.

Cronix left a reply on Configuring Phpmyadmin On Nginx Server For Laravel

You should be able to access the database via phpadmin remotely. It shouldn't be a part of your laravel project or code.

Is this just for testing (like to see data), or, are you actually trying to have it be an actual part of your app?

Cronix left a reply on Building Form With Questions

@joshblevins Would you mind editing your post so all of the code is within code blocks? That's hard to decipher up top.

Cronix left a reply on Cleaner Controllers

Im answering their actual question. You are not.

Do you know what typecasting does?

$request->has() returns a boolean (true/false). Casting that to an int would force it to 0 or 1.

Cronix left a reply on Cleaner Controllers

@jlrdw That's fine. I was just meaning

$somevar = (int)$request->has('Viewable');

is shorter/cleaner than

$somevar = ($request->has('Viewable')  ? '1' : '0');
// or
$somevar = (Request::has('Viewable) ? '1' : '0');
// or
$somevar = Request::has('adopted') ? '1' : '0';

Cronix left a reply on Cleaner Controllers

A way to be able to do it as easily as you are showing Instructor::update(request(['FirstName', 'LastName'])); would be to do something like

<input type="hidden" name="checkboxname" value="0">
<input type="checkbox" name="checkboxname" value="1">

So if the checkbox isn't checked (meaning it won't be submitted), checkboxname=0, if it is checked, checkboxname=1.

@jlrdw Typecasting a bool to an int is shorter: $somevar = (int)$request->has('Viewable');

Cronix left a reply on How Did It End As An Array?

At what point do you get the actual error? Is it the controller, or the view?

Try eliminating the view first by "dump and die (dd())" the variable before it gets to the view. You should use dd() instead of echo "<pre>"; print_r($productDetails); die;. It does a better job and is only 2 chars.

    public function addAttributes(Request $request, $id=null)
        $productDetails = Product::with('attributes')->where(['id' => $id])->firstOrFail();
        return view('admin.products.add_attributes', compact('productDetails'));

Can you expand the attributes section of the output and see the correct data for that model (click triangle next to "attributes" from the dd())? Can you do the same for the with property and see the individual attribute objects? If so, the problem is in the view.

What you showed above... you need to click on the "attributes" to see the data for that's there. It says there are 10 elements in it.

Cronix left a reply on Yet Another 1215 Foreign Key Question!?

is nullable as well? Foreign keys should basically match the the parent keys definition.

Cronix left a reply on How Did It End As An Array?

@uniels Great observation! I don't think it messes the query itself up (since with('attributes') was used and produced results), but it definitely could in the view when accessing it as a property, like $model->attributes.

Cronix left a reply on How Did It End As An Array?

That shouldn't be caused by anything I suggested or showed. The only difference between your query and mine was using firstOrFail() instead of first().

What is $id? What is your route?

Troubleshoot it.

  1. dd($id); - is $id what you expect? If not, why?
  2. remove the relationship from the query and dd() the result immediately. Then hit the route again. Does that work? If so,
  3. Add back in the relationship

etc. Simplify it and add back complexity until it breaks. Then you can pinpoint the actual problem.

Cronix left a reply on Object Oriented Programming In PHP

I didn't say faster was better all by itself. Doctors use Google all of the time. Of course they went through medical school, but they still know where to get info when they need it, which is quite often. Studies and new drugs are being introduced daily. Medicine moves fast. A good deal of what you learn in medical school becomes outdated rapidly. So, for your example and how it relates to this post, a doctor asking a question on a forum vs a doctor googling and getting to the pertinent info on their own.

Of course it has to do with getting the correct answer, first. Point is to not wait around hours/days for the answers to be given to you when you can research it yourself. This topic is 60 years old. There is a wealth of very good information on it in all languages conceivable.

Cronix left a reply on Object Oriented Programming In PHP

Meanwhile, your competition is using Google to get answers faster than you are and will outperform you and get more jobs. Most of a devs job is problem solving - and researching. You can ask questions and wait for x hours/days to get an answer if you want to, but you're not doing your career any favors by doing so.

Look at it from a practical standpoint. You have 2 devs working for you. One can research and learn independently and the other doesn't. The first completes projects faster which makes them more valuable, and the second takes longer to complete projects. Which do you want to be? Which do you think your prospective employers will be expecting? Who will get more assignments and who will eventually be let go?

Cronix left a reply on How Did It End As An Array?

    public function addAttributes(Request $request, $id=null)
        $productDetails = Product::with('attributes')->where(['id' => $id])->first();

        return view('admin.products.add_attributes', compact('productDetails'));
@foreach($productDetails->attributes as $attribute)
    {{ $attribute->id }}

You better be sure you get a result first. You're assuming you are but never check. For instance, if the $id doesn't exist you will get errors for trying to use a property on an object that doesn't exist. You should basically always use firstOrFail($id) instead of just first(). That way you will get an appropriate 404 page not found error instead if the $id didn't exist.

Cronix left a reply on Laracasts: Why Browse Is Not Just A List Of Every Episode?

I believe it's a caching issue and they need to clear/update the cache when a new item is added (or published?)

Cronix left a reply on Class 'App\ProductsAttributes' What Does It Mean?

@lestah Sure thing. One thing that would be good to get in the habit of doing is using your IDE's search functionality. If you get an error message about a specific thing, like App\ProductsAttributes, then just do a global search in your project for that string. If you're using a decent IDE, it would also show errors for that class (like it would be underlined in red or something and hovering over it would say it can't find the class or whatever) where you used it if it couldn't find it.

Cronix left a reply on Class 'App\ProductsAttributes' What Does It Mean?

is that file named exactly /app/ProductAttributes.php and is it class ProductAttributes extends Model inside?

Everything needs to have an s in Attributes, including

use App\ProductsAttribute;

Cronix left a reply on Class 'App\ProductsAttributes' What Does It Mean?

return $this->hasMany('App\ProductsAttributes','product_id');
use App\ProductsAttribute;

Again, which is it? ProductAttribute or ProductAttributes. You're using both. One is not right.

Cronix left a reply on Class 'App\ProductsAttributes' What Does It Mean?

Which is it actually called...Attributes with an s, or Attribute without an s? You're showing both.

19 Feb
3 days ago

Cronix left a reply on Replace String With Function

@You might be able to shorten that a bit

@foreach(explode('[image]', $article->body) as $part)
    <p>{{ $part }}</p>
    @if($loop->iteration < 4)
        {{ $article->getFirstMedia('image' . $loop->iteration) }}

Cronix left a reply on Help With Ubuntu Enviroment Commands And General Tips

~ is the current users home dir. cd is change directory. It's changing the directory to the current users home dir, which is usually /root or /home/{username} for others.

| is pipe. It sends the output to another command. In chis case, it's downloading composer and sending the installer to php, because it's a php script so it needs to run the installer through the php commandline.

There are literally millions of guides/tutorials for Ubuntu and Linux in general. Most linux systems use the same basic commands (unix), but have different package managers (apt vs yum, etc) and include different packages.

Basically, just google whatever questions you have, and google for ubuntu tutorials, etc. You'll always find tons of answers. Unix/Linux/Ubuntu are all very old.

Cronix left a reply on Don't Show Form If Auth()->user Has Submitted Form

All routes going to the BidController would start with /bid in my book. It doesn't matter what "page" the form or whatever is on. It matters where it submits to. If it's dealing with a bid, it should have bid in the url, and use the bid controller.

I really like using resource controllers ( ). They contain all of the methods needed for a controller, and also create the routes with a simple single command, like Route::resource('jobs', 'JobsController'); which is a lot simpler than

Route::get('/jobs', '[email protected]')->name('jobs.index');
Route::get('/jobs/create', '[email protected]');
Route::post('/jobs', '[email protected]');
Route::get('/jobs/{job}/edit', '[email protected]');
Route::get('/jobs/{job}', '[email protected]')->name('showjobedits');
Route::patch('/jobs/{job}', '[email protected]');

But for now, just make all of your urls unique and not reuse them for different things.

Cronix left a reply on Don't Show Form If Auth()->user Has Submitted Form

There are several things wrong in that route file. Multiple controllers responding to the same endpoint. Your endpoints are not unique. The way routing works, it starts at the top of the file and works its way down line by line to see if the request matches. As soon as it finds the first one that will satisfy the condition, it will use that and ignore the others. I think @snapey pointed out the specific problem in this case, but you also have

Route::patch('/jobs/{job}', '[email protected]');
Route::patch('/jobs/{job}', '[email protected]');

same url, same method (patch) going to 2 different controllers. The BidsController one will never get called because the first route would always match. The 2nd one should be Route::patch('/bids/{job}') or something more unique to what it's actually doing. It's not a job url, it's a bid url.

Cronix left a reply on Laravel Login Doesn't Seem To Work - Laravel 5.7

You'd still have your custom migrations in your old project, like for blog? After you get default auth working (no custom code at all) then start to copy things over one by one. So just copy your migration file over to the new project after auth is working along with the blog controller and any other blog-related code.

All you want to do right now is get the default auth working with no other alterations. If you start mucking around and it breaks, you will have a much harder time figuring out where it went wrong (like we're doing now). So start from a known working system, then start adding your custom code back piece by piece, testing it along the way so you know at which point something breaks.

Cronix left a reply on Don't Show Form If Auth()->user Has Submitted Form

Hard to know. Is the url you are accessing going to the correct controller/method from the route? Are you actually showing the correct method for the route being accessed?

Cronix left a reply on Laravel Login Doesn't Seem To Work - Laravel 5.7

I'd start a new project. The reason why I say that is it would be easiest for you. You are learning laravel and have probably changed something somewhere that you aren't aware of or remember doing, and we can sit here asking a million questions about the setup. It looks like you've just started this project, so I'd just start a new one, and try to get default auth working. It works out of the box after running the various auth commands. If it doesn't, something isn't set up right and I'd start looking at whatever you're using for a dev server. I'd also watch the video series I linked to before doing anything. After you get default auth working, then add back your blogcontroller. Get that working, then add more.

Cronix left a reply on Laravel Login Doesn't Seem To Work - Laravel 5.7

@GEORGE1 - Yes, those are custom routes. Laravels auth has Auth::routes() which provides all routes needed, which is mapped to the correct controllers/methods.

How do you know for sure your database is set up? You've run the migrations and know the tables are present? Can you query and actually retrieve data? Can you see your user object in it (you said you had a user created)?

All of the auth controllers should be put back to stock condition, like here:

remove these routes and just keep Auth::routes()

    Route::get('auth/login', 'Auth\[email protected]');
    Route::post('auth/login', 'Auth\[email protected]');
    Route::get('/logout', '\App\Http\Controllers\Auth\[email protected]')->name('logout' );

    Route::get('auth/register', 'Auth\[email protected]');
    Route::post('auth/register', 'Auth\[email protected]');

Cronix left a reply on Don't Show Form If Auth()->user Has Submitted Form

Another puzzle is where $job comes from and why you're not getting an error about that. It just mysteriously appears in the method without being passed or created, and then you use $job to get $hasbidinterest.

Cronix left a reply on Laravel Login Doesn't Seem To Work - Laravel 5.7

All config settings are in the various files in the /config dir. Most of those are variables are dynamically set in the .env file. If you don't know how to set laravel up, I think you're working too fast here.

So far, I don't understand anything you're doing. There is no need (from what I can tell of your code) to alter any of the default auth settings. You should get the default auth working before trying to customize it.

I'd get rid of all of your custom code and routes and use the defaults and use the Auth::routes() route. That works out of the box unless you have larger issues (server related). Once that is working, then alter it if needed.

Cronix left a reply on Newbie: Using The Same Variable Name For Foreach Loop?

Yeah, you overwrite $news.

try this.

$news = news::all();

//check news

//do your foreach overwriting $news
foreach($news as $news) {
    echo $news->story;

// now check $news again

if $news had 5 items originally, now it only has 1. The last one.

Cronix left a reply on Laravel/Ajax

When you create events, they get applied to what is currently on the page. So you'd have to add the same events on anything you add dynamically to the dom. A workaround for that is event delegation, where you target the parent div and delegate to the children of a given class. Then if you add a new child with that class, it picks up on the other events.

Cronix left a reply on Best Way For Store Data In Database?

@snapey Hah, yes. People need to learn more about what actual proper database design is. First Normal Form (1NF), etc.

Cronix left a reply on We Want To Add Error Messages To Validator Variable For Custom Login

You also never want to specifically tell someone what was wrong with the login. If you say the password is bad, that tells the hacker that at least the account exists. It's best to be generic and just say the credentials didn't match.

Cronix left a reply on Laravel Relationship Suggestion

The pivot table is the correct solution. You shouldn't have a column containing multiple ids. You can't index that and it will get slower and slower as the tables grow. You also can't use relationships or joins on them without a bunch of hacky workarounds because that's not how a relational database works.