TylerW

TylerW

Member Since 1 Year Ago

Experience Points 6,210
Experience Level 2

3,790 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 47
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

07 Jun
1 week ago

TylerW started a new conversation Laravel Cashier Cancelling Subscriptions

Apparently, it is not supposed to show a subscription as 'cancelled' in the BrainTree payment panel until the ends_at date in the subscriptions table is reached for that subscription. Is this true? This is super confusing to me, but I tested it with the cancelNow() function and it did indeed update on BrainTree immediately.

Am I explaining the intended functionality correctly? This is just scary to me because I don't want any of my users to get charged if they cancelled for obvious reasons.

25 May
3 weeks ago

TylerW left a reply on Resources For Learning How To Manage Server Resources?

@SNAPEY - Wow, this looks exactly like what I was looking for. I came across a couple of similar things but I really trust this community a lot more than I do Google search results, so thank you for this. Going to eat this content up.

TylerW started a new conversation Resources For Learning How To Manage Server Resources?

I got lucky - I made an application and it turns out there are some people who actually want to use it. I never thought I would get this far.

My application is based around retrieving information from a database with about 80 million rows. The database is heavily indexed, and the information in it is static - it isn't written to, except with user account data. The people using my application are performing search queries on this database essentially once every couple of seconds.

Currently I am running the website on through Forge on a Digital Ocean droplet with 3GB of RAM and a 60GB disk. The point of this post is: I want to learn how to monitor the performance metrics on the server and know if/when I will need to upgrade things like RAM and CPU speed.

I've been watching the graphs on Digital Ocean and so far everything seems fine. CPU usage is rarely over 5% and memory usage is a steady 16%. Disk usage is sitting at 37% and the disk I/O has spikes of up to 350kb/s pretty frequently (no idea what this means). The bandwidth public gets spikes of .05mbps frequently, and occasionally a large spike to .36mbps. Those are all the graphs at my disposal.

Is monitoring those graphs all I need to do to ensure I always have enough "juice" to power my application as my number of users increases? What is a good resource to learn how to monitor my server's load and how/when I need to upgrade different components of it? Appreciate the help in advance guys.

25 Feb
3 months ago

TylerW started a new conversation Reset Component Data Upon Ajax Request Submission

So I have a button that @click calls a method in my main Vue instance called "search." I also have a bunch of buttons used to filter the search on the page, and these are all in the form of components with a data function that contains a property called 'selected.' This selected property is used to determine whether or not a class is displayed that visually shows the button as selected for the user.

When a user clicks the search button and the search method is called, an ajax request is performed and I want to reset everything. The last thing I have left to reset is that 'selected' property of the buttons which were selected, which should be set back to false. How do I go about changing the 'selected' property to all components back to false when a method such as 'search' is called in the main Vue instance? Thanks in advance!

28 Jan
4 months ago

TylerW started a new conversation Variables From Laravel Session To Vue

I know there are other threads created about this, but I've been scouring them for over an hour and I cannot seem to understand how to achieve the desired functionality I want.

I have a text input bound to "hand", a data property in my Vue instance. This is set to blank by default. There is a button next to the input with an @click="lastHand", which calls a Vue method that is supposed change the hand property to the value of session->get('last_hand').

Here is my Vue code, which references the problem:

const app = new Vue({ el: '#app', data: { hand: '' }, methods: { lastHand() { this.hand = "This string should be equal to session()->get('last_hand'), how do I put that here?" } } });

21 Jul
10 months ago

TylerW started a new conversation Redirect To Login Page If User Registration Email Is Not Unique

If someone goes to register and that email is taken, I just want it to take them directly to the login page. How would I accomplish this using the default php artisan make:auth scaffolding? Not sure if I can do this by modifying the current validator or if I need to make a custom validator, but I don't have any experience with that so some help would be appreciated.

TylerW left a reply on Creating A New Account With A Soft Deleted Email

@Snapey I agree, this seems like the way to go and I've implemented the _deleted to the email upon deletion.

so you probably don't want that account taken over by the new user else they will be attributed with previous activity.

