Cronix

Cronix

Portland, OR

Member Since 5 Years Ago

Experience Points 889,800
Experience
Level
Lessons Completed 1006
Lessons
Completed
Best Reply Awards 1193
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.

12 Dec
1 day ago

Cronix left a reply on Total Newbee Who's Been Given An Existing Site To Edit

If your new to laravel, updating is the last thing I'd be trying to do, especially through that many versions. A lot of the changes are trivial, but you don't know the codebase you're working with since you didn't code it, and upgrading some things really requires that knowledge.

I'd just find out specifically what version of laravel the code is using so you can refer to that version in the docs, and do the updates that you need to do. Do the upgrade after you're more familiar with how everything is working under the hood. You will really have your work cut out for you if you upgrade first without actually knowing the app.

Cronix left a reply on Laravel Website With 1500000 Users At The Same Time

Is there a way to test how many requests a server can handle at maximum?

Yes, and that's what you need to do. "Load testing"

For databse server how RAM and CPU needed so it can handle this much traffic?

That will also be revealed during load testing. It's a crucial step when building something of this size. You need to know what the hardware will handle. This is why I suggesting on testing against several different machines of different sizes. Often having multiple smaller servers will outperform a larger server. You don't want to test them to 100% usage (using 100% cpu/memory/etc). Test them to about 80% capacity and don't let your servers run higher than that. You never want to peg a system to 100% as it becomes inoperable.

Once you have the numbers for different server options, you can then decide on the most economical way to go (many smaller servers vs fewer larger servers).

https://www.guru99.com/load-testing-tutorial.html

The questions you're asking there isn't a one size fits all answer. There is no "Oh, for 150k users, you need x cpu and y ram. Because every single app is different. A "to-do" list type app would need very few resources compared to something like facebook. You could probably get 3x as many users on the to-do list app using the same hardware vs a FB type app. You need the actual data that only load testing would really provide, by running your specific app code on it.

Cronix left a reply on Display Any Type Of Video On Web Page

This is why most video sites use ffmpeg or similar tool to convert the uploaded video to a useful web format like mp4. Then you don't have to worry about esoteric video players. Everything gets converted and served as web friendly mp4 that any (modernish) device can play. The video player becomes irrelevant.

Cronix left a reply on Address Bar Problems

What about my first problem?

You didn't show how you are trying to make the link with the dashboard route, you only showed the route definition. So how could we know what your mistake is? You just say "it's not working"

For your second problem, you don't have a route defined with the name of admin, so this doesn't work

<a href="{{route('admin')}}">manage </a>

Cronix left a reply on Learn It All Wrong First?

Still wish I knew specifically what the OP was talking about. Without a specific video to illustrate the point, there really isn't one.

Cronix left a reply on Proper Way To Skip Duplicate Value While Inserting 100k Rows

Nice but how can I know if I created or it was already in db?

You can't without querying the db first to see if it exists.

11 Dec
2 days ago

Cronix left a reply on Learn It All Wrong First?

ʇxǝʇ dǝɹoɹɹᴉɯ ɓnᴉdʎʇ sɐ ๅooɔ sɐ ʇsoɯๅɐ sᴉ ʇɐɥʇ ʻʍoM

Cronix left a reply on Bind A Select Field From Db

@billmn From what I gather, he wants the selected entry to appear first in the list.

Like if the select originally had options

<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>

And if in the db the person had "2" as the value, then he wants the options to be displayed with 2 as the first option, instead of 1, like

<option value="2" selected>Two</option>
<option value="1">One</option>
<option value="3">Three</option>

My response: Why does it matter? You'll still see the option that is selected as the chosen option and don't see the others until you expand the dropdown.

Cronix left a reply on Using A Global Php Helper Functions When Developing A Package

As a workaround, you could try to include_once(/your/helper) in your service provider or something.

Cronix left a reply on Using A Global Php Helper Functions When Developing A Package

Are you putting it in your packages package.json, or in laravels? It should be in yours.

Cronix left a reply on Speed Up Make:migration

Do all artisan commands run slow, or just make:migration?

Cronix left a reply on Laravel Website With 1500000 Users At The Same Time

For something like this; load balancing. The app can be running on many servers distributing the load. Once that is achieved, it's literally trivial (a few button clicks) to add/remove servers, or have AWS do it automatically with auto-scaling.

