Cronix

Experience

197,700

229 Best Reply Awards

  • Member Since 4 Years Ago
  • 507 Lessons Completed
  • 2 Favorites

17th February, 2018

Cronix left a reply on Error While Trying To Pass AJAX Data To Laravel Method • 1 day ago

You are sending the data in a post request, but using get when retrieving the values like $request->get('admin'); Try just $request->admin, etc.

16th February, 2018

Cronix left a reply on Page Expired Error While AJAX Login Laravel+VueJS • 1 day ago

Is the token actually being sent with your request?

Try setting your csrf token on the axios object (like you are with X-Requested-With) instead of Vue.http.headers.common.

Cronix left a reply on Guzzlehttp Causing Problem In Installing Laravel Installer. • 1 day ago

Thanks for posting the solution. I see nothing but problems on the forum with people using the installer (it's almost always an outdated installer version). Just use composer to install laravel and this is never an issue.

Cronix left a reply on Checkboxes And Model Updating Revisited For Laravel 5.5 And Above • 1 day ago

$request->has() returns a boolean, so ?? false seems kind of redundant there.

Cronix left a reply on Increase Font-size In Discussions • 1 day ago

Even the font size in the reply box is larger than the of the text on the screen. It is a little small, but I just increase the font (zoom) in my browser with cmd+

Cronix left a reply on Get Subject Name From Parent Query For Use In Subquery. • 1 day ago

Look at "bindings" here: https://laravel.com/docs/5.6/database#running-queries

use placeholders and bindings for the user supplied variables.

15th February, 2018

Cronix left a reply on Update App Timezone And All Timestamps In DB • 3 days ago

First, backup your database.

You will have to write a query for each table and each time related field in each table (like TIME if you use it, not just datetime fields). The query would be something like

UPDATE `tableName` SET `dateTimeColumn` = DATE_ADD(`dateTimeColumn`, INTERVAL 2 HOUR)

That would add 2 hours to each entry in the dateTimeColumn field in the tableName table. "2 HOUR" would be the offset between the old timezone and the one you are changing it to. If it's a negative number, you can use "INTERVAL -2 HOUR". You'd need one for each date/time related field.

Personally I think I'd create a migration that did all of that since it's something that you'd only run once. The migration would just have a series of DB statements for the updates and not using Schema.

14th February, 2018

Cronix left a reply on Get One Data From Each Duplicate Data Row • 3 days ago

If you have all of the month values in an array, you can just run array_unique() on it and not worry about grouping.

$months = [5, 5, 2, 2, 1, 4];
dump(array_unique($months)); // 5, 2, 1, 4

// sort them
dump(sort(array_unique($months))); // 1, 2, 4, 5

Cronix left a reply on Case Sensitivity Difference (in Directory Names) Between Local (mac) And Production (ubuntu) Environments? • 3 days ago

Yes, this is a common issue, but one that's easily avoided by using the same OS in dev that you are in production, which is why I develop on VM's. You're lucky it was just that one command. Usually it's controllers and other things as well.

Cronix left a reply on Delete Confirmation In Modal • 3 days ago

I can't troubleshoot it like you can sitting with it right there. I do similar all the time so I know the theory works. You'll just have to massage it a bit!

Cronix left a reply on Bar ("/") After Routes Getting Errors • 3 days ago

By default laravel removes trailing slashes in urls in public/.htaccess. Not sure if you're using apache or not but thought I'd mention it.

method not allowed simple means you are hitting a route with a method other than what the route allows. Like sending a get request to a post route or similar.

Cronix left a reply on Undefined Variable: Data In View. • 3 days ago

try running artisan view:clear to clean out the cached view files.

Cronix left a reply on Caching An Item For Current Request. Not Using Session • 3 days ago

the config is just a big array under the hood with all config settings from all config files, so you can put anything in there that you normally could put in an array, which is just about anything.

Cronix left a reply on Delete Confirmation In Modal • 3 days ago

Why not put your form action in the actual view that contains the <form>? That view is parsed by php whereas javascript files are not (unless you set it up in your server settings). Then you'd just append the id to it dynamically.

<form action="{{ route('comments.destroy') }}" method="post">
let commentId = $(e.relatedTarget).data('comment_id');
// append the commentId to current form url
let action = $("#delForm").attr('action') + '/' + commentId;
// set the new url in the form
$("#delForm").attr('action', action);

Cronix left a reply on Is There Any Homestead Up To Date Documetation? • 4 days ago

No, 7.1.2 is newest. Check the releases: https://github.com/laravel/homestead/releases

Cronix left a reply on Delete Confirmation In Modal • 4 days ago

Which version of bootstrap are you using?

Cronix left a reply on How .version() Really Works In Laravel Mix ? • 4 days ago

This has always been a trick. I've been using it for at least 10 years except we just used the datetime stamp of the files themselves as the query string, so if a file was altered it would change the last modified timestamp of the file on the filesystem and put it in the querystring forcing the browser to load our newest changed files. The browser looks at the whole string and not just the filename. If the string is different it will force the browser to load it fresh. Our files would look like file.js?v=20190214081002 for a file saved at 2019-02-14 08:10:02

Jeffrey was running into problems with the hashes in the filenames themselves. At one point, Mix quit deleting old ones and only generating the new ones when compiling. This left hundreds/thousands of versions of the same file (each with its own hash) which were then clogging up git. This was especially bad when using npm run watch as you could end up with 20 versions of the same file while just working on it a few minutes. This was a more elegant solution since only the query portion changes, which means Mix didn't have to delete old files any longer. It just overwrites the existing.

Cronix left a reply on RSA Encryption • 4 days ago

all I did was go to packagist and type "encryption" and it was one of the top packages. There are others that are highly rated. I didn't look at them all since that one had RSA in the description.

https://packagist.org/?q=encryption&p=0

13th February, 2018

Cronix left a reply on Email From • 4 days ago

Basically the ISP that is receiving the email checks to see if the FROM matches the domain it received if from. If not...spam. You'll also want to set up SPF and DKIM in your DNS.

Cronix left a reply on Multiple Eloquent Relations In View • 4 days ago

code blocks...

1) 3 backticks on it's own line
2) your code after that
3) a new line with 3 closing backticks.

