Jaytee

at Student at Ara Institute

Experience

96,465

105 Best Reply Awards

  • Member Since 2 Years Ago
  • 368 Lessons Completed
  • 1 Favorite

15th October, 2017

Jaytee left a reply on Best Way To Become A 'web Programmer' • 4 days ago

Strangely, I'm at the point where i can help people better than i can code lol.

I've been procrastinating for the past two months, to sit down and have a good coding session to finish up my work. Yet if someone asks for help, i'm there within 1 minute and helping.

Can anyone else relate? Or am i just burnt out?

Jaytee left a reply on Can't Get Thread_is Even Though Followed As Shown In Series 'Lets's Build Forum With Laravel' • 4 days ago

If you're passing the thread in via route model binding, then i believe strict wildcard checking comes in to play.

You'll need to change the wildcard from {id} to {thread}.

12th October, 2017

Jaytee left a reply on Problem With Custom Validation Rule • 6 days ago

Be sure that you have:

  1. Laravel 5.5
  2. Updated the Laravel installer
  3. Imported the rule class

11th October, 2017

Jaytee left a reply on Limit No Longer Works As Intended After Eager Loading? • 1 week ago

Try the take() method instead.

Or try this approach in the controller:

$replies = $thread->replies()->with(['user.forumBadges' => function ($query) {
    $query->orderBy('display_order', 'asc')->take(5);
}]);

And then remove the orderBy and take from the method on the model.

Jaytee left a reply on Instantiating A Class (from A Laravel Package) Inside Of A Controller • 1 week ago

Yep that error is because the package is old and has no namespace. Since Laravel uses namespaces everywhere (apart from helper files), it allows composer to pick up on these and load them in.

There is a laravel package which is just a clone of the one you're trying to use, with an addition. It has namespaces and a service provider.

You can find it here: https://github.com/sonnenglas/amazon-mws-laravel

This one will work for you, just follow the documentation on the github page.

Jaytee left a reply on Instantiating A Class (from A Laravel Package) Inside Of A Controller • 1 week ago

Laravel doesn't assume that it's looking for a controller. It's just looking for a class (the one you have specified).

Instantiating AmazonOrderList should work as you'd expect. Now the package is old, so it's probably failing because it doesn't have a namespace.

What you'll need to do is use include or require at the top of your file and then give the full path to the file.

Alternatively, find an updated package that makes use of namespacing and autoloading.

Jaytee left a reply on Can't Validate Mp3 File When Upload File In Laravel • 1 week ago

Try:

'something' => 'mimes:mp3'

10th October, 2017

Jaytee left a reply on How Can I Solve This Error: Class 'App\Http\Controllers\Auth\Role' Not Found • 1 week ago

You haven't imported the role class correctly. If you haven't changed the directory structure, then it should be one of these:

use App\Role;
use App\Models\Role;

9th October, 2017

Jaytee left a reply on Mysterious String Phenomena • 1 week ago

Your original problem was with this line here: <a href="{{ route('/chickens/{variety}{name}/create', ['variety' => $chicken->variety, 'name' => $chicken->name]) }}">create</a>.

When you use the route() method, you give it a name instead of the URL. You were passing the whole route AND the wildcards which is a no no and a recipe for disaster (which happened).

When you use the as key on the route or when you chain on ->name('some.name'); is when a route becomes a named route.

So for example, to use the route() method:

Route::get('/', '[email protected]')->name('home');
Route::get('/', ['uses' => '[email protected]', 'as' => 'home']); 

// both of them are the same
// Then i'd do something like

<a href="{{ route('home') }}">a link</a>

// if i need to pass one parameter, i would pass it as the second argument
<a href="{{ route('home', $user->username) }}">a link</a>

// if i need to pass more than one parameter, i would pass an array as the second argument

<a href="{{ route('home', [$user->username]) }}">a link</a>

Jaytee left a reply on Homestead - Cannot See Database Tables • 1 week ago

Remember that when using something like Sequel pro and Homestead, you need to use the Homestead IP. 192.168.10.10 and then the credentials which is usually homestead and secret

Jaytee left a reply on Mysterious String Phenomena • 1 week ago

Yeah something is going wrong somewhere.

Can you show me the controller and view please.

Also, if you can show me where you're passing the parameters for the URL (e.g: a form or button).

