roerjo

Member Since 3 Years Ago

Asheville, NC

Software Engineer at Friendemic

Experience Points 53,800
Experience Level 11

1,200 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 502
Lessons
Completed
Best Reply Awards 4
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.

03 May
1 month ago

roerjo left a reply on Laravel 5.9 Wish List

Some kind of out-of-the-box support for documentation, both API and non-API, would be cool too

roerjo left a reply on Laravel 5.9 Wish List

I create my own factories for incoming 3rd party API requests/webhooks. It would be nice if Laravel had support for non-model factories out-of-box.

11 Mar
3 months ago

roerjo left a reply on Extend Vendor Model To Include Additional Field

@emDoes this vendor package create a database table for you or is it using an existing one? I would check their docs, because I am guess that they are creating the table within their package and you can't just add a new field to the model fillable array and expect it to populate in the db table. Their package might allow you to 'publish' the migrations so you that you can access them within you App namespace.

It looks like this might be the package you are trying to work with: https://github.com/Riari/laravel-forum

I see that they have the option to publish their files via: php artisan vendor:publish

After updating the migration, you will need to run php artisan migrate again so that the database pulls in your changes.

07 Mar
3 months ago

roerjo left a reply on Conditionally Bind Implementation To Interfaces

Like this ?

if (some condition) {
    $this->app->bind(
        Interface::class,
        Implementation::class
    );
} elseif (some condition) {
    $this->app->bind(
        Interface::class,
        DifferentImplementation::class
    );
}

IDK know if that will work, but it sounds like what you are going for.

roerjo left a reply on Default Scheduler Timezone

Yes the one config/app.php will be the timezone for the scheduler.

Also, be aware that your database can have it's own default timezone (usually UTC) and your server may also have a default timezone.

roerjo left a reply on Keep Current User Logged In When Creating A New User In Admin

@You don't have to create a whole new trait. You can just override the method of the trait in the class that is implementing that trait. In this case, you could just set your own register() method in the RegisterController.