Cronix left a reply on Undefined Variable: Data In View. • 4 days ago

Do you actually get the error when you go to yoursite.com/AdminView?

Cronix left a reply on Simple HTML Problem • 4 days ago

Laravel also has a helper for that kind of thing. https://laravel.com/docs/5.5/helpers#method-str-limit

Cronix left a reply on Keep Checked Box From One Page To Another With Laravel Pagination • 5 days ago

Put them in session?

12th February, 2018

Cronix left a reply on Empty Square Brackets After Every Log:: Line On Upgrade To 5.5 - Can They Be Removed? • 5 days ago

Just an example, I log queries sometimes doing something like:

$dbLog->info($query->sql, ['Bindings' => $query->bindings, 'Time' => $query->time]);

So it will show the raw query, like Select * from users where username = ? and in the array portion it will show the bindings [ex Bill] and how long it took the query to execute. I guess you're doing kind of the same thing except using 3 separate log calls to show query, another for bindings and another for time. Since they're all related, I like to have them in the same line but separated.

if you did something like

$dbLog->info('A Payment was made!', ['Payment' => $payment, 'User' => $user]);

You could dump the payment object, as well as the user object that the payment was made for. If $payment and $user are objects, it will just run the toArray() on them.

Hope you get the idea and how useful it can be.

Cronix left a reply on Empty Square Brackets After Every Log:: Line On Upgrade To 5.5 - Can They Be Removed? • 5 days ago

You can log arrays as extra parameters beyond the basic text message. It's just showing that you didn't enter anything, so they are empty arrays. I've never really considered it an issue to see whether it can be prevented. A lot of times I do dump the $user or other objects there or something, so I'm actually using them sometimes, and it's helpful to see the data (or lack thereof) which is useful to further troubleshoot.

11th February, 2018

Cronix left a reply on Laravel Insert Data Twice When Timeout Occurs (bug Possibility) • 6 days ago

What is "timing out" exactly? Your session, or php itself? You can increase either or both.

Cronix left a reply on Passing Data To View Vs Fetching With Ajax • 6 days ago

You can also use a combination. For 300 items, I'd be using pagination. Page 1 would just load the view with data for page 1. Subsequent pages would use ajax and load data for those pages and update the dom.

Cronix left a reply on Contact Us Form (sending Email) Laravel 5 • 6 days ago

damn, just saw the date on these posts. Not sure why it showed up as a recent post...

Cronix left a reply on Contact Us Form (sending Email) Laravel 5 • 6 days ago

Sounds like DNS isn't working on your server, so it can't resolve 'smtp.gmail.com' to an ip address. If you go to the CLI and enter 'ping smtp.gmail.com' does it resolve to an ip address or receive errors?

