Cronix

Experience

148,820

159 Best Reply Awards

  • Member Since 3 Years Ago
  • 490 Lessons Completed
  • 2 Favorites

23rd September, 2017

Cronix left a reply on Remove Index.php From URL • 11 hours ago

Are you sure your APP_URL doesn't have index.php in it? Does your app still work if you manually type a url without index.php in it?

Cronix left a reply on Eloquent Casting Int As String • 11 hours ago

I think it's PDO doing this and not necessarily Laravel. There are PDO options you could put in your database connection array that will tell PDO to not convert ints to strings. It could also have something to do with the PDO driver you're using.

https://stackoverflow.com/questions/1197005/how-to-get-numeric-types-from-mysql-using-pdo

22nd September, 2017

Cronix left a reply on What Is The Right Way To Check If A Migration Already Ran At Runtime? • 1 day ago

You could always check if the migration is listed in the migrations table in the db.

$hasRun = DB::table('migrations')->where('migration', '2017_09_17_230130_create_assets_table')->exists();

Yes you can group the migrations into different folders, but I don't think it's implemented very well, as then you have to specify the folder name when running artisan migrate by specifying the artisan migrate --path=/path/to/migration, as well as when you want to rollback. You can't just run artisan migrate and have it auto-discover your folders. You can check artisan help migrate and artisan help migrate:rollback for the various options available.

Cronix left a reply on Using Route::get() After Route::resource() • 1 day ago

He means that if you have a Route::resource(), and then you make additional routes for that controller, those additional routes need to go before the Route::resource() route.

https://laravel.com/docs/5.5/controllers#restful-supplementing-resource-controllers

Cronix left a reply on Laracasts User Profile URL Structure (/@Username) • 1 day ago

Give the route a name and use the route('name') in your links.

Route::get('/@{username}', '[email protected]')->name('username');
<a href="{{ route('username', ['username' => 'bob']) }}">@Bob's Profile</a>

https://laravel.com/docs/5.5/routing#named-routes

Cronix left a reply on Eloquent Casts Array Returns Null Instead Of Empty Array • 1 day ago

Create a trait with the accessor and use it in those models.

21st September, 2017

Cronix left a reply on Upgrade Php From 7.0.5 To Latest Stable Version 7.0.23 • 2 days ago

php -v from the cli will return what version of php-cli you are running (not necessarily the same version as what your webserver is running - they are different).

put phpinfo(); in a php file and visit the url for that file in a browser (or at the top of /public/index.php)

Cronix left a reply on Lavavel Get Posts Of Last Month. • 2 days ago

You can also use latest() instead of orderBy('created_at', 'DESC'). They're identical sql-wise.

19th September, 2017

Cronix left a reply on Dynamic Developers • 4 days ago

Good deal. Please mark the post as solved to make it easier for others to find the solution if they come across this.

Cronix left a reply on Dynamic Developers • 4 days ago

I believe you'd do that in the SparkServiceProvider. Not sure if it should go in the booted() or register() method. Just make a db call to get the list and populate it as you showed.

16th September, 2017

Cronix left a reply on Will I Notice A Performance Improvement Manually Writing Query For Large Inserts? • 1 week ago

I don't think it will matter much. 11 million inserts will take longer than 60 seconds no matter what you use. I just disable the time limit before doing that much. set_time_limit(0);

It will also go a bit faster, and consume a lot less resources (memory) if you disable query logging.

DB::disableQueryLog();

15th September, 2017

Cronix left a reply on Is There A Way To Get A List Of The Migrated Classes After Migrations Takes Place? • 1 week ago

AFAIK, there are no events associated with migrations.

Cronix left a reply on Nginx | Can Only Access Some Routes But Not All • 1 week ago

If you have extra methods in a resource controller beyond the default ones (index/create/store/show/edit/update/destroy), those routes need to go above the resource route.

https://laravel.com/docs/5.5/controllers#resource-controllers

