Cronix

Cronix

Portland, OR

Member Since 5 Years Ago

Experience Points 903,590
Experience
Level
Lessons Completed 1025
Lessons
Completed
Best Reply Awards 1211
Best Answer
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.

19 Jan
1 day ago

Cronix left a reply on TrimStrings Via API?

Yes, but why? Wouldn't it be much better to clean up your data in the database and remove all of the unnecessary spaces wasting space in the db if they aren't wanted/needed?

I'd write a script to remove the spaces in the database that is currently there. Then, I'd also be stripping it off of any new data going into the database. Cleaning it up on output, each and every time, is not efficient at all and puts unnecessary strain on the app.

Cronix left a reply on TrimStrings Via API?

return [
    'ordnumbe' => trim($this->ORDNUMBE)
];

Again, trimstrings works only for the data you send to the api, not what you receive back.

For instance, an ajax post request sending {name: "value "} as a key/value pair would trim the value to be just "value" for thename` key.

Or a form input.

<input name="name" type="text">

trimstrings will trim the value of whatever was submitted for name

trimstrings has nothing at all to do with the data you send back in the response. Only what is received from the request. You're not actually sending any data in your request at all. It's a simple get request.

Cronix left a reply on Send Data From View To Other View

GET|HEAD  | search/{search}

Then the variable in the show method should be search for that request, not officer.

Personally, I'd rename it to {officer} there if that's actually the object you're searching on.

Cronix left a reply on Laravel 5.4 - Creating New Model And Attach Data To PIVOT

Your updated code has the same problem elsewhere.

public method save(Request $request)

Cronix left a reply on TrimStrings Via API?

How are you sending data to your api? It would be best to show it rather than explain it.

Cronix left a reply on Send Data From View To Other View

What does the route to that method look like, and are you sending the officer ID to the route using route model binding?

Cronix left a reply on Case Insensitive Route Model Binding?

Route::get('user/{username}', '[email protected]');

Now $username will be passed to the show method. It's just a variable since it's between { and }.

https://laravel.com/docs/5.7/routing#route-parameters

Cronix left a reply on Send Data From View To Other View

We have no idea what you've actually done unless you show it.

Cronix left a reply on Laravel 5.4 - Creating New Model And Attach Data To PIVOT

public method addGroup(Request $request){

How does public method even work?

18 Jan
2 days ago

Cronix left a reply on .env Not Reading Variables Sometimes

@john.pope That's exactly what php artisan config:clear does as well.

17 Jan
3 days ago

Cronix left a reply on Catch NotFoundHttpException

Your code would be useful.

Cronix left a reply on Multiple Form Update

You can also use variables for the method name.

$methodName = 'update' . ucfirst(request('type'));

if (method_exists($this, $methodName)) {
    $this->{$methodName}();
}

Cronix left a reply on Model Return Types

@return \Illuminate\Database\Eloquent\Relations\HasOne
16 Jan
4 days ago

Cronix left a reply on How Can I Get The Last Digit In The Url, Laravel 5.5

@True, which is why I made the 2nd suggestion (which would be solid) and mentioned that it depends on what kind of pattern there is (which was never stated). You'd be able to get the value directly from the query string as a variable since it will make an array of the keys/values and you can just grab the value for valorusario. Even regex would have problems as I pointed out (if url has 2 different places for digits and isn't constant, etc).

Cronix left a reply on How Can I Get The Last Digit In The Url, Laravel 5.5

Another option is to use these 2 php commands.

Parse the url - get query string: http://php.net/manual/en/function.parse-url.php

Parse the query string that you got from the above function. Then you can directly get the value for valorusario, which would give you 3. http://php.net/manual/en/function.parse-str.php

Cronix left a reply on How Can I Get The Last Digit In The Url, Laravel 5.5

There are lots of ways to do that. It's important to know though, whether it will always be the last character in the url. Is it a pattern, in other words.

If you know it will always be the last char in the string, you can just grab it.

$lastChar = substr(request()->headers->get('referer'), -1);

You can also use regex and actually grab digits from the string. That might work, but again, it depends on if there is a pattern to look for. There could be a number in 2 different places in the url or something.

Cronix left a reply on Whoops Doesn't Show Any Errors. Homestead 2.0

@cilyan The thread is 3 years old. The last post before yours was Jan 8, 2016. Take that into consideration when looking for current solutions.

Cronix left a reply on How To Display Section In A Page Template

Watch this free series for an intro to laravel: https://laracasts.com/series/laravel-from-scratch-2018

You can also check the docs: https://laravel.com/docs/5.7/blade

You didn't post any code, so not sure exactly where you are with your issue, so it's probably best to start from scratch since it seems you're new to Laravel.

Cronix left a reply on Syntax Error Or Access Violation: 1582 Incorrect Parameter Count In The Call To Native Function &#039;radians&#039

Are you sure your form input name is "lang" and not "long" for longitude? If it's wrong, then $lng is null.

$lng =  $request->lang;
15 Jan
5 days ago

Cronix left a reply on Login Works On Local Server But Not On Production [HELP]

Check the error log. /storage/logs/laravel.log as well as your nginx log.

Cronix left a reply on Validate Dropdown Values

Yes, and give them id's and store the id's in the foreign tables rather than the name of the currency.

currencies
----
id
name
<select name="currency">
    <option value="" selected>Select a currency</option>
    @foreach ($currencies as $currency)
        <option value="{{ $currency->id }}">{{ $currency->name }}</option>
    @endforeach
</select>

validation rule:

'currency' => 'required|exists:currencies,id'

You just need to create a basic currency model and pass $currencies to the view(s) with the form(s).

Cronix left a reply on How Can I Host Storage On Different Source?

Look in the docs for storage. It uses the Flysystem, and if you visit the homepage for that project you can find many other adapters that aren't included out of the box, like google cloud. https://github.com/thephpleague/flysystem

Cronix left a reply on Validate Dropdown Values

Typically the better thing to do would be put your currencies in the database. Then use the database to generate the select element, and use the database for the validation in rule. Then you have a single source of truth and only one place you need to update if you add/remove a currency. If you hardcode it, then you have multiple places to update (your views and validation rules).

Thinks like "yes/no" options...not so much, but things that can change really should. I'm sure there will be other cryptocurrencies created in the future, so you will most likely at least be adding new ones.

Cronix left a reply on Can't Change Data After Using Axios

Change it...where? In the database? In your app?

14 Jan
6 days ago

Cronix left a reply on Laracasts Membership Pricing

What amount is actually being charged? Not what the invoice says, or the site says, but how much is actually being taken out of your account?

Cronix left a reply on Can You Rename Migration Files To Your Own Custom Format?

I hear you, but I think if you just power through that thought, your life will be simpler and you'll code faster. It drove me nuts for awhile early on too, and after coming up with my own migration naming scheme, it was just easier to use artisan make:migration and go with it rather than run it, rename the files, sometimes forgetting to increment by 10 instead of 1, etc. It just wastes time in the end. Once I just accepted it, things were just easier lol.

Cronix left a reply on Can You Rename Migration Files To Your Own Custom Format?

No problem. One thing to keep in mind is when you do it that way, it gets hard to create a migration that should be run between 2 other existing migrations since there isn't any room for additions if you use 001_migrationName, 002_migrationName, etc, and you end up having to rename a lot of things. That's a typical scenario you come across in dev (obviously you wouldn't add migrations in between other migrations on a production box.) With the timestamps used, that's pretty easy since they aren't sequential, but are still chronological, so you can insert many new migrations in between existing.

Cronix left a reply on Changes To App.blade.php Not Rendering

It looks like you're editing the vendor package (/spark/resources/views/layouts/app.blade.php), which you shouldn't do. Your changes get overridden when you update Spark that way. You should run artisan vendor:publish and install everything related to Spark (also artisan view:clear to clear the view cache). Then edit the views in /resources/views/vendor/spark. See the bottom of the customization guide: https://spark.laravel.com/docs/7.0/customization

Cronix left a reply on Can You Rename Migration Files To Your Own Custom Format?

Yes, you can name them however you want, but they will run in alphabetical order (which is why laravel timestamps them). Also you can change a migrations name after the fact (you've already run the migration). You just need to change the filename in the migrations database table (so it can find it to roll it back) in addition to changing the actual filename and classname.

Cronix left a reply on Passing Multiple Data To Blade Template

In your controller, do you define a $page variable before sending it to the view in your compact() function? As a side, $slug shouldn't be in compact. Only string names of variables, like 'slug' (like how you have the other variables in compact)

13 Jan
1 week ago

Cronix left a reply on Laravel Forge Pushing To Master Gives An Error

public/js/app.js
public/mix-manifest.json

Those files shouldn't be tracked by git then. Add them to your .gitignore and remove them from git.

git rm --cached public/js/app.js
git rm --cached public/mix-manifest.json

Now you won't get the error on production when the files change (which is what's causing the actual problem) after you run npm for production.

Or, alternatively, keep them in git and run npm run production on your box and commit the compiled assets so the compiled versions are in git, and then don't run it on production.

Cronix left a reply on Laravel Tinker Problem

Video unavailable...

Cronix left a reply on Return User To Page They Logged In From

Ah, I think the problem is because it's an ajax request, and you can't return a redirect to javascript, which is what it's doing internally. You'd need to return the url to ajax, and then do window.location.href = /the-returned-url to make the browser redirect back to it.

Cronix left a reply on Laravel Forge Pushing To Master Gives An Error

Are you sure you didn't run npm run production or anything on the production box?

Cronix left a reply on Return User To Page They Logged In From

if they are not logged in it pushed them to the login screen

Does it not redirect them back to where they originally were after they were forced to login?

Cronix left a reply on Return User To Page They Logged In From

That's how the default behavior works if I'm understanding correctly?

If you go to /some-url-requires-login and you're not logged in, it will force you to login. Once you do, it redirects you back to the intended page you were originally trying to access, /some-url-requires-login. Or if you are already logged in and the session has timed out (maybe you walked away for a few hours), whatever action you next take that requires auth forces you to login again and redirects you back to where you came from.

Cronix left a reply on How To Create Facades On Laravel 5.7 Package

You have a typo on your part.

namespace mpesa\Facades;

Mpesa should be capitalized so it matches everything else.

Cronix left a reply on Laravel Cart

It's not stock laravel, so you'll have to find whatever library that is, or maybe that's what the tutorial is building? Who knows. We don't know the site/tutorial you're looking at. There are many, many different shopping carts out there and we have no idea which one you're talking about.

11 Jan
1 week ago

Cronix left a reply on Upgrade Billing Plan After X Days

Yes, you got it. As I said I haven't tried it they way you're wanting, but it looks like it would work according to the various docs I linked to.

Cronix left a reply on Upgrade Billing Plan After X Days

Haven't tried it, but sound like it might work if you offer a regular plan (instead of free), and then create a coupon/discount for it and apply it automatically so the user doesn't have to manually enter it? So it charges x on signup and goes to y after some period of time?

Apply to every invoice, just one invoice, or for a certain length of time

https://stripe.com/docs/billing/subscriptions/discounts

Cronix left a reply on Not Seeing How To Get Laravel Code Style In PHPStorm

@davestead I misunderstood what you were after. I guess the main question is why your app needs to be psr-2? That's really for the interoperability of libraries/packages so they share the same coding style between various frameworks, not your actual app? Is your app going to be imported via composer into other apps? Unlikely, or it would be a package?

The link you posted in your OP regarding Laravel, is for if you are going to `contribute to the framework'. It's under the "contribution guide," not "how you should code your app."