I'm not sure which Laravel version @ouhare is using my in my RegistersUsers Trait, there is a register() method that is logging in the newly created user:

    /**
     * Handle a registration request for the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user); // <----SEE HERE

        return $this->registered($request, $user)
                        ?: redirect($this->redirectPath());
    }```

In your RegisterController, you can just create a `register()` method that will override this one like so:

```php
    /**
     * Handle a registration request for the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        return $this->registered($request, $user)
                        ?: redirect($this->redirectPath());
    }```

roerjo left a reply on Trying To Get Property 'cost_item' Of Non-object

@zaster it probably didn't work because what you had it your original post was spelled wrong. I used the wrong spelling po_items (po_item) in my example. Changing that to plural should work:

<td>{{$po->po_items->first()->cost_item->vendor_company->id}}</td>
06 Mar
3 months ago

roerjo left a reply on Trying To Get Property 'cost_item' Of Non-object

If it doesn't matter which po_item is used, then you can just grab the first one returned from the the po hasMany po_item relationship:

<td>{{$po->po_item->first()->cost_item->vendor_company->id}}</td>
04 Mar
3 months ago

roerjo left a reply on Model Events Not Trigerring When Using Factories

I ran into a similar issue just now while using the Event::fake() mock in my tests. It dawned on me that I was faking my model events which I didn't want faked. You can pass an array to the fake() of the events you want faked to avoid faking the events you don't want faked.

https://laravel.com/docs/5.7/mocking#event-fake

22 Feb
3 months ago

roerjo left a reply on Is There A Way I Could Provide Paramatere For All Controllers Used Inside Route Group?

Can you give an example? I am unclear of what you mean.

roerjo left a reply on Three Way Relationship Or Relationship With A Relationship?

@JOHNBEALES - If you want to be less 'wasteful', Laravel has Pivot Models that I believe are more lightweight than the Eloquent models. Search for Defining Custom Intermediate Table Models on this page in the docs:

https://laravel.com/docs/5.7/eloquent-relationships

roerjo left a reply on Naming Routes

If you are attempting to follow REST best practices, then you wouldn't include the /delete trailer on the URI. Here are some guidelines for URI naming when following REST: https://restfulapi.net/resource-naming/

Of course, these are not 'must follow' rules. They are considered best practices, but if need to deviate in your project because you think it is best for what you are trying to accomplish, don't be afraid to rebel a little :)

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

@zaster to ensure that it is not the redirect back() causing the issue, could you try instead redirecting to a specified route, like return redirect()->route('employee.poitem.pendinglist');?

roerjo left a reply on Controller <> Model Conflict?

For traits, you should be using $this, not _Model, so there is no benefit there. For controller reuse, Laravel provides the php artisan make: controller command and you can add flags that will populate the model for you...check out the resource option.

roerjo left a reply on How To Assign Field From Another Model?

@fikri1510 Are you setting $profile->ssn to the SSN after you new Profile?

roerjo left a reply on How To Assign Field From Another Model?

If you have already set $profile->ssn then what you have should work

roerjo left a reply on Laravel Default Login Redirection Not Working

@janakadombawela From https://laravel.com/docs/5.7/authentication#included-authenticating you can setup some custom redirection logic by setting the redirectTo() in the LoginController

Path Customization When a user is successfully authenticated, they will be redirected to the /home URI. You can customize the post-authentication redirect location by defining a redirectTo property on the LoginController, RegisterController, and ResetPasswordController:

protected $redirectTo = '/'; If the redirect path needs custom generation logic you may define a redirectTo method instead of a redirectTo property:

protected function redirectTo() { return '/path'; }

21 Feb
3 months ago

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

@I'm bored haha so no problem, but I am about to go to bed.

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

Is this exception be thrown after the item is deleted? Is it being thrown on the redirect back? Here:

        return back()->with('success','Information has been  deleted');

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

@zaster As a debug, could try changing the route to:

Route::post('/poitem/{poitem}', 'Employee\[email protected]')->name('employee.poitem.destroy');

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

Are the other delete routes working? That stack trace isn't very descriptive...is the Arguments part at the bottom saying that an empty string was passed as the method?

Arguments
""

roerjo left a reply on Use Trait To Override AttributesToArray On Model

http://php.net/manual/en/language.oop5.traits.php

There is some interesting stuff in the 'Conflict Resolution' section and I wonder if what they talk about there might be useful to you. Something along the lines of:

class Sale extends SaleBase
{
    use EncryptableTrait {
        EncryptableTrait::attributesToArray insteadof {class that originally defines it here};
    }
    ...
}

roerjo left a reply on Route Conflict With / And A Name-prefix /

Could maybe set the main domain as .env variable for each environment and concatenate that.

.env

DOMAIN=myapp.local

routes/web.php

Route::domain('cars.'.env('DOMAIN'))->...

Might not work, but throwing it out there :)

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

@ZASTER - Hmm everything looks good there...can you post the stack trace? Are there any other routes that have non-get/post verbs such? If so, are those working?

roerjo left a reply on Route Conflict With / And A Name-prefix /

Route::domain('app.myapp.com')->group(function () {
    Route::get('/', function () { return view('welcome'); });
});

Route::domain('cars.myapp.com')->namespace('Users')->middleware('auth')->group(function () {
    Route::get('/', function () { return view('user.cars.welcome'); });
});

roerjo left a reply on Joins And Where Clause?

$cost_items = CostItem::with('po_item')->where('vendor_company_id', $vendor_company_id)                        
                                ->get();

the with method will retrieve the relationship, so replace po_item with whatever method name you have defined for the CostItem's relationship with POItem.

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

@ZASTER - Can you post the rendered HTML so we can confirm that the URL is correct?

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

If you inspect the HTML in the browser, is the form action URL generated properly?

roerjo left a reply on MethodNotAllowedHttpException In RouteCollection.php

The hidden input field looks correct...maybe try {{ method_field('DELETE') }}?

roerjo left a reply on Controller <> Model Conflict?

What are you going to do when you need to import more than a one model?


namespace blahblah

use App\Product as _Model;
use App\User as ?;

roerjo left a reply on Display A Collection

Can you show how you generated the collection that you posted?

roerjo left a reply on Laravel Eloquent Relationship

@softwebglobe if you want to see the SQL query of that code, change ->get() to ->toSql() and then dump that result e.g.

dd(
    Blog::whereHas('replies', function ($query) use ($user) {
        $query->where('user_id', $user->id);
    })->toSql()
);

roerjo left a reply on Laravel Eloquent Relationship

The closure query is being performed on the replies table. So I guess if I was to translate this PHP code into English I would say:

On the `replies` table , find me all the replies with a `user_id` of {$user->id}. Now that that I have a list all the replies a user has made, join this list to the `blogs` table using the `blog_id` on the replies table. Now that I have a list of all blogs with the same ids as 'blog_id`, return this list to the user.

Not sure if that is what you meant by explain it haha

roerjo left a reply on Laravel Eloquent Relationship

@softwebglobe Based on what you've posted so far the following should work:

Blog::whereHas('replies', function ($query) use ($user) {
    $query->where('user_id', $user->id);
})->get();

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

@connor11528 lol awesome...sounds like it wasn't anything I thought of...nice find!

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

@connor11528 That cookie XSRF-TOKEN isn't the issue I think. I checked a personal project and I have the same cookie but it isn't creating any conflicts. Have you tried reverting back file based sessions to see if those worked?

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

@Another debug tip: ssh into your prod server and nav to you codebase..in forge I believe it puts it in ~/{repo}/current? From there, run php artisan tinker and then run getenv() to dump all the server environment variables...you can then confirm that php has pulled in the correct setup.

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

I believe you said you already tried changing the APP_KEY, but since I don't know if you used the command to do that, maybe trying php artisan generate:key? I believe that will invalidate the current sessions.

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

Yeah the token that generated in the hidden input needs to match the token stored in the session.

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

@connor11528 Did you by chance change anything from the default sessions table configuration?

Default:

    $table->string('id')->unique();
    $table->unsignedInteger('user_id')->nullable();
    $table->string('ip_address', 45)->nullable();
    $table->text('user_agent')->nullable();
    $table->text('payload');
    $table->integer('last_activity');
});

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

Another debug option would be to try switching back to file sessions if those were working before. Maybe it is an issue with the database driver.

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

On your production form I am seeing a token generated but I am also seeing cookie token being generated:

set-cookie: XSRF-TOKEN=eyJpdiI6IllnUTV6QnZpRjZQaGN5dk9ETGFnOVE9PSIsInZhbHVlIjoic2xVZ0MyYTlzODFHamNmZ1A3NGlueVFWWk4xWHpnOHNrZ2VqWVlDMVVYTmtLaWdzZ1RsYnVENFBhSms3QXRVOSIsIm1hYyI6ImIzNTFkZjk2YjViMmViOGVlYTJhNmFhMGFmNzQ2NzRhYTBlOGQ1OWQ5ODNlYWZmYjMxZjZkYTI0MzdlNDY5OWUifQ%3D%3D; expires=Thu, 21-Feb-2019 23:43:24 GMT; Max-Age=7200; path=/

I'm getting into the weeds on with my knowledge, but are you somehow setting both a cookie token and db token?

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

@tykus in his original post it looks like he had php artisan migrate --force as part of his deployment script

roerjo left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

along with @tykus suggestion, if they did migrate, are they populating since your last deployment?