Jaytee

Jaytee

Member Since 3 Years Ago

Christchurch, NZ

Software Developer at WSP Opus

Experience Points 107,965
Experience Level 22

2,035 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 447
Lessons
Completed
Best Reply Awards 106
Best Reply
Awards
  • 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

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    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.

01 May
3 weeks ago

Jaytee left a reply on Created And Updated Events Are Both Fired For Model::create()

Yeah so the way it works is that the save method checks to see if the model should be created or updated (based on whether the model already exists etc), and then fire the respective event. I don't believe it fires both, it should fire one or the other.

13 Mar
2 months ago

Jaytee left a reply on How Can I Select Certain Fields Using With()

->with('children:id,name')->get()

Jaytee left a reply on Is There Technically Something Wrong With The "update Method" In This Controller?

There are a couple of things that can be changed, including one issue that is wrong.

  1. Index method, you could just use relationships instead of using the DB Facade to get courses belonging to the user. Setup a relationship on the user model so that you can do $courses = auth()->user()->courses

  2. You can get rid of the Auth:: facade and use a global helper auth()->id(). Just a simple improvement so you don't need to import anything and/or prefix it with \Auth::id()

  3. The edit method is taking in a course, but you're actually passing a collection to the view. ->get() returns a collection. That means you'd need to loop through $course which isn't correct. If you also setup a relationship, then you can once again remove the DB:: facade.

  4. In the update method, you have a $validated variable. You can just pass that to the ->update() method instead of doing update(['title' => $request->title]); etc. ->update($validated)

12 Mar
2 months ago

Jaytee left a reply on Set Faker's Seed Globally For Laravel's Factories

You can override helper functions. Laravel does a function_exists() before creating that helper, so that means if you declare a helper with the same name in bootstrap/app.php, you can override it to use yours.

Jaytee left a reply on About Helpers

You're fine to separate them if you wish.

Helpers that are autoloaded with composer are available in every file, so if you're worried about having too many helpers, you could just create classes with helpers in them, and then import them into the files when you require them. However, Laravel also loads about 70 helpers on every file, so it shouldn't be an issue to have quite a lot of helpers.

10 Mar
2 months ago

Jaytee started a new conversation Unable To Ctrl + Click On Threads

Hey Jeff,

I noticed since the Laracasts refresh, that we can no longer open multiple threads using Ctrl + Click. Instead, we need to either right click > open in new tab, or actually view the thread.

Can this be changed? Some of us like to open up multiple threads so we can jump to them quickly and help resolve them.

Cheers

Jaytee left a reply on What Does A Namespace Actually Do In A Laravel Route ?

Have a read of this. This explains what namespaces are in PHP. Namespaces aren't just used in PHP, they're used in a lot of other languages.

https://daylerees.com/php-namespaces-explained/

The namespace on the route, is to define where the controller is for that route in Laravel. You don't have to use ->namespace(), you can do Route::get('something', 'MyNamespace\[email protected]');

09 Mar
2 months ago

Jaytee left a reply on Whats The Difference ? View::make('index') And View('index')

@snapey You can actually just do view('template') and get the same result bro. The helper will return the make method if at least one argument is passed, otherwise it'll return the factory.

07 Mar
2 months ago

Jaytee left a reply on Base Url

Start looking at the documentation for once Davy. You've been asking bullshit questions for nearly a year and a half now, on everything that is in the documentation, or on the first page in Google. Are you actually going to learn how to code at some point, or are you just gonna milk Laracasts for the answers?

The point of this forum is to help people, yes, but not to help people who can't even consult the documentation, and ask questions multiple times per week, to which the answers can be found in seconds.

15 Feb
3 months ago

Jaytee left a reply on Riddle Me This (PHP Error: No Property On Object)

@jlrdw @snapey Well here's the other fucked up thing.

The name is Rosie.Hewett so definitely not a reserved issue. But, she can log in to other apps fine. Just not this one. However, she's had issues in the past with logging in to the other apps, but for some reason, it lets her in. Whats more is, Her account actually gets created in the database, but the exception is still thrown saying we couldn't find her.