Cronix left a reply on Your Understanding Of What A MySQL Schema Is?

Schema is a generic word (it's Greek) that has been used across many industries. It's not specific to databases at all. I think if you just google the actual definition (not specifically related to databases) it would be more clear. It just describes how to define the database. Just like in electronics, a schematic is the blueprint to create a circuit board, and in construction the schematic is the blueprint to build the house. The database schema describes how to build the database and tables.

  1. : a diagrammatic presentation broadly : a structured framework or plan : outline

https://www.merriam-webster.com/dictionary/schema

  1. a diagram, plan, or scheme.
  2. an underlying organizational pattern or structure; conceptual framework:

https://www.dictionary.com/browse/schema

Cronix left a reply on Not Seeing How To Get Laravel Code Style In PHPStorm

Do you have the laravel plugin enabled? Go to your plugins and type laravel in the search bar. Another huge help is this package, which I always install first thing in any project: https://github.com/barryvdh/laravel-ide-helper

10 Jan
1 week ago

Cronix left a reply on Carbon: The Separation Symbol Could Not Be Found Unexpected Data Found. Trailing Data

Are you positive there is no extra data (a space) in your date input? I literally used your code above in tinker (see above) using the value you supplied (10/01/2019) and it works fine.

Cronix left a reply on Carbon: The Separation Symbol Could Not Be Found Unexpected Data Found. Trailing Data

Why would you add the time (toDateTimeString()) if it's just a date? It will use the systems current time if you don't supply a time, which is probably not what you want.

Cronix left a reply on Laravel - Route Based On Form Submit?

In HTML5, you can use a formaction attribute on one of the submit buttons to tell it to submit the form to a different url.

<form action="/page1">

    <button type="submit">Submit to page 1</button>
    <button type="submit" formaction="/page2">Submit to page 2</button>

</form>

If first submit clicked, it will go to the normal action of the form (/page1). If the 2nd submit is clicked, it will submit the form to /page2.

https://www.w3schools.com/tags/att_button_formaction.asp

09 Jan
1 week ago

Cronix left a reply on Lifer, But Can't See Videos

At the bottom of the page there is a "Support" link, that has a popup to contact Jeffrey.

Cronix left a reply on Auto Logout If No Activity In Given Time

@amirhazz How would that achieve what the OP is wanting, which is based on the users role?

Cronix left a reply on Class App\Providers\AppServiceProvider Not Found Within ProviderRepository.php

Most likely you just need to run artisan clear-compiled, which will cause it to regenerate the classes that it's autoloading. It's not aware of your changes and is using the old cached version found in /bootstrap/cache/packages.php.