Alternatively, what you could do is just have a generic /chickens/create route and have a couple of select boxes which a user selects for the variety and name.

Jaytee left a reply on Blade Templating Issue... • 1 week ago

I've noticed in your navbar section, you're using @section(). If you're trying to insert data here, it should be @yield().

Then in the pages where you extend the template, you can use @section.

P.S: You don't need to have the / on html tags that do not have a closing tag. i.e: <meta />, you can just do <meta>.

P.S.S: I also hope you have <!DOCTYPE html>, <html>, <head>, and <body> tags

8th October, 2017

Jaytee left a reply on <style> In View • 1 week ago

@jlrdw I think it's like discord dude, you do three backticks and then the name of the language


test

Jaytee left a reply on Couple Vagrant Questions • 1 week ago

Yep you can, just change it in your homestead.yaml file.

7th October, 2017

Jaytee left a reply on Namespace Declaration Statement Has To Be The Very First Statement • 1 week ago

In settings, change this value and try ANSI:

"default_encoding": "UTF-8",

If that fails, revert back. UTF-8 is my default and I use sublime. P.S: if the namespace declaration error is just happening in the one class, try deleting it and create it again.

Jaytee left a reply on Couple Vagrant Questions • 1 week ago

Jeff doesn't use homestead anymore, he uses Valet (for mac).

Homestead will install all of that stuff for you. But you need to ssh into the vm and then do things like running composer.

Just follow the homestead installation guide, and you'll be on your way. If you need to install / upgrade something, you ssh into the VM first and then do what you need to do.

Jaytee left a reply on Namespace Declaration Statement Has To Be The Very First Statement • 1 week ago

What text editor are you using? Saw some people say change the encoding type from UTF-8 to ANSI

Jaytee left a reply on Disable Eager Load • 1 week ago

It's a great API. If you can guess what you're looking for, you're probably right.

And if you're not sure, you can search the API docs here: https://laravel.com/api/master/

Jaytee left a reply on TypeError: Too Few Arguments In Function • 1 week ago

The show method is for showing one user. IF you want to show multiple, use an index method.

Your show method is only querying one user, so why are you looping over it? Again, thats a job for the index method.

Jaytee left a reply on Disable Eager Load • 1 week ago

Bar::with('reports')->without(['reports.invoice', 'reports.act']);

But remember, the point of setting the with property is so that they are always eager loaded. If in a lot of situations you don't want them loaded, just don't set the with property.

Jaytee left a reply on Why Do I Always Get A 404 In My Test? • 1 week ago

According to the docs, routes go in the boot method, not the register method. If that still doesn't work, use this from the docs in the boot method.

Put them into a routes file and then use $this->loadRoutesFrom(__DIR__ . '/routes.php');

Jaytee left a reply on Trouble Accessing An Array • 1 week ago

Not sure why you need the index, but that's PHP for you lol.

If you don't like that approach, just turn it into a collection.

$visits = collect($visits->getPageUrls(['period' => 'week', 'expanded' => '1', 'segment' => 'pageUrl%3D%5Ehttp%253A%252F%252Ftesting.dev%252Fblog%252F']););

Jaytee left a reply on DRY Related • 1 week ago

You're best to use middleware. That way, you can either put it on the constructor or on the routes itself.

Middleware is the intended use for this, trying something new is great and all, but in situations like this, it isn't necessary.

Jaytee left a reply on Pass Variable From Request Into Config::set • 1 week ago

Don't use quotes for the variable here, otherwise it's always going to search for the string literal $iid

if (!Storage::disk('doc')->exists('$iid'))

6th October, 2017

Jaytee left a reply on Migration Quick Question • 1 week ago

Name the migration something else.

As a convention, when creating tables:

php artisan make:migration create_{table}_table

And when adding to an already existing table:

php artisan make:migration add_{field}_to_{table}_table // or something else that describes what you are doing, for example:

php artisan make:migration update_{table}_table

If you're doing this in development, you might aswell just drop all tables and change it within the main migration file, since usually you use dummy data in development.

IF in production, it's important to create a new migration to modify an already existing table, otherwise you will lose real data.

5th October, 2017

Jaytee left a reply on Preventing Two Users To Update A Model At The Same Time • 1 week ago