This isn't the case. First and foremost, in this case the 'new user,' even if they were someone totally different, would not in any way be associated with the previous activity because all associations are by ID. An action is only associated with an account, not an email. Practically speaking, it wouldn't even be possible for someone to maliciously register under an email (if that is what you are inferring) because there is multi-level verification based around existing "IDs" independent of our application. The only possible case is that someone registers with the same email who is also the same person who previously held the account. Although they will still not be directly associated with the actions of the previous account, we will be able to easily see if/when they signed certain agreements in the past, etc. I know, it's a fairly obscure use case.

TylerW left a reply on Creating A New Account With A Soft Deleted Email

@jlrdw Long story short, occasionally we will have a case where an administrator manually creates an account (with a certain email), and then deletes that user and we will want that user to be able to come in and register a completely new account and go through the process as if they are a new user, but we don't want to lose the account the administrator "deleted" for legal reasons (contracts the user may have signed in the past, etc.) In other words, we just need there to be one unique ACTIVE account at a time, not necessarily unique to all entries including deleted.

TylerW started a new conversation Creating A New Account With A Soft Deleted Email

If I soft delete a user, I want another user to be able to create an account with the same email that is soft deleted. I figured the default php artisan make:auth scaffolding would account for this when checking if an email is unique, but alas it appears that is not the case. Where exactly would I go to fix this?

11 Jul
11 months ago

TylerW left a reply on This Site Can’t Be Reached On Production Server After Client Made Changes Via SSH

Thanks guys, I'm going the route of setting up a new instance now. Really appreciate your expertise and time.

TylerW left a reply on This Site Can’t Be Reached On Production Server After Client Made Changes Via SSH

That makes sense. When I try and run

sudo nginx -t

I get:

sudo: nginx: command not found

Sounds like something is either seriously messed up or I've been looking at the wrong stuff. The server should be running nginx right?

If you guys don't have any other ideas I'll break the news to the client and start over.

TylerW left a reply on This Site Can’t Be Reached On Production Server After Client Made Changes Via SSH

When I use the history command, here are all of the commands he entered:

55 curl -sSL https://agent.digitalocean.com/install.sh | sh 56 sudo nano test.txt 57 curl -sSL https://agent.digitalocean.com/install.sh | sh 58 exit 59 mysql -uforge -pXXXXXXEDITEDOUTXXXXX 60 export DEBIAN_FRONTEND=noninteractive; echo 'Acquire::ForceIPv4 "true";' | tee /etc/apt/apt.conf.d/99force-ipv4; apt-get update; apt-get install curl -y; apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade -y; curl --silent --location https://manage.runcloud.io/script/installer/03IIOz0sfLGH9R0GdHkPTrtMAD1531248913ns6tBiCZGrDuY5WJgDuOQLZQhG6MaSeSjklfdsjaklSDJFIlsdfsaklScGIQO0zcRi0AN/7X77cGB9L7Do2w6XrPx3nj5661nUzLifGQLjdoflBKiXs3efsjk32kjsdkjflUlMcCx7C0HWiRsh38xy913omOPbKJBzH08tofml4QTqdO4eaMQ16WlSHWfddfja39j2lkmafdsa324239kOZYfXB4Dn6i0ziVBOfdsfKiF | bash -; export DEBIAN_FRONTEND=newt 61 exit 62 su root 63 cu root 64 su root

TylerW left a reply on This Site Can’t Be Reached On Production Server After Client Made Changes Via SSH

@lostdreamer_nl nginx is not running (is has a minus sign next to it). When I enter sudo service nginx start, I get:

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

Following the recommendation in the message, I enter systemctl status nginx.service and get:

● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2018-07-11 15:21:54 UTC; 1min 27s ago Docs: man:nginx(8) Process: 2499 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=203/EXEC)

TylerW left a reply on This Site Can’t Be Reached On Production Server After Client Made Changes Via SSH

@ohffs Thank for you taking the time. I'm trying to follow your instructions step by step but I'm still a bit lost.

When I run pgrep apache, nothing happens. When I run httpd, I get:

(13)Permission denied: AH00072: make_sock: could not bind to address 127.0.0.1:81 no listening sockets available, shutting down AH00015: Unable to open logs

curl localhost shows that it's not reachable from inside the server. It returns curl: (7) Failed to connect to localhost port 80: Connection refused.

When I try and run iptables I get:

iptables v1.6.1: can't initialize iptables table `filter': Permission denied (you must be root) Perhaps iptables or your kernel needs to be upgraded.