If you need to add additional routes to a resource controller beyond the default set of resource routes, you should define those routes before your call to Route::resource; otherwise, the routes defined by the resource method may unintentionally take precedence over your supplemental routes:

Cronix left a reply on Solution For Connecting To A Remote Database • 1 week ago

Basically you'd create a generic 2nd connection in your database config, and then change the config parameters to what you want (dynamically) at runtime.

https://laracasts.com/discuss/channels/laravel/dynamic-database-connection

14th September, 2017

Cronix left a reply on After Upgrade To Laravel 5.5 (from Laravel 5.4) NewPivot Is Broken • 1 week ago

Really don't know, but can you check if it's an array and if not do a ->toArray() on it since it's an eloquent model?

Cronix left a reply on Laravel Collective Select Option Issue • 1 week ago

Are you sure you're actually executing the query EnsinoPesquisa\FilterCourse::whereFiltercourseCategoryId(1)->pluck('name', 'id')?

Shouldn't there be a ->get() before you ->pluck()?

Cronix left a reply on How To Speed Up Laravel? • 1 week ago

There are also many factors affecting load time that have nothing to do with Laravel.

How many images you're loading, their size, are they compressed, are they the correct size for the device consuming them (not loading huge images and then using scaling using height/width to make them smaller)?

Are you using http cache headers so that assets aren't continuously being redownloaded?

Are your assets (css/js) compressed with gzip?

Are you using HTTP/2?

Are you using CDN's to deliver your assets (images/js/css/etc)?

13th September, 2017

Cronix left a reply on Laravel Keep Eating Memory With Every Request • 1 week ago

I just have it before running a ton of queries, like when I'm pulling in data from apis and storing it in a huge loop.

Cronix left a reply on Laravel Keep Eating Memory With Every Request • 1 week ago

Laravel keeps all of the queries that have been ran in memory for debugging. I run some processes that run for hours inserting tens of thousands of records in the db. Each loop takes more memory until it crashes... until.. I discovered how to turn that off.

DB::disableQueryLog();
// run lots of queries

After doing that, laravel consumed no more than 5M memory for the entire thing.

Cronix left a reply on Purpose Of Homestead/Laravel Rsa Keys • 1 week ago

did you reprovision the server after doing that?

Cronix left a reply on Purpose Of Homestead/Laravel Rsa Keys • 1 week ago

so you can use homestead ssh or vagrant ssh commands to ssh into homestead. If you're using putty, just ignore it.

Cronix left a reply on Helper Doesn't Work With Controllers • 1 week ago

Just add the directory to your composer.json file for PS4 autoloading. Not sure why you're doing this in code.

Cronix left a reply on Foreach Target First • 1 week ago

Yes, as @sutherland mentioned, just use the built-in $loop variable. There are more options available than stated, as well.

https://laravel.com/docs/5.5/blade#the-loop-variable

Cronix left a reply on Stripe - How To Protect Amount Variable While POSTing To Server Side • 1 week ago

You don't need a hidden field. Just give each button a value.

<button name="submit" type="submit" value="option1">$5</button>
<button name="submit" type="submit" value="option2">$10</button>
$button = $request->submit;

if ($button === 'option1') {
  // $5
} else if ($button === 'option2') {
  // $10
} else {
  // unknown value sent
}

12th September, 2017

Cronix left a reply on What's Wrong Here? • 1 week ago

I'd opt for switch anyway, as it's a lot more legible than stacking ternaries. You can quickly tell what's going on without having to sit there and think about it.

Cronix left a reply on Generate Dummy Data With Faker While Still Maintaining Consistent Data And Relationships • 1 week ago

Do you have a factory for organization and purchase? Just use those within your Assessment factory so that it will create those models as well.

Something like: https://laracasts.com/discuss/channels/eloquent/model-factories-relations?page=1