Couple ways you could do it

  1. Like the way you've done it.
  2. Add a locked field that expires after X minutes
  3. Use Javascript (and optionally use websockets) when a user clicks on it, it locks it using an AJAX request. If you use websocket, you can display a live message instantly to say "so and so has already accessed this ticket".

Jaytee left a reply on Route Group Name In Laravel 5.5 • 1 week ago

There's nothing wrong with grouping routes under a name, the docs will have it like the user above has posted.

I personally, don't use groups with/without names anymore, only because of two reasons:

  1. My routes file doesn't look as aesthetic (personal thing, don't ask lol)
  2. Explicitly defining routes seems to read better for me.

Jaytee left a reply on Why Does Laravel Use Snake Case For Helper Functions? • 1 week ago

  • i don't know about you but:

arrayAdd looks like shit lol

Jaytee left a reply on PHP Array Output • 2 weeks ago

In the future, make sure your question is understandable.

Fortunately, I was able to know what you need. You want the results to be the values and not the keys/indexes.

You need to use array_values

without array_values

array:2 [
  0 => array:5 [
    0 => "a"
    1 => "b"
    2 => "c"
    3 => "d"
    4 => "e"
  ]
  1 => array:5 [
    0 => 1
    1 => 2
    2 => 3
    3 => 4
    4 => 5
  ]
]

** with array_values **

array_values($arr);
[
     [
       "a",
       "b",
       "c",
       "d",
       "e",
     ],
     [
       1,
       2,
       3,
       4,
       5,
     ],
]

4th October, 2017

Jaytee left a reply on When To Use Html\message.blade.php And When Markdown\message.blade.php / MailMessage Methods • 2 weeks ago

You use it whenever you want. Some people like using Markdown and some people like to use HTML.

Markdown is used for things that don't need to be complex, mainly like a regular email.

HTML is for all those who go crazy with designs.

Again, the choice is yours.

Jaytee left a reply on Users Password Is Not Matching In Production • 2 weeks ago

You can either just copy the method into the trait and override it like the user above said,

OR; Since you're only ever gonna be setting a password twice in your system, just remove the mutator and hash the password when creating the user, rather than letting a mutator handle it.

Jaytee left a reply on Small View Problem With Laravel 5.5 • 2 weeks ago

The folder structure is well thought as it is.

I'll give you an example on the three you pointed out models, views & controllers.

Controllers live in the HTTP directory as they deal with requests and responses which are http. It makes sense to have them in there, with other http files such as middleware and responses.

Models yeah, by default they are in the app directory. They're fine there, but if you do start to have a lot of models, a lot of people do move them to a models directory.

Views aren't part of the application code, hence why they're in a resources folder. They're just responsible for displaying data, hence why you'll also see scripts and styles in the resources folder.

Like said above, you can change all of this, but it's not recommended.

Jaytee left a reply on MethodNotAllowedHttpException No Message [on 5.5] • 2 weeks ago

No that shouldn't affect it, and it shouldn't be 5.5 affecting it either. 5.5 is a fairly seamless update.

Can I have a look at your routes? P.S: try deleting vendor folder and installing again.

And if you have the routes cached , delete the route cache or re-cache routes php artisan route:cache

Jaytee left a reply on MethodNotAllowedHttpException No Message [on 5.5] • 2 weeks ago

I don't think im thinking lol.

You got any routes overriding it, such as a wildcard to user/{user} or something.

I don't think a parameter is required for a delete request, all tho i could be wrong.

You could try adding a parameter and passing something through Route::delete('user/{somethinghere}/delete', 'SomeController');

Jaytee left a reply on What Is Standard Method Name For Data Persistant? • 2 weeks ago

index => retrieve all items
create => show the form for creating a new item
store => store the new item
show => show one item
edit => show the form for editing a new item
update => update an item
destroy => delete an item

In some cases, you'll use all of these, in others you won't. But they are the naming conventions.

Jaytee left a reply on MethodNotAllowedHttpException No Message [on 5.5] • 2 weeks ago

That's because you're trying to return hi.

DELETE and POST requests (and others) are used to update/insert/delete something, not retrieve something and show it. That's a GET request.

So instead of returning hi, do something like a redirect instead.