So it looks like I'm failing pretty early on in the process, but not sure where to go from here. Thanks again in advance.

Tyler

TylerW started a new conversation This Site Can’t Be Reached On Production Server After Client Made Changes Via SSH

I am running a Laravel application on a Forge server via a DigitalOcean droplet. A few minutes ago the client emailed me saying the application was "down." Upon further inspection, the server itself isn't down, but the application cannot be accessed and instead returns:

This site can’t be reached 204.XX.XX.XXX refused to connect.

Try:

Checking the connection Checking the proxy and the firewall ERR_CONNECTION_REFUSED

I asked him if he had done anything recently since the application was running smoothly before this, and he told me that last night he had:

A. Reset the root password since "there wasn't one set already" and he needed one for an application he was installing. B. Installed a monitoring application using the new root password.

Does resetting the root password affect Forge at all? Or should I be looking at the monitoring application as the issue? I'm completely unqualified to be a systems administrator, but this is a very small budget gig, so I would appreciate it greatly if you guys could help me out here.

Thanks in advance.

13 Jun
1 year ago

TylerW started a new conversation Best Practice For Changing Database Relationships In Production?

I built a Laravel application that is now in production. Only one problem: currently a location belongs to a user (one to many relationship of user->locations), when the client now says he wants it to be many to many (many to many, user->locations, location->users). I have implemented this in code, but how should I go about implementing this when there are already a lot of records in production?

07 Jun
1 year ago

TylerW started a new conversation How To Access Error Log For A Production Laravel Cite On Forge?

Where do I actually go when I SSH into my forge server hosting a Laravel site to access errors that occurred in production? I don't even know how to find the Laravel install, I would of expected it to be in /var/www/html, but it is not. Not a system administrator here, just trying to figure out what the error is that my users are running into on the production server that I cannot reproduce on the development server. Thanks.

04 Jun
1 year ago

TylerW started a new conversation Address Validation

This is more of a general question than Laravel specific, but I'm wondering what the best way to go about address validation is. For example, when users sign up they add a "location" to their profile (which is a standard U.S. address), but I can't have users creating duplicates. Each location needs to be a single entity with multiple users attached to it (many to one).

Is the Google Maps API the best choice here? I haven't used it before personally, but I'm guessing it would be the most consistent way to determine if a user is searching for a location that is already in the database given that people can type addresses with various inconsistencies.

26 May
1 year ago

TylerW started a new conversation Issues Deploying A Site

This may seem like a fairly convoluted matter, but I would really appreciate some help because this is a very important matter for me. I'm not a system administrator, but I am trying to help a client deploy his Laravel site and I'm running into issues.