~ ᐅ ping smtp.gmail.com
PING gmail-smtp-msa.l.google.com (74.125.28.109): 56 data bytes
64 bytes from 74.125.28.109: icmp_seq=0 ttl=45 time=22.585 ms
64 bytes from 74.125.28.109: icmp_seq=1 ttl=45 time=21.073 ms
64 bytes from 74.125.28.109: icmp_seq=2 ttl=45 time=26.836 ms

Cronix left a reply on Outputing Data From Database From TinyMCE • 6 days ago

{!! $var !!} is basically just running it through html_entity_decode(), which converts the entities back to html (opposite of what htmlspecialchars() does, which is encode the entities)

http://php.net/manual/en/function.html-entity-decode.php

The only way you're going to be able to output actual html is to convert the entities back to their original characters using {!! $var !!} or html_entity_decode(). These days I just use markdown and don't save any user generated html in the database.

10th February, 2018

Cronix left a reply on Import Lodash Breaking Vue Section In Laravel Spark • 1 week ago

That was clear. You said you got that to work using underscore, so I was wondering why you need lodash unless there is more.

Cronix left a reply on Import Lodash Breaking Vue Section In Laravel Spark • 1 week ago

What do you need from lodash that underscore doesn't do?

8th February, 2018

Cronix left a reply on Video Formating And Watermark • 1 week ago

FFMPEG is pretty much the standard for video manipulation. It's not php (it's a cli tool), but can be used via php using exec(). There are plenty of tutorials on FFMPEG around the net.

https://www.ffmpeg.org/documentation.html

Cronix left a reply on Don't Show Results From Soft Deleted Relation Model • 1 week ago

In the "Querying relationship existence" section here in the main relationships docs: https://laravel.com/docs/5.5/eloquent-relationships#querying-relations

7th February, 2018

Cronix left a reply on Missing Laravel Installer Option • 1 week ago

Personally I think the installers are dumb anyway. It's just as easy to create a project with just composer on the CLI, just like the dumb installer, and you never run into this.

Cronix left a reply on How To Do A Custom Validation Rule Like Require_if? • 1 week ago

@sndytj Should probably review the available rules. I'm sure there are others you aren't aware of that will come in handy: https://laravel.com/docs/5.6/validation#available-validation-rules

Cronix left a reply on Multiple Web Servers And Dedicated DB Server • 1 week ago

Does it matter if it's installed? It's not like it's going to consume resources if it's not being used. You can also stop the nginx service in your deploy script or a "recipe" if you want, or even uninstall nginx.

Cronix left a reply on Javascript Or Any Other Way To Increase A Value In A Database Table? • 1 week ago

Yes, ajax would be best for that, and quickest.

Cronix left a reply on Table Column Mismatch In Laravel Eloquent • 1 week ago

You'd override them in your applicant_skill() relationship. See the docs where it shows you for each type of relationship (hasOne, hasMany, etc): https://laravel.com/docs/5.5/eloquent-relationships

Cronix left a reply on Cannot Add New Column Enum Type • 1 week ago

I would also avoid enums unless you know for an absolute fact the options will never change. Google "enum evil" for a ton of reasons why.

Here are some: http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/

6th February, 2018

Cronix left a reply on Browser Doesn't Load New Page When Redirected • 1 week ago

Show some relevant code. Is this a redirect within laravel, or a javascript redirect?

Cronix left a reply on Specifying Columns For Eager-loaded Relationships • 1 week ago

When specifying columns for selects in relationships, you have to manually enter the id and foreign_id(s) for each relationship. You're overriding the default behavior, so you need to specify in order for the relationships to work, like @edoc mentioned.

Cronix left a reply on Laracasts Facebook No More? • 1 week ago

@gator I think he means the facebook icon/link at the very bottom of the pages of this site.

Cronix left a reply on Update Two Records With Two Input Data • 1 week ago

Well, you grab a single product here:

$productProductOptions = ProductProductOption::where('product_id', $product->id)->get();

And then update the product_option_id field on it twice in the loop. So yes, only the last thing updated will be stored since it overwrites the first thing.

5th February, 2018

Cronix left a reply on I Can't Access My Site, Only Home Route! • 1 week ago

is mod_rewrite installed on that server?

3rd February, 2018

Cronix left a reply on Start A Laravel Dusk Test From Inside A Laravel Form • 2 weeks ago

Ok, but did you try entering the full path to artisan?

Cronix left a reply on Start A Laravel Dusk Test From Inside A Laravel Form • 2 weeks ago

You might have to give it the full path to artisan

Cronix left a reply on Class Name Class? • 2 weeks ago

I'd call it "Course". Using "Class" will come back to bite you and might as well avoid that from the get-go so you don't have to refactor it all later.

Edit Your Profile
Update

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