Jaytee left a reply on MethodNotAllowedHttpException No Message [on 5.5] • 2 weeks ago

When performing a delete request, you need to kind of "tricking" it so that laravel understands that its a delete request and not a POST or GET request.

First of all:

Change your route from Route::post() to Route::delete()

Secondly, in your form, add a new field:

<input type="hidden" name="_method" value="DELETE">
<!-- Or use the helper function to do it for you -->
{{ method_field('DELETE') }}

3rd October, 2017

Jaytee left a reply on How Can I Select A Model To Use Based On A Variable? • 2 weeks ago

Can you try re-word it again? I'm running on over 24 hours of no sleep so lacking concentration lol.

P.S: You gonna be extending the MacroRegion class since its abstract?

Jaytee left a reply on I Cannot Solve This Error Code (Function Must Be A String) • 2 weeks ago

@devlanga Yep the correct answer should be marked.

In the meantime tho, the correct answer is from @shakti . The request is an object so calling it as if you're calling a function, won't work.

Instead you access the properties. $request->someProperty

2nd October, 2017

Jaytee left a reply on How Can I Get The Build In Error Message When Using Form-request? • 2 weeks ago

There's been a couple of issues with Validation (not like this issue) since earlier versions of 5.5.

Update to the latest 5.5 version and re-install the vendor folder, see if that fixes it.

Jaytee left a reply on How Can I Get The Build In Error Message When Using Form-request? • 2 weeks ago

Yeah I can't seem to replicate this issue. I checked the MessageBag when validation fails and couldn't find anything other than the messages ("This field is required etc).

Its worth a shot at doing a few of these, sometimes things do glitch out.

  • Try delete the request and create a new one
  • run composer dump-autoload
  • reinstall vendor folder

Jaytee left a reply on Im Getting 404 When Tring To Do A POST Request With GuzzleHttp • 2 weeks ago

Make sure your APP_URL is correct. If you're using something like Homestead or Valet, then yeah its not gonna work since they use custom URLs like myapp.dev

As for receiving input from the request, just do $request->nameOfWhateverYouWant

Jaytee left a reply on How Can I Get The Build In Error Message When Using Form-request? • 2 weeks ago

Whilst this isn't relating to the problem, in your authorize method, you can just return true since the constructor on the controller is requiring all methods to have an authenticated user.

Also, for the try catch blocks, there likely isn't a need for that. Just do your logic and be done. The method won't be called if validation fails, and if eloquent fails to insert data, i believe it will error you by default anyway.

Now to the problem, check that you haven't deleted the lang files in resources folder. More specifically, the validation.php file.

Jaytee left a reply on Validating Unique On An Update Request • 2 weeks ago

No worries. Hey, even better,

Instead of type hinting the Request in your methods, you can omit that and just use the global request helper too.

request()->validate();

request()->username // etc

Jaytee left a reply on Validating Unique On An Update Request • 2 weeks ago

What you can do is something like this:

use Illuminate\Validation\Rule;

$request->validate([
    'team_tag' => [
        Rule::unique('team_tag')->ignore($team->team_id, 'team_id'),
    ]
]);

Jaytee left a reply on PhpStorm • 2 weeks ago

@NadeemAkhter The student version is free; You just need a student email and you get it free for 1 year.

Jaytee left a reply on PhpStorm • 2 weeks ago

Nope!

If you're a student, you can get it for free, otherwise, buy it.

Jaytee left a reply on Scheduling Queued Jobs • 2 weeks ago

Use everyMinute() for testing purposes. This command is ran as soon as you run the scheduler (in development mode).

Otherwise, all other commands in development mode will run on their exact time.

1st October, 2017

Jaytee left a reply on Package Registration In Package • 2 weeks ago

Hmm, is there where you're trying to pull in the Javascript package? In that case, yeah it probably won't work.

Laravel is the one that auto-registers the providers/facades, a package wont.

When you require your package into a laravel app, i should auto register, if it doesnt, then you can add the ServiceProvider to the config.

Other than that, just pull in the actual classes for the package instead.

Jaytee left a reply on Package Registration In Package • 2 weeks ago

Run php artisan package:discover and see if it shows up in the terminal. Test if it works.

Otherwise, occasionally i've noticed providers/aliases aren't discovered. I just manually add them to config/app, no big deal.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.