We essentially say if there is no AD User then throw an exception, otherwise create the user. But what happens is, the user gets created from the AD Object, but then that exception is still thrown.

It's almost like its creating first, throwing the exception second, when it should be throwing the exception first and not continuing with creating.

Jaytee started a new conversation Riddle Me This (PHP Error: No Property On Object)

Long time no speak to some of you. Okay, so we use LDAP for authentication at work on our internal server (intranet). I've come across an issue on a new application for one certain user. It's mind boggling shit.

// Active Directory. Does a search for the user's usercode. Gets this from $_SERVER['REMOTE_USER'];

e.g: REMOTE_USER = 'CORP\jth181';

// We do an explode on the remote user, get the usercode (the bit after CORP\); This all works fine

// This also works fine. Returns a user object
$adUser = $ad->getMyDetails();

Above is a basic rundown on how we get a user's credentials etc.

Now, if i run dd() on the $adUser, it's fine, we have a property called usercode. Typical stuff, we use it all the time by passing it through to User::firstOrNew(['usercode' => $adUser->usercode])

Here's where things get fucked up. There is one user who has a completely different structure to her usercode. Usually it's a alpha numeric string, but her's is firstname.lastname

When we do $adUser->usercode on this particular user, PHP throws an error saying the usercode property doesn't exist on the object. Try cast it to an array, and it complains about the index. Weird as fuck.

But yet, we can actually dd() on the object and dd() on $adUser->usercode, but the second we try call it, nope, doesn't work. Yep it's public etc.

Any ideas?

30 Dec
4 months ago

Jaytee left a reply on Laravel Elequent

Take a look at the "where exists" section is: https://laravel.com/docs/master/queries#where-clauses

Alternatively, if you're actually using eloquent (e.g you have a Car model and a Reservation model setup), you can define a relationship to return the results.

26 Dec
4 months ago

Jaytee left a reply on Laravel Cart Package Not Saving Cart Items On Page Refresh

You'll need to show us some code that you have dude, otherwise we can't help.

25 Dec
4 months ago

Jaytee left a reply on I Can't Submit My Form

You've been on Laracasts for like 2 years, and yet still, everyday you ask a simple question. Why don't you try to debug your own shit and actually learn for once?

25 Nov
5 months ago

Jaytee left a reply on How To Save Category In Laravel 5.7 With Vue.js

Are you using the ziggy package to allow you to use route() in JS? If not, that's why you'd be getting the error because axios doesn't have a valid endpoint.

Jaytee left a reply on How To Secure File Uploads

Change the method to this:

return [
    'photos.*' => 'image|mimes:jpeg,bmp,png|max:2000',
    // other validation
]

Jaytee left a reply on Logout Not Working

if you're using the form approach, use an onclick event on the button instead.

<a href="#" onclick="document.getElementById('logout-form').submit();">Logout</a>

21 Apr
1 year ago

Jaytee left a reply on No Default Value

You should of known about mass assignment within one month, never mind one year. 99% of the shit you post is basic stuff.

The username is required to be in the fillable array, otherwise it won't be inserted.

04 Mar
1 year ago

Jaytee left a reply on About Me

The likelihood of you becoming a great developer in one year, is slim.

I've been at it for about 4 years, i'm still not a "great" developer. I'm constantly learning. It took me about a year to actually piece together a basic website without researching.

This stuff takes time. One year is a high target for a milestone.

17 Feb
1 year ago

Jaytee left a reply on Odd Behaviour With Collections.reverseOrder?

This is a PHP forum not a Java forum

06 Feb
1 year ago

Jaytee left a reply on Pusher Not Working, No Push Notifications, Is Echo Working At All?

  1. php artisan queue:work or php artisan queue:listen (run this before anything)

  2. Double check

  3. Yep

  4. No the broadcasting routes in routes/channels.php. You need to have a route for the channel you're trying to push data to. The route needs to either return true or false (true meaning the user is authenticated, false meaning no). Consult the Laravel docs.