I am using Forge, connected to digital ocean via his API token. First, I created a droplet and deployed Laravel to it. Everything works great. He has pointed the domain to the droplet and I can access the site through the domain and IP address. Then, when I go to setup the SSL certificate, it tells me I need to enter something other than default in the domain name field. I put in the domain the website is hosted on (although it's not in the root directory of that host, not sure if this matters). All of a sudden, all of the pages on the site now start pointing to a 404 error. I change the site name back to default (which deletes the SSL certificate), so everything should be back to normal, and still getting 404 errors. Tried deploying again to no success.

If I need to start over I can, but how should I go about fixing this? I'm totally lost.

TylerW started a new conversation Best Practice For Two Different Types Of Users?

I'm building an application now where there are two very different types of users. One is a "User" (tons of fields), and one is an Admin (essentially just needs the default make:auth scaffolding). Is there a large benefit to doing something other than adding a isAdmin field to the user and setting up my admin middleware to check the value of this field? I know it's possible to make a totally separate Admin model, but I'm just not quite sure it's worth all of the work and I wouldn't even know how to hook this up with the existing authentication scaffolding from make:auth.

25 May
1 year ago

TylerW started a new conversation Adding Password Reset For Existing, Authenticated User?

What is the best way to go about allowing a user who is logged in to "reset their password" by clicking a button and automatically being sent a password reset email? They don't need to go through the normal reset process, such putting in their email, because they are already logged in.

15 May
1 year ago

TylerW started a new conversation Working With APIs

I understand that Laravel has many tools for actually creating an API, but what about simply working with one? Is there a "laravel way" to make a request to an external API and deal with the data it returns? I saw something on Google about Guzzle, but at the time that person also said that Guzzle was included in Laravel, but that does not appear to be the case anymore. Any recommendations?

13 May
1 year ago

TylerW left a reply on General Confusion About Handling Dates

@Cronix

After doing some troubleshooting, it does appear that the format may be the issue. I noticed in the error page that the problem was that the argument was expecting 'Y-m-d HH:MM:SS' and it was only getting '6:00:00'. When I change the format of the select value to '2018-1-1 6:00:00', it correctly stores the time in the time field.

Then the problem becomes retrieving the data. I get the same error, and for the same reason. The error is:

Unexpected data found. Unexpected data found. Data missing

And the error is coming form the fact that Carbon is trying to create a date with the following arguments

"Y-m-d H:i:s"
"06:00:00"

Is there some way to make it so Carbon will stop trying to create from that format and instead try and create from time? Or should I simply include dummy data in all the places where I only want to store a time? Should I skip using carbon all together for times?

TylerW left a reply on General Confusion About Handling Dates

@Cronix

Could the issue lie in the format? It says in Laravel docs:

When a column is considered a date, you may set its value to a UNIX timestamp, date string (Y-m-d), date-time string, and of course a DateTime / Carbon instance, and the date's value will automatically be correctly stored in your database:

It doesn't appear that it supports a TIME format. How would you recommend I format this?

TylerW left a reply on General Confusion About Handling Dates

@Cronix

I was trying to do that to format the input the user entered, but even if I use the standard time format of HH:MM:SS for the input and remove that so it looks like

"monday_start_time" => request('mondayStartTime'),

I still get a similar error. Only difference this time is it's an "InvalidArgumentException."

InvalidArgumentException
Unexpected data found. Unexpected data found. Data missing

TylerW left a reply on General Confusion About Handling Dates

@Cronix

Okay, so for example I'm running into an error when trying to do the above. I ran into this error last time and kind of gave up due to to time constraints.

I have a Schedule model. Inside of that model I've defined:


namespace App;

use Illuminate\Database\Eloquent\Model;

class Schedule extends Model
{
    protected $dates = ['monday_start_time', 'monday_end_time'];

    protected $guarded = [];
    //
}

Then, in my create_schedules_table I have:

$table->time('monday_start_time');
$table->time('monday_end_time');

Inside of my controller, I'm just doing:

 \App\Schedule::create([
            "user_id" => \Auth::user()->id,
            "monday_start_time" => new Carbon(request('mondayStartTime')),
            "monday_end_time" => new Carbon(request('mondayEndTime')),
]);

This all results in the errors:

Unexpected data found. Unexpected data found. Data missing (View: (route)/index.blade.php)

TylerW left a reply on General Confusion About Handling Dates

@Cronix Okay, and then when I want to go display the times back to the user in a readable fashion, you would recommend I create a new carbon instance with that value and use one of the format methods in the package?

What about storing dates? I read that you there is a protected dates property you can override in a model to automatically create a carbon instance with the designated values. So would you recommend I add my dates there? And then do I need to also add those fields to the Schema::create table method? Or should I just create the carbon instance when I retrieve the date?

TylerW started a new conversation General Confusion About Handling Dates

I'm working on a Laravel project that involves a scheduling component, so I'm hoping to understand how dates should be used in a real world example.

For example, let's say I want a user to select a time from a dropdown.

  1. How would I store this value in the database? Would I save it as a MYSQL Time field?
  2. If I save it as a time field, would I simply plan on adding the correct format to the select? E.g.
<option value="8:00:00">8:00 AM</option>
  1. Could I use "Carbon" to simply do the above in an easier fashion?
  2. How do I manipulate data with Carbon, such as the time, in the correct fashion to display it to the user how I want?

With all of the above questions, I find I'm just simply saving the times as strings and using PHP DateTime to format them. I want to do it a better way.

12 May
1 year ago

TylerW started a new conversation Testing Laravel Application (debugging Error)

I am new to Laravel, and I recently sent the first client site I built in Laravel to the client. This is still the very early stages, so I haven't done any testing yet (although I'm looking into TDD and following the series from Jeffrey Way now, so I plan on doing testing as a part of my development process in the future).

