roerjo

Software Engineer at Friendemic

Member Since 3 Years Ago

Asheville, NC

Experience Points
54,970
Total
Experience

30 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
511
Lessons
Completed
Best Reply Awards
4
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 11
54,970 XP
Sep
11
1 month ago
Activity icon

Commented on Prime Factors

It was just for 3

Aug
25
1 month ago
Activity icon

Commented on Refactoring To Controller Classes

A good code editor would have probably highlighted that as a possible error. Look into getting some PHP plugins for whatever code editor you are using.

Activity icon

Commented on Composer Autoloading

Ignoring the /vendor directory is a very good practice.

Also, in this project, I believe he setup the config.php to hold the hard-coded username and password for the database connection. You would also want to ignore this file in that case. If you didn't, then your username and password would be available for anyone to view at the location this repository is stored, e.g. GitHub.

Activity icon

Commented on Dynamic Inserts With PDO

join() is an alias of implode(), so yes you can use either. One argument for using implode over join is that the opposite function, explode() just sounds more paired to implode than `join'. But that is just my personal opinion.

https://www.php.net/manual/en/function.join.php

Activity icon

Commented on Forms, Request Types, And Routing

I believe it is good practice to declare class properties and give them default properties when practical. This allows the next developer to quickly scan the class and see what the properties and methods of that class are. If you omitted the $routes declaration, it is not obvious that there is an available routes property on the class unless you dig deeper into the methods and find out that get() and post() are setting that property.

Also, by omitting the declaration, you have lost the ability to restrict the visibility of the routes property. When you build it the way you did, the property is given a default visibility of 'public' instead of 'protected'.

Activity icon

Commented on Make A Router

I thought he did an amazing job presenting a complicated topic that has lots of interconnected pieces. It broke it down into it's parts to make it more digestible and this is similar to how a framework would implement a router. If you had trouble following along, then just watch it again and again until you grasp it.

Activity icon

Commented on Intro To PDO

After re-reading your question, I believe what you are looking for what Laravel calls Accessors/Mutators. You would need to use the magic method __set() and then within that method call a function to manipulate that value. Something like:

class User
{
    public function getName()
    {
        return ucwords($this->name);
    }

    public function setName($value)
    {
        // Do whatever it is you want to do to the value
        $this->name = $value;
    }

    public function __set($key, $value)
    {
        if ($key === 'name') {
            $this->setName($value);
        }
    }
}

This is just off the top of my head and would probably require some manipulation to work. Read the whole post of the link that I referenced in my previous comment to get a better handle on how PDO is setting up the class.

Activity icon

Commented on Intro To PDO

https://phpdelusions.net/pdo/objects#parameters

You can pass additional arguments to the fetchAll method to retrieve things in different ways and pass arguments to the constructor.

Aug
22
1 month ago
Activity icon

Commented on Feature: Forum Reputation Refactoring

What are the benefits of declaring the reputation values as constants instead of using a config file?

Jul
08
3 months ago
Activity icon

Replied to Login With Passport

@jorgealberto check out this thread: https://laracasts.com/discuss/channels/lumen/method-attempt-does-not-exist-or-auth-guard-driver-api-is-not-defined

Looks like attempt is not part of the 'api' guard and you should try using 'check` instead.

Activity icon

Replied to Login With Passport

Maybe try running php artisan config:clear . You may have cached you config prior to changing the auth.php file and it is reading that cached version instead.

Activity icon

Replied to Failed Asserting That Exception Of Type "\Exception" Is Thrown.

<?php

namespace Tests\Unit;

use Tests\TestCase;

class ExceptionTest extends TestCase
{
    /** @test */
    function test_exception()
    {
        $this->expectException(\Exception::class);

        throw new \Exception('blah');
    }
}

This test passes for me so there must be something else you haven't shown us.

Activity icon

Started a new conversation Soft Delete On Specific Date

Anybody know of a way to have a model soft deleted on a passed in date rather than the current date/time? I want to call a soft delete which will trigger the deleted model event (which I have setup to cascade that soft delete to certain related models).

I suppose I could just use the QueryBuilder and call DB::table('blah')->where('id', $id)->update(['deleted_at' => {date_string}]);, but then I'll need to cascade that soft delete manually as well (and I also want that specific date to cascade).

It would be nice if I could just call $model->delete({date_string}); but it doesn't look like the delete() method accepts any params according to API docs.

May
03
5 months ago
Activity icon

Replied to Laravel 5.9 Wish List

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

Activity icon

Replied to Laravel 5.9 Wish List

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

Mar
11
7 months ago
Activity icon

Replied to Extend Vendor Model To Include Additional Field

@emDoes does this vendor package create a database table for you or is it using an existing one? I would check their docs, because I am guessing 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.

Mar
07
7 months ago
Activity icon

Replied to Conditionally Bind Implementation To Interfaces

@meddle 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.

EDIT:

You can use the app() helper method too to get an instance of the service container.

Activity icon

Replied to 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.

Activity icon

Replied to Keep Current User Logged In When Creating A New User In Admin

@mike_sa 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, but in my RegistersUsers Trait (v5.7.26), 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:

    /**
     * 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());
    }
Activity icon

Replied to 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 your wrong spelling of po_items in my first example. Changing that to plural should work:

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

Replied to 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>
Mar
04
7 months ago
Activity icon

Replied to 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

Feb
22
7 months ago
Activity icon

Replied to 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.

Activity icon

Replied to 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

Activity icon

Replied to 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 :)

Activity icon

Replied to 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');?

Activity icon

Replied to Controller <> Model Conflict?

@learner1982 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.

Activity icon

Replied to How To Assign Field From Another Model?

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

Activity icon

Replied to How To Assign Field From Another Model?

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

Activity icon

Replied to 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'; }"

Feb
21
7 months ago
Activity icon

Replied to MethodNotAllowedHttpException In RouteCollection.php

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

Activity icon

Replied to MethodNotAllowedHttpException In RouteCollection.php

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

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

Replied to 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');
Activity icon

Replied to 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
""
Activity icon

Replied to 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};
    }
    ...
}
Activity icon

Replied to Route Conflict With / And A Name-prefix /

@Notdavis 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 :)

Activity icon

Replied to 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?

Activity icon

Replied to 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'); });
});
Activity icon

Replied to 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 CostItem's relationship with POItem.

Activity icon

Replied to MethodNotAllowedHttpException In RouteCollection.php

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

Activity icon

Replied to MethodNotAllowedHttpException In RouteCollection.php

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

Activity icon

Replied to MethodNotAllowedHttpException In RouteCollection.php

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

Activity icon

Replied to Controller <> Model Conflict?

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

namespace App\Http\Controllers;

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

Replied to Display A Collection

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

Activity icon

Replied to 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()
);
Activity icon

Replied to 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. The docs link that I posted probably does a better job of explaining it.