Jaytee left a reply on Pusher Not Working, No Push Notifications, Is Echo Working At All?

  1. Make sure the queue is running
  2. Make sure Pusher config is correct
  3. Make sure the broadcast service provider is uncommented
  4. Make sure the broadcast route is setup.
22 Jan
1 year ago

Jaytee left a reply on Change Version Of Bootstrap Installed

@tisuchi The official version of Bootstrap is out now, so it's as simple as one of these:

  1. npm install bootstrap

  2. Modify package.json "bootstrap": "4.0.0"

21 Jan
1 year ago

Jaytee left a reply on Filling The <title>... Controller? Routes?

Some are explicit and yield the title @yield('title') and then fill it for each page, some pass it from the controller, some use the current route for it.

Some pull in a package like this and do it in the controller: https://github.com/artesaos/seotools

All depends on what you want really

Jaytee left a reply on Set Default Value For User

Go with option one to what @Cinek said. I presume you're still in development so rolling back migrations isn't an issue since you should just be working with test/dummy data.

20 Jan
1 year ago

Jaytee left a reply on How Can I Uninstall Laravel-mix Completely From 5.5 ?

Just delete the node_modules folder, then remove laravel mix from package.json then run npm install to install the dependencies again.

Jaytee left a reply on Entrust

Don't comment on stuff that's old @Bhargav960143 .

But to close this topic with a solution: There are better solutions out there now, Bouncer, Spatie's Permissions, A maintained version of Entrust called Laratrust etc.

19 Jan
1 year ago

Jaytee left a reply on Bootstrap Select Into Laravel Collective

Collective is old, and no longer a benefit. Switch to writing regular forms.

18 Jan
1 year ago

Jaytee left a reply on Authorize Null Field On Create But Make It Required On Update

So as per your title, you're just wanting to make the fields nullable on create, and required on update?

Well you should already have two different methods, one for creating and one for updating, so just update the validation rules accordingly.


public function store()
{
    $data = request()->validate([
        'field_one' => 'nullable'
    ]);
}

public function update($theResourceOrID)
{
    $data = request()->validate([
        'field_one' => 'required'
    ]);
}

Jaytee left a reply on Upgrade Laravel Version

Follow the upgrade guide. 5.2 had a different built in auth. Go to Laravel docs and click on the upgrade guide.

Jaytee left a reply on Bootstrap 4 - Fixed Navbar Full Width Collumn

A fixed position is positioned based on the viewport so naturally it won't work.

What you can do, is specify a width for the navbar and then use the left: amount property in CSS to position it with the column.

But with that, you do also need to determine the width of the column on the left so that you know how much to move the navbar left, and of course with different resolutions, it will change.

I would say to use the position: sticky but it's not very well supported.

If you want to take an easier approach, i'd suggest either making the navbar fixed at full width or making the sidebar relative (so when you scroll, it'll disappear).

Jaytee left a reply on NodeJs

Master PHP first, that's something you definitely haven't done yet.

Essentially you use Javascript for the server-side and the client-side. No need to mix with other languages (e.g: PHP for server, JS for client).

01 Jan
1 year ago

Jaytee left a reply on PHPUnit Won't Run One Test In A File But The Rest Are Fine

Make sure you're telling PHPUnit about the test. Either with a doc block or prefixing the function with test_

Doc Block:

/* @test */
26 Dec
1 year ago

Jaytee left a reply on Artisan - Intelligence

Basically, there's two classes in the framework. One named Pluralizer and the other called Inflector.

The inflector houses a log of Regular Expressions to match for the word and then replaces it with the pluralized/singular version of the word.

From what i've tested, and copied from the Inflector class, this is the Regular Expression responsible for the word company

'/([^aeiouy]|qu)y$/i' => 'ies',

And in fact, if you go to regexr.com and paste this in ([^aeiouy]|qu)y It will return a match on the word company.

22 Dec
1 year ago

Jaytee left a reply on Changing Default Tinker Namespace?

Sweet, done and dusted!

Jaytee left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'article_id' Cannot Be Null (SQL: Insert Into `comments` (`body`, `article_id`, `updated_at`, `created_at`) Values (adding New Comment, , 2017-12-22 03:21:15, 2017-12-22 03:21:15))