As for this project, although everything seems to work perfectly fine on my end, the client sent me back an email letting me know that he ran into the error: "Whoops, looks like something went wrong." The website is deployed on DigitalOcean using Forge. What is the best way to go about troubleshooting this?

Thanks.

04 May
1 year ago

TylerW left a reply on Determining If A Relationship Exists In A Many To Many Relationship.

@Cronix Well yes, the is just a single table, but the table itself is simply there to define the relationship between my User model and Document model in a many to many fashion. In the same way that I can return all documents using belongsToMany, I was wondering if there is a way to say $user->has('\App\Document', $id), or something like that. To check if that model has a relationship with that document.

TylerW left a reply on Determining If A Relationship Exists In A Many To Many Relationship.

@Cronix At first I thought that was what I was looking for, but now I'm not 100% sure. For example, here is something I am trying to do now:

I want to create a method that determines if the document with an id of 2 has a relationship with an id of 3. I can't seem to understand how to do this, since it appears those are static methods. I can't perform has or whereHas on an instance of the user object, so I don't see how I can tell it that I want it to check both of those. Is there some way to add the additional constraint using the static method?

TylerW started a new conversation Determining If A Relationship Exists In A Many To Many Relationship.

Pretty simple stuff, but it isn't quite intuitive to me yet since I'm new to Laravel. I have documents and I have users. Users can sign many documents and documents will be signed by many users. When a user signs a document, a relationship is made in the document_user table, following the traditional Laravel schema.

I'm trying to create a method to return the next document that a user has to sign. I have added some comments to explain the desired functionality. Is there some way I could do this better?

From my User model:


public function activeDocument()
    {
        /*
        Pull in a list of active documents.
        Loop through that list. For each document, if there is a relationship in document_user, continue.
        If there is no relationship in document_user, return that document.
        */
        $activeDocuments = Document::active(); // fetches a list of all documents with active = 1
        foreach ($activeDocuments as $activeDocument) {
            $belongsTo = $activeDocument->users; // returns a collection of users the doc belongs to
            if (!($belongsTo->contains('id', $this->id))) { // checks if the collection of users contains an id matching the user's id
                return $activeDocument;
            }
        }
    }

03 May
1 year ago

TylerW left a reply on How Can I Add The Ability For A User To Move Backwards In The Flow With Their Browser?

@lostdreamer_nl That seems like the best of both worlds. Didn't even consider this possibility. Thanks for the excellent idea.

02 May
1 year ago

TylerW started a new conversation How Can I Add The Ability For A User To Move Backwards In The Flow With Their Browser?

I decided to setup my multi-step registration flow in a peculiar way where the whole process only uses a single request URI that points to a controller that handles all requests. It returns a certain view based on the user's step in the process.

Basically, all get requests go through:

Route::get('register/provider', '[email protected]')->middleware('provider.registration');

The middleware simply checks to see if they are actually in the registration process. The ~findView~ method in the RegistrationController simply fetches the name of the view by comparing ~Auth::user()->registration_step~ with the index of the ~$steps~ array.

    public function findView()
    {
        /*
        Determine the registration page that the user should be on.
        Then, return the view corresponding to that page.
        */
        $user = \Auth::user();
        $step = $user->registration_step;

        if (!isset($this->steps[$step])) {
            $user->registration_step = null;
            $user->save();
            return redirect('/dashboard');
        }
        $view = $this->steps[$step];
        return view($view, compact('view'));
    }

Everything works fantastic. The only problem is, of course, if the user tries to go backwards in the browser, the page is loading in the view dynamically based on a value stored in the database so nothing actually changes.

I wouldn't of built it this way if I knew the user was supposed to be able to move backwards, but now that we are here, is there some way to adequately deal with this? Or do I simply need to expand this controller to return redirects to routes for each page in the registration flow and add validation to the method for each controller method returning said views?

28 Apr
1 year ago

TylerW left a reply on Cannot Display Errors For A Specific Field Laravel 5.6

Nevermind, I sorted it out. The issue is that I copied the code over from the register.blade.php page from the default php artisan make:auth scaffolding, and the span that is created to display the error has display: none set on it for some reason. So the error was outputting, just not displaying in the browser.