Cronix left a reply on Task Scheduling Runs Every Minute Instead Of The Time That I Set • 1 week ago

You could also check the current date/time to see if it matches your $time in your loop, and execute the scheduled command if it is. That would allow you to keep everything in code still and do what you are wanting.

Cronix left a reply on Task Scheduling Runs Every Minute Instead Of The Time That I Set • 1 week ago

I guess remove the default cron job that's running every minute. But then you'd lose the whole purpose of having cron jobs in code as opposed to crontab and would have to create and maintain each cronjob on each server manually. It's much better to have it in code so it's a part of your repo, and you only ever need one actual cron job to execute all jobs no matter when they were.

Cronix left a reply on Task Scheduling Runs Every Minute Instead Of The Time That I Set • 1 week ago

homestead already has a cron job running every minute, which executes schedule:run (which is how it is supposed to be). You shouldn't have to enter anything in cron.

You just need to schedule a job through the scheduler using ->dailyAt('00:05'); if you want it to run at 5 after midnight.

https://laravel.com/docs/5.5/scheduling

Cronix left a reply on How To Append An Image Using Jquery To Div Element Through Ajax • 1 week ago

I think it's because you have the response.unit_plan_images.UnitImage within the quotes of the img src, so it thinks that's literally the url of the image. Break out of the quote and concatenate.

'<img (src)="'+response.unit_plan_images.UnitImage+'" height="64px" width="64px">'

11th September, 2017

Cronix left a reply on Webpack Watch-poll Crashing The Homestead • 1 week ago

It won't mess your host with build stuff. Everything is still done in the laravel directory, which is also the homestead directory...

Cronix left a reply on Webpack Watch-poll Crashing The Homestead • 1 week ago

when I run with watch on homestead (ssh/cli), it pegs my host (mac) cpu at 100+%. So, I run in on the host instead of from within the vm. It drops cpu usage down to ~8%. I'm not sure why it does that, but it was turning my macbook into a lap warmer before changing it and only running via host.

8th September, 2017

Cronix left a reply on Testing And Apostrophe Characters In Fields • 2 weeks ago

It's because blade runs variables through html entities, so apostrophes get converted to their html entity '.

In your tests, you just need to run your variables through the e() function, which is what blade is doing.

->assertSee(e($model->name))

Cronix left a reply on How To Display Charts Properly? • 2 weeks ago

Yeah, sorry, I'm not sure on that. I haven't used that package. I just noticed the loop where you're overwriting the variable on each iteration.

Cronix left a reply on How To Display Charts Properly? • 2 weeks ago

Looks like you need to create an array of charts.