This type of setup is different from a typical setup. You'd have a separate db server that the other webservers share. You'd use S3 for storing all assets instead of on an individual server, so that all servers (acting as one) has access to the same data. If user A uploads a file to Server A, it needs to be accessible by servers B, C and D as well, so it can't be stored on the individual webserver.

The same goes for sessions. A user might login to server A, but the next request gets served from server B. So you need a common session store that all servers use, like redis.

Now you're just left with dumb webworkers, so you can just add new ones to increase capacity and scale.

Here's a good place to start learning: https://serversforhackers.com/c/so-you-got-yourself-a-loadbalancer

You can also use the Laravel Forge service to manage it all (and set it up). It can create load balancers along with servers.

Cronix left a reply on Fill Form From Database

Try removing the is_admin middleware for now. Add it back after you get the main part working. I'd also use an actual segment for {id} in your route like all the examples in the docs show instead of a query string. You also have an error in your variable name here

Route::get('edituser?id={$id}', function ($id) {
    $users = DB::table('user')->get();
    $edit_user = DB::table('users')->where('id', $id)->first();
    return view('Admin.edit_users', ['user' => $users,'edit_users' => $edit_users]);
})
    ->middleware('is_admin');;

You passed $edit_users (plural) to the view, but the variable is actually $edit_user (singular)

10 Dec
3 days ago

Cronix left a reply on Question On New Site Navigation

I have always liked coming to that list to see what was newly published, regardless of course. I’m having a hard time discerning what has changed since my last visit.

For some reason, "Series" is selected by default on the left under the "Lesson Type" section. Uncheck it so it shows all.

Cronix left a reply on How To Handle Multiple Paginations With One Link

Use appends() like the docs show to add additional custom parameters. https://laravel.com/docs/5.7/pagination#displaying-pagination-results

{{ $users->appends(['sort' => 'votes'])->links() }}

add &sort=votes to pagination query string

Cronix left a reply on Fill Form From Database

You're sending it to the wrong url for your route definition. You gave the route a name. Use the route() helper with the route name.

<a href="{{ route('edit_users', $user->id) }}"> Edit </a>

Otherwise, if you want to use the URL::to(), then you need to specify the url that is in the definition.

You defined the route to respond to /edituser?id={$id}, but you're sending the request to /admin/edituser?id={$id}

The route doesn't have an admin prefix, unless you're not showing that to us.

Cronix left a reply on Post Reloads The Page

@nathanoj

although it redirected to https (which should only happen if it is a 'production' site).

Not necessarily. Some domain extensions, like .app, are forced to use https by the browser. It's required. https://blog.nameshield.com/blog/2018/04/19/google-makes-https-hsts-encryption-mandatory-for-its-45-new-tlds/

A safe tld to use that doesn't require https is .test, which is reserved.

08 Dec
5 days ago

Cronix left a reply on Retrieve A Subset Of Database Entries

Silly question, but are you sure the tickets table has a ticket_status_id field, and it's not just called status_id or something? Usually it's redundant to have a field containing the same name as the table it's in.

Cronix left a reply on Validating Iamges

You can get a few of those things using javascript. https://developer.mozilla.org/en-US/docs/Web/API/File

You wouldn't be able to get image dimensions as easily. There is a trick, but it involves taking the file and putting it in an img tag (hidden with css) and getting the image dimensions that way, but you can't get it directly off the file itself like you can with the filesize, name and mimetype. There are js upload libraries like dropzone that can help with some of this as well.

Cronix left a reply on Remember Selected Files After Choosing New One..

The only way you'd be able to is by actually having multiple individual file inputs. That way each input gets to select its own file and won't affect other selected files.

<input type="file"  name="photo1[]">
<input type="file"  name="photo1[]">

This is an html issue (not laravel) with all form controls that can use the multiple attribute, even <select> elements. If you select multiple elements and reopen the select, the previous choices are removed.

Cronix left a reply on Accessor Full_name Breaks AJAX Lookup

is there a specific reason you wouldn't use one of the other methods I mentioned

Yes

Should I add the function from the Controller to a helper file if I want it available for all views (since it is in the nav bar of the app.blade.php file it will essentially be available almost everywhere)?

Or should I add it to something like common.php and use ... in every controller?