TylerW started a new conversation Cannot Display Errors For A Specific Field Laravel 5.6

I setup validation for the name field in my form so that the field is required, but I cannot seem to fetch the specific error from that field.

I used {{ print_r($errors->all()) }} at the top of my view, and it does show Array ( [0] => The name field is required. ).

But when I try and use:

@if ($errors->has('name'))
          <span class="invalid-feedback">
                 <strong>{{ $errors->first('name') }}</strong>
           </span>
@endif 

I get nothing. See any glaring issues here? If not, I'll go grab my full code.

27 Apr
1 year ago

TylerW left a reply on "Laravel Way" To Accomplish This Specific Flow?

@Snapey I like this idea because it groups all of the logic, but I'm not sure I understand how exactly that would work. For example, I post the form request to this endpoint. How would I pass that form request data to the relevant method? Simply referencing the method like LocationsController::store($request); and setting up my store method in my LocationsController to store the data and redirect to the next page?

As far as the middleware part, now that you mention it that sounds much more appropriate. Thanks for the help.

TylerW started a new conversation "Laravel Way" To Accomplish This Specific Flow?

I'm building a new application using the standard make:auth scaffolding. My flow looks like this:

  1. User signs up using email, password, accomplished with standard Register controller.
  2. User then sees multiple form pages to enter additional values to the user record. Values are saved upon submitting each form. The forms redirect in order until the user is finished.
  3. The user should not be able to access any pages on the site until they are fully registered other than the page they are supposed to be at in the registration flow.

I'm imagining that the first part is accomplished through middleware. Right now I'm using ->middleware('auth') on my routes to restrict the additional sign up pages to only users who have registered with an email and password. I can then create a second middleware that only applies to accounts that have completed the registration process, and restrict all other pages on the site to that middleware.

As far as the registration process, obviously I can simply redirect the user to the next page in the registration flow until they get to the end, at which point I can qualify their account as complete. But in order to prevent the user from jumping ahead in steps by simply entering the URL for a future form in their browser, I would obviously need to save their current step and then check to see if the view they are accessing matches. As far as saving the current step, many people recommend a session variable, but this doesn't seem to make sense to me in my situation because I'm storing the data after each page, meaning I don't want them to restart the process if I close the browser. So I'm imagining simply adding a field to the user's record called registration_step that is set to 1 by default and grows by 1, until they have submitted the last form and it is set to 0. The middleware for a registered user I mentioned above would simply be based around this value. Wondering if there is a better way to do this.

Also, where would you recommend I perform the above logic? I'm imagining just checking inside of the controller method for each view to see if the user's registration_step value matches the designated value for that page, and then perhaps also creating a method that returns the URL to redirect a user to based off of this value in the event that someone manages to get ahead of the flow by manually entering a URL.

TylerW left a reply on Please Critique My Code For Updating A User

@Snapey and @Nash thanks for the help. I think I understand now. So if I am using the auth middleware, then there is really no reason to perform findOrFail, but rather to simply us $user = Auth::user(). I think my only concern was that someone could, for example, get to this page, and then logout in another tab. But since I am using the middleware on each route, that shouldn't be an important consideration.

26 Apr
1 year ago

TylerW started a new conversation Please Critique My Code For Updating A User

I used php artisan make:authto setup my basic authentication. I want to have a multi-step registration process, so I added extra columns to the ùsers` table with->nullable()`.

First, I'm not sure if these next steps would technically be considered creations or edits. Yes, the user account is already created, but the user has never input the information I'm asking for at this stage - it's a prolonged registration process. Not sure exactly how this fits into the context of RESTful controllers - I'm new to this, but I want to do it right.

Second, I have built the basics in a way that work, but I cannot imagine I'm doing it the "laravel" way. First, I'm not sure if I should be using a post request or if this should be a put/patch request (not even sure the difference).

Here is the second page the user sees after creating their login, where they add contact info:

My form is located here: Route::get('/register/contact', '[email protected]')->middleware('auth');

That form is posting to: Route::post('/register/contact', '[email protected]')->middleware('auth');

` public function storeContact(Request $request) { $user = \App\User::findOrFail(\Auth::user()->id);

    $user->name = request('name');
    
    $user->save();


}

`