When using Route Model Binding, Laravel expects the wildcard in the route to match the same as the method parameters.

Your method parameter is accepting an instance of Article Article $article, but your route is defined as accepting a {post}. Change {post} to {article}

Jaytee left a reply on Changing Default Tinker Namespace?

Haven't used Spark, but I can't imagine anything will be different unless it's using a different version of Tinker.

Did you quit and go back into Tinker when you made the change? And I'm not sure what the Spark structure is like, but i'm guessing the User model and Team model is within the app directory, where as all your other models are within a models directory?

Just doing something like User::create() in Tinker, should alias it to YourNamespace\Path\To\User.php

Jaytee left a reply on Any One Knows,where Dd() Is Defined In Laravel?

Could just be a syntax error from yourself, can you post the code where you're using dd().

The helpers file goes untouched unless you personally have touched it, so that shouldn't be the issue.

Jaytee left a reply on Changing Default Tinker Namespace?

Tinker should pick up on the namespace. The version included with 5.5 also allows you to just call the model without including the namespace and it will alias it to the namespace.

14 Dec
1 year ago

Jaytee left a reply on Remember Me Not Working

Remember me only lasts for 2 hours by default.

You can update this value in your env file for the SESSION_LIFETIME. Or if you're using a slightly older version of laravel, you can update the config/session.php file.

The value is in minutes, so for 24 hours, the value should be: 1440

Jaytee left a reply on How To Deal Large Dataset Using Eloquent?

If you have that many records, then it's pointless paginating them all. Just get the most recent ones, perhaps 500 of them and then paginate.

Unless you have absolutely no time on your hands, no one is gonna sit through and paginate through all those records.

13 Dec
1 year ago

Jaytee left a reply on 404 Response For "webhook/stripe" Url For Test Domain?

You updated the webhook URL in stripe to point to the actual domain? And of course, set stripe keys to live keys instead of test keys?

Jaytee left a reply on Is It Worth Javascriptifying The Front-end?

I use Javascript if i can, it makes the website more lively. And it's always great when you don't need to wait for the page to refresh, especially if the server is slow. I find it much better looking at a loading icon rather than the browser going nuts trying to load stuff.

Jaytee left a reply on Laravel - Action App\Http\Controllers\post-show Not Defined

The action is used to call a controller method, not a named route. Whenever you use the as array key or name() method on a route, it becomes a named route, not an action.

The action method would be something like action('[email protected]').

@jorpedito The second parameter for the route method isn't required to be an array as there is only one wildcard

Jaytee left a reply on Is It Worth Javascriptifying The Front-end?

I don't usually ajax a forum thread, because it's not really a live chat where users are constantly commenting. But ajaxing won't make the replies show without refreshing, unless you're polling the server for new replies or using sockets.

It's entirely up to you whether you want to add live functionality, in some cases it's definitely beneficial, in others, not so much, but more of a nice feature.

Jaytee left a reply on Laravel - Action App\Http\Controllers\post-show Not Defined

The error is with this:

<a href="{{ URL::action('post-show', $post->slug)}}">{{$post->title}}</a>

Change it to this:

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

Jaytee left a reply on Moved From BS3 To BS4 - Problem W. Spacing Between <NAV> And <MAIN>

It's just the way it is. I mean, a simple solution would be to just add spacing by yourself??

28 Nov
1 year ago

Jaytee left a reply on Problem With Installing Laravel

Make sure you're actually installing the whole of Laravel through composer, and not just copying the composer.json file into an empty folder.

either install through the laravel installer and then run laravel new someappname

or install directly through composer composer create-project laravel/laravel someappname

18 Nov
1 year ago

Jaytee left a reply on Crudbooster::admin_template

What does this mean? https://laravel.com/docs/master/packages#views

Read that. Try reading the docs, multiple times i've seen you not even bother to try read the docs or actually learn PHP now. We're here to help, not build your whole app.

I cannot find where the admin_template is?

Look in the vendor folder and look for a crudbooster folder. It should be in there. Or see if you can publish any assets using php artisan vendor:publish and look for crudbooster