This is simpler than either of those 2 things. By putting it on the model (which seems appropriate since it's for a query on that model), it makes it automatically available wherever you use that model. So less code since you don't have to include it on other pages. What you suggested would definitely work. I just like to have my model code in models and not spread out over many files.

07 Dec
6 days ago

Cronix left a reply on Illuminate \ Database \ QueryException (23000) SQLSTATE[23000]: Integrity Constraint Violation: 1048 Column 'name' Cannot Be Null (SQL: Insert Into `students` (`name`, `address`, `number`, `updated_at`, `created_at`) Values (, , , 2018-12-08 04:19:17, 201

Where's the rest of the form? You're just showing a submit button and a close form tag. Show the whole form including the opening form tag, all fields, and the form cllose tag.

Cronix left a reply on Weird Redirect When Using Back()

something like

$duplicate = $this->places_service->checkDuplicates($place, $insert_data['name'], $request->input('type_1'));

$this->validate($request, [
    'title' => [
        'required',
        function($attribute, $value, $fail) use ($duplicate) {
            if ($duplicate) {
                $fail(__('places.record_duplicate'));
            }
        }
    ]
]);

Cronix left a reply on Weird Redirect When Using Back()

I don't know how to validate when it depends on two inputs at the same time

Did you check the link I posted? You can do whatever you want in the closure and use as many parameters/variables as you need. You can use $request in it as well (if you pass $request to the closure with use)

Cronix left a reply on Weird Redirect When Using Back()

I believe it should be ->withErrors(['title', __('places.record_duplicate')]);, using a comma instead of an arrow. It's not an associative array.

Cronix left a reply on Accessor Full_name Breaks AJAX Lookup

I'd just turn it into a query scope and put it on the model. https://laravel.com/docs/5.7/eloquent#query-scopes

public function scopeFullnameLike($query, $like)
{
    return $query->whereRaw("CONCAT(contact1firstname,' ',contact1lastname) LIKE ?", ['%'.$like.'%'])
}

Then you could just do

$data = Contact::where('user_id', '=', $user_id)
            ->fullname_like($query)
            ->get();

and use it wherever you wanted

Cronix left a reply on Homestead 502 Bad Gateway For Php 7.3 Web App - Works With 7.2

I don't believe it's fully tested yet. If you look at the comments on their .travis.yml file in the framework repo, you'll see "Allow 7.3 failures". There is a fix waiting to be merged to change that. 7.3 was only officially released yesterday. Are you sure the 7.3 version in homestead is the stable version officially released yesterday?

Cronix left a reply on Accessor Full_name Breaks AJAX Lookup

->where('full_name', 'LIKE', '%'.$query.'%')

That won't work. That's an actual sql query which knows nothing about your made up accessor. It's literally saying where full_name like %var% so it's expecting an actual full_name column to exist (this is sql, not php).

You'd have to use whereRaw for that and use sql to do the actual concatenation with concat(). https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat

something like

->whereRaw("CONCAT(
return User::whereRaw("CONCAT(contact1firstname, ' ', contact1lastname) LIKE ?", ['%'.$query.'%'])

Cronix left a reply on Add Playing Time To Episode List?

@jlrdw yes it shows on different views as you pointed out, but what does that have to do with the specific link he's talking about? Click the link in his first post (the one he was actually talking about). The times are missing. It doesn't matter if you can find it somewhere else. It's not convenient to have it listed in some places and not others bc you then have to stop what you're doing and go somewhere else to find the info. You're talking about the series page, and he's talking about the browse page. 2 different things/views. One shows times, the other doesn't.

Cronix left a reply on Quicker Route:cache

Do you happen to have the php imap extension enabled? Try disabling it if it is and you're not using imap functions (most likely not). There have been cases where having that extension enabled slows down cli and adds like 5 seconds to response times, even with php -v taking 5 seconds to respond at times.

Cronix left a reply on Quicker Route:cache

Check the php version of the php cli instance and make sure it's up to date.

Cronix left a reply on How To Use Ajax In Laravel ?

Yes, data will be the same as $post. An object with the properties you saved.

Cronix left a reply on How To Use Ajax In Laravel ?

You're close.

With ajax, you don't want to return a redirect from the controller. First, ajax will ignore that. Redirects don't work for ajax requests, only for full page requests. Second, you should just return the data back to the view that you just saved in the store() method (return $post;). Then in the success method of your ajax request, you receive that data and insert it into the current page, or update existing data on the current page. That's how you achieve the "without reloading the page" because you never leave that page. You just update the current html in the page.

Cronix left a reply on No Queries Being Exected With Route-model Binding?!

@sergiu17 is correct about the reason why it's not working (the route parameter name needs to match the function parameter name), but I'd just change the route variable name since that's more representative of what you're actually retrieving.

Route::get('guild/{discord}', '[email protected]');
05 Dec
1 week ago

Cronix left a reply on Forms, Hidden Inputs And Request Generators - Some Questions

My question is, is it safe to put hidden fields where are ids or other important data that will be added to the database?

It really depends on the data. Mostly passing ID's is ok, if you're sure the user should have that type of access. I mean, if you have a way to add states to countries, you have to have a way to pass the country_id when creating a state for it.

After all, someone can use the request generator and provide false data there.

I'm not sure what you mean by "request generator"

Is there any way to check, that the request is from my website? How to take care of it?

If you're using csrf tokens on your forms, then it would be impossible for someone to send a request to your site from a different site and have it succeed.

Use authentication, along with authorization. A lot of people don't do the authorization part. Also, use validation and make sure the data you receive from the user is valid before inserting it. You can prevent a lot by doing these things. There is a section in the docs for each.

Cronix left a reply on Run Laravel Without Storage Permissions

As stated you haven't set up your host properly. The /public dir should be the sites document root. There's no way you should be able to access any of the other dirs via the url.

Cronix left a reply on Farewell NOVA For Now, For Me. *Not Ripping On. Just Didn't Work In My Use Case

If you want to actually benefit people with your post, why don't you actually state why it didn't work for you and what your use case was? The way you've written it, it's just someone ranting with no data behind as to why so it doesn't make very much sense or provide any real useful info. I really don't see the point of the post - because you didn't actually make one. All you've really done is stated you won't use it anymore. Ok! Thanks for letting us know lol.

Cronix left a reply on Validating And Uploading Images

@hossamali Not that I'm aware of.

04 Dec
1 week ago

Cronix left a reply on Incorrect Date Value

@drfraker Except he's using js date objects, not php.

However, there are packages for momentjs that will easily create a date range like you can with carbon. Then you'd just need

const range = moment.range(new Date(2018, 11, 17), new Date(2012, 12, 10));

https://github.com/rotaready/moment-range

Cronix left a reply on Validating And Uploading Images

@sergiu17 That doesn't validate before uploading. That only works once the server has received the uploaded image.

@hossamali You can, but it would require javascript since you want to validate in the browser. You need to validate on the backend too since browser validation can be defeated/bypassed.

You can access the file name, size and type off of the <input type="file"> inputs that have a file selected.

https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications

Cronix left a reply on Laravel Relative Paths In Urls

You can't use file:// in source tags in html. It's an HTML limitation and has nothing to do with laravel.

You could create a symlink from HardDrive/MyFolder/ to /public though.

Cronix left a reply on Incorrect Date Value

Not to do with the issue, but please see this big warning about using env() outside of config files: https://laravel.com/docs/5.7/configuration#configuration-caching

You won't be able to cache the config on your production box, which makes the app run faster. You should only use env() in a config file, and use the config() helper to get the values instead of env().

Cronix left a reply on How To Shift Text To HTML

A picture of the problem would help. We also don't know all of your css class definitions, and this is probably a css issue, so we don't really have enough info to answer the question.

Cronix left a reply on How To Store Array Of Data In Cache?

Ok, well it's just a basic associative php array. You need to access the right keys to get the individual values you want and make a new array with just those. It looks like it would be

$data = [
    'id' => $request['repository']['id'],
    'name' => $request['repository']['name'],
    'tags_url' => $request['repository']['tags_url'],
    'archive_url' => $request['repository']['archive_url'],
    'updated_at' => $request['repository']['created_at'],
];

// now cache $data

Cronix left a reply on How To Store Array Of Data In Cache?

I Just like to store some data in repository array

Yes, but what data do you want to get from that array to store in cache? Because $request['repository']['id']['name']['tags_url']['archive_url']['updated_at'] that array key doesn't exist.

03 Dec
1 week ago

Cronix left a reply on How To Store Array Of Data In Cache?

$repo_date = $request['repository']['id']['name']['tags_url']['archive_url']['updated_at'];

That's what you're storing in cache ($repo_date). Does that multidimensional array exist in the request object? What do you get if you dd($repo_date); right after that line?

Cronix left a reply on How To Store Array Of Data In Cache?

You don't assign value to $hooks here when you retrieve from the cache.

if (Cache::has('repo')){
    Cache::get('repo');
}