There is obviously one glaring issue here, which is how to deal with findOrFail. I could obviously just use find, but that doesn't address the fact that I need to validate if the user is actually authorized. Should I be simply throwing those lines inside of a try/catch?

Other than that, please let me know how I could be doing the above better.

TylerW left a reply on Do You Use The Default Mac Keybindings?

@stefanbauer I could see that. So out of curiosity, do you press CMD+C and CMD+V with only your left hand? If so, which fingers do you use? Or do you use the CMD on the right side when you do it. CMD on the right side makes it so that I need to take my hand off of the mouse and CMD on the left seems to only be possible by using my thumb to hit CMD and my index finger to hit C or V. Feels like the flexibility olympics.

TylerW left a reply on Proper Way To Retrieve Avatar Images?

@Cronix Sorry for the late reply, but this appears to be exactly the answer I was looking for. I'll report back if I run into any issues, but for now I will mark you as correct answer.

TylerW started a new conversation Do You Use The Default Mac Keybindings?

I recently purchased a MacBook Pro after using linux for several years with a standard tenkeyless keyboard. So far I love it, with one caveat.

Do the majority of the developers using a mac stick to the standard keybindings? I find it incredibly unnatural to press cmd+c and cmd+v for copy and paste, for example. How am I even supposed to do it? With my thumb?

It seems like the keys that get used the most often are in the most inconvenient location. Is this just something I get used to? Also, if that is the case, can someone explain to me the "ergonomic way" to actually press these key bindings? For example, advanced new file is "cmd+option+n."

Thanks.

23 Apr
1 year ago

TylerW left a reply on Proper Way To Retrieve Avatar Images?

Hey @Cronix , thanks again for your help.

I did read about that solution, but it says it is not possible to use on most shared hosting platforms. This is a great concern for me because most likely the website I am working on will be running on shared hosting.

Why is it the case that this will not work on shared hosting? I mean, a folder is a folder and if the folder is located on my server it seems like it should be able to access it. And in the case that it cannot be used on shared hosting, what alternative would you recommend? Simply sorting the file in the public folder?

TylerW started a new conversation Proper Way To Retrieve Avatar Images?

I know a lot of threads have been made about this in the past, but after much searching I cannot find one that is recent and adequately explains how to retrieve images you have saved to storage.

I am saying avatar images to to the avatars folder, which means they are being stored in storage/app/avatars. I am then adding the path returned by the store method to a column in the user database. This value looks like avatars/j4yZcfzSSJnRONYKaiTUZTrQp5UaDQfSSnrZ5i8G.jpeg.

Simply put, how do I access the URL to this image and echo it out on the page?

16 Apr
1 year ago

TylerW left a reply on Going To / Route Causes Site To Redirect To /defaultsite With A 404 Error.

@jlrdw Yeah, that's weird. I went ahead and selected your answer as correct. I really appreciate your taking the time to help me with this issue and also help me get situated here on the forums. Thanks again.

TylerW left a reply on Going To / Route Causes Site To Redirect To /defaultsite With A 404 Error.

@jlrdw Wow, it does appear to be a caching issue. I did hard refresh the page several times, but I never thought to clear my cache. Opening up an incognito seems to have confirmed that this is the issue because I can access adminpro.com there. I'll go clear my cache and it looks like the issue is resolved. Thanks for the help guys - any idea why this would of happened for future reference?

TylerW left a reply on Going To / Route Causes Site To Redirect To /defaultsite With A 404 Error.

@jlrdw Yes, it's only the / route that doesn't work. That same route works if I change the URI to /test, but for some reason that specific URI is redirecting to /defaultsite with a 404 error on the page. Not sure what that /defaultsite thing even is, is that something in Laravel?

TylerW left a reply on Going To / Route Causes Site To Redirect To /defaultsite With A 404 Error.

@jlrdw I did not have those lines before, but I can confirm I do now and after restarting apache the issue persists.

<Directory />
    # AllowOverride none
    AllowOverride FileInfo
    # Require all denied
    Require all granted
</Directory>

As far as the events test, I'm not sure how to do this. I'm new to Laravel just following along with the 5.4 from scratch series.

TylerW left a reply on Going To / Route Causes Site To Redirect To /defaultsite With A 404 Error.

jlrdw, could you point me in the direction of the directory that file is located in. Can't seem to find it.