foreach ($survey->questions as $key=>$question){
          $chart = Charts::database($answer->where('question_id', '=', $survey->questions->pluck('id'))->get(), 'bar', 'material')
...

You're overwriting $chart on each loop, so $chart will only be whatever the last loop was

Cronix left a reply on Laravel 5.5 So Slow. Using Windows 7 And Xampp. Why? How To Make This Right? • 2 weeks ago

Also, are you using debugbar? That will add quite a bit of time (1-2 seconds for me on complex pages)

Cronix left a reply on Getting Nested Relation? • 2 weeks ago

I'm assuming your 'videos' relationship is defined in your Follow class...

$user->load('following.videos');

7th September, 2017

Cronix left a reply on Table Cell On Chrome • 2 weeks ago

If you are using <th> tags in your thead, you can just apply the style to those, and then all of the <td> in the will use the same. So you don't have to apply them to the td's in your loop, which will make for a smaller payload to the browser.

Cronix left a reply on Table Cell On Chrome • 2 weeks ago

Are you actually specifying the td widths, or at least the th widths which all of the respective td's would follow?

6th September, 2017

Cronix left a reply on SQLSTATE[HY000]: General Error: 1215 Cannot Add Foreign Key Constraint • 2 weeks ago

The FK field needs to match the field in the other table exactly. In one, you create sr with an unsigned int, in the other sr_id it's a regular (signed) int. They both need to be signed, or unsigned.

You also should be creating indexes on anything that is an id, or a fk.

There is no need to create a separate schema() entry to create the fk within the same migration. Just do it in the regular definition.

Cronix left a reply on Latest Macbook Pro For Dev • 2 weeks ago

That problem really comes down to the plugins you are using and what they are doing and on how much code they are doing it. All a faster computer will do is plow through it a little faster. Not sure if that's worth spending that much money on. If that's your main reason for upgrading, I'd skip it. It will still be slow at compiling all of that, just somewhat faster than it is right now.

Cronix left a reply on Switch Team Subscription Error • 2 weeks ago

I'm glad you found a solution, but you really shouldn't alter vendor files. It will mess upgrades up (overwrite your changes).

What I usually do when I need to alter the core functionality:

  1. copy the file you want to alter to /App/SparkExtensions (or wherever)
  2. change the class definition, to something like:
use Laravel\Spark\Interactions\Settings\Profile\UpdateContactInformation as SparkUpdateContactInformation;

class UpdateContactInformation extends SparkUpdateContactInformation
{

I 'use'd their class, but aliased it to 'SparkUpdateContactInformation, and then used that name to extend my own from.

  1. Register your class in the ioc in the SparkServiceProvider's register method
public function register()
    {
        $this->app->singleton(
            'Laravel\Spark\Contracts\Interactions\Settings\Profile\UpdateContactInformation',
            'App\SparkExtensions\UpdateContactInformation'
        );
    }

Now spark (or any laravel app) would use your implementation instead of the native one when it tries to resolve that class from the container.

Cronix left a reply on Spark Installation Errors • 2 weeks ago

Try installing using composer instead of the spark-installer. You need to add the satis spark repo to your composer.json, but that's covered in the installation guide.

Cronix left a reply on Uncaught ReferenceError: Spark Is Not Defined • 2 weeks ago

There's probably no way for someone to guess what you could have done to break it. Since you can get it to work until you start changing it (adding your code) I'd start with a fresh copy, verify it works, and then start tediously copying small parts of code, AND TEST IT each step of the way until you break it. Don't start copying everything. One small piece at a time until you find what actually is breaking it. Once you determine that, and if you can't figure out what' causing it on your own, I'm sure we can help, but we need to narrow it down quite a bit.

That said, I don't believe spark is 100% compatible with Laravel 5.5 yet. I'd use 5.4 until they have a 5.5 compatible release, which should be really soon.

Cronix left a reply on Where Do I Raise Issues Or Provide PRs? • 2 weeks ago

Spark is a commercial product, and not open source, so the "public" doesn't have access to it. If you have a Spark license, you can access it once you set it up.

  1. Login to your account on spark.laravel.com
  2. Go to your profile (click settings)
  3. On the left menu, select Github and follow the directions to add your GH account

Once added, you can access the repo at: https://github.com/laravel/spark

And the Docs repo is at: https://github.com/laravel/spark-docs

5th September, 2017

Cronix left a reply on What $table->foreign~ On A Migration Does? • 2 weeks ago

It creates a foreign key on the current table named estado_id pointing to the 'id' field on the estados table.

Cronix left a reply on Switch Team Subscription Error • 2 weeks ago

I really couldn't tell you, I haven't used anything tax-related with spark.

4th September, 2017

Cronix left a reply on Eloquent Relation Scopes? • 2 weeks ago

@PeregrineStudios You can apply any query builder method to it as long as it doesn't execute the query, like ->get(), etc.

Cronix left a reply on Vue.js Components And SEO • 2 weeks ago

best to google that. But the answer seems to be no, it's not seo friendly, at least not without some forethought and work. You could always use blade for the initial view, with all of your SEO goodies, and then use Vue to manipulate it after it's rendered. One of the downsides to javascript...

Edit Your Profile
Update

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