bionary

bionary

Member Since 2 Years Ago

Experience Points
10,630
Total
Experience

4,370 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
94
Lessons
Completed
Best Reply Awards
0
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 3
10,630 XP
Oct
31
1 week ago
Activity icon

Awarded Best Reply on Schedule Runs Manually But Not With Cron As Expected

So I spent yet a few hours sleuthing this out. I was sprinkling DB::table('test')->insert(['key'=>'some location']); statements every step of the way.

I also took a look at the error logs. (Hand over face moment) yes the logs. I didn't think to check them because I was so darn fixated on telescope's exception panel, which showed nada.

So I was able to resolve the problem.

I have a bunch of abstract classes that inherit from one another. Since this is a complicated project I have been type-hinting all inputs so that a few years from now, code maintenance is easier.

Well it turns out that a few inherited methods where type hinted in the abstract parent class BUT where not properly type hinted in the child class.

So in essence I had things like this in the Parent Class:

/* Abstract child methods */
abstract protected function encodeQuery(string $rawQuery);
abstract protected function cleanLinksHook(array $links);

But in the various child classes I had a few spots where I was sloppy and was creating the method without proper type-hinting... like this:

protected function cleanLinksHook($links) {
    ...
}

or this

protected function cleanLinksHook(Array $links) {
    ...
    //notice the capital A
}

I can see why this didn't work BUT the weirdest thing, is the code ALWAYS worked when running php artisan schedule:run once off, manually in the command line BUT never when run via cron/scheduler. I tested it dozens of times and there is not logical reason I can think of why this was the case BUT it was. very very very strange.

Activity icon

Replied to Schedule Runs Manually But Not With Cron As Expected

So I spent yet a few hours sleuthing this out. I was sprinkling DB::table('test')->insert(['key'=>'some location']); statements every step of the way.

I also took a look at the error logs. (Hand over face moment) yes the logs. I didn't think to check them because I was so darn fixated on telescope's exception panel, which showed nada.

So I was able to resolve the problem.

I have a bunch of abstract classes that inherit from one another. Since this is a complicated project I have been type-hinting all inputs so that a few years from now, code maintenance is easier.

Well it turns out that a few inherited methods where type hinted in the abstract parent class BUT where not properly type hinted in the child class.

So in essence I had things like this in the Parent Class:

/* Abstract child methods */
abstract protected function encodeQuery(string $rawQuery);
abstract protected function cleanLinksHook(array $links);

But in the various child classes I had a few spots where I was sloppy and was creating the method without proper type-hinting... like this:

protected function cleanLinksHook($links) {
    ...
}

or this

protected function cleanLinksHook(Array $links) {
    ...
    //notice the capital A
}

I can see why this didn't work BUT the weirdest thing, is the code ALWAYS worked when running php artisan schedule:run once off, manually in the command line BUT never when run via cron/scheduler. I tested it dozens of times and there is not logical reason I can think of why this was the case BUT it was. very very very strange.

Activity icon

Replied to Schedule Runs Manually But Not With Cron As Expected

Thank you for your reply. The cron is firing every minute. I can confirm this with the following block which works as expected:

   $schedule->call(function () {
        DB::table('test')->insert(['key'=>date('Y-m-d H:i:s') ]);
    })->name("scrape test")->everyMinute();

It really is strange.

Oct
30
1 week ago
Activity icon

Started a new Conversation Schedule Runs Manually But Not With Cron As Expected

I have a bizarre problem that I would like a few brains to help me figure out the solution. (I'm sure I'm just overlooking something trivial like usual)

I have setup laravel cron scheduling in the past with success on previous projects. This time around I have a complex web scraping routine that works fine when run manually but does not run via automatic scheduling.

It's so weird.

I set up the cron job and put in simple test:

        $schedule->call(function () {
            DB::table('test')->insert(['key'=>date('Y-m-d H:i:s') ]);
        })->name("scrape test")->everyMinute();

The previous code works fine. I can see the database rows stacking up each minute...great

When I swap out the test for the real code like this:

        $schedule->call(function () {
            $tasksController = new TasksController;
            $tasksController->scrape('something');
        })->name("scrape test")->everyMinute();

It doesn't work :(

Now here is the baffling part...

If I run the scheduler via the command line it works fine!

php artisan schedule:run

My code works flawlessly when run via command line but not when called via the scheduler.

???

I'm out of ideas, this makes zero sense to me.

Have any ideas?

Thanks

ps. I can concur all of this via telescope as well. Telescope records each schedule when it's working and does not register the schedule even when it's not working

Oct
22
3 weeks ago
Activity icon

Commented on Eloquent Subquery Additions

I was wondering the same thing.

Oct
05
1 month ago
Activity icon

Replied to Validating Unique Via Pivot Table

Thanks but the problem is I don't know the role_id ahead of time.

Why? because it's coming from a text input field and not a pre-supplied drop down!

I believe your code would work if roles where established in the DB:roles table and had an roles.id. BUT I am trying to validate the input text provided by a user. What I'm trying to avoid is having roles entered more than once in the roles table.

So after validation if the role exists i simply create a new row in the role_user table. If the role doesn't exist I create it in the role table and then create a new row in the role_user table.

I need to make sure that the user_id , role_id is unique to the role_user table.

This is very trivial to do in regular Sql and even the QueryBuilder, but I'm not sure how to use the query builder on it's own without piggy backing off of the few database-based validation methods. According to the docs you can use exists() and unique() only.

Sep
30
1 month ago
Activity icon

Started a new Conversation Validating Unique Via Pivot Table

I have a many to many relationship between tables users & roles :

users: id, name 
roles: id, role 

I use a pivot table to link them

role_user: id user_id, role_id 

How can I validate incoming data to ensure that the same role is not applied twice to a user? I'm using a FormRequest class to validate

public function rules(){
    return [
        'role' =>[
            'required',
            'unique:???' ],
    ];
}

I need to report validation error if the role_user already exists

Activity icon

Replied to Get Many For Parent / Child Tables

How right you are! My code is so elegant now I'd like to take it out to dinner! I had a difficult time understanding the docs but you helped me @snapey so thanks.

I actually traversed three joined tabled (grandparent - parent -child) whereas the parent - child relationship had an intermediate (pivot table?) table connecting the two and it simply works like magic. I'm still amazed thinking back to all those humongous complicated table joins I used to write.

Sep
29
1 month ago
Activity icon

Replied to Get Many For Parent / Child Tables

That worked perfectly thank you! Here's my blade markup: (the only think I don't like is if the $domain->groups is empty I get an empty pair of <ul></ul> I could probably do an if/else for each tag.

                    <ul>
                        @foreach($domains as $domain)
                        <li>{{ $domain->domain }}
                            <ul>
                                @foreach($domain->groups as $group)
                                    <li>{{ $group->group }}</li>
                                @endforeach
                            </ul>
                        </li>
                        @endforeach
                    </ul>

Hypothetically @snapey could I chain that query even further, say into a "sub_group" like:

$domains= Domain::with('groups')->with(sub_groups)->get();
Activity icon

Started a new Conversation Get Many For Parent / Child Tables

I have some db tables that reference each other like this:

table name: domains

columns: id,domain

And

table name: groups

columns: id,domain_id, group

I would like to grab all rows from both tables and display them as a hierarchy. So Domain is the Parent Table and Groups is the Child table which references "domain_id" Like this:

  • google.com
    • search
    • advertising
    • android
  • apple.com
    • macos
    • ios
    • audio

I know I can get both tables separately and cobble it all together but is there an elegant way to do this in Laravel?

I looked into ->hasMany() but it seems to only work for a single query against the parent table like Domain::find(1)->groups; I was hoping this would work but it doesn't: Domain::all()->groups;

Sep
20
1 month ago
Activity icon

Replied to Pass Model By Reference?

nope, I thought I could too, but I get the same error

Activity icon

Started a new Conversation Paid Membership App Advice

I need to build a web app for paying members. I'm looking for some general advice on what packages / services I should use to do so. **If you have recommendations from direct experience with the required packages / services please leave me some feedback here. **Thank you.

The web app should be able to do/have this:

  • Video Library
  • Live Chat
  • Forum
  • Membership (paid)
  • Managed server/deployments

~ VIDEO LIBRARY

This should be easy. I think vimeo is a good option to keep the videos siloed inside the paid membership area.

~ LIVE CHAT

No, not the trendy chatbot / support chat stuff. I need our members to be able to form groups and meetup online to discuss things in real time. Text chat is a good start but video chat between members would be even better. I dont even know where to begin with this!

~ FORUM

Members should be able to post and upload images. I bet there is some kind of package that makes this trivial. Have any experience recommendations?

~ MEMBERSHIP

At its core this web app will be a paid membership platform. Users need to be on payment plans (monthy / yearly) to have access. Im sure we will need some kind of ACL to manage the roles too.

~ MANAGED SERVER/DEPLOYMENTS

Id like to ease the pain of server administration. I hate managing the server. For the past several years Ive hosted projects on a Digital Ocean Ubuntu server. Runs great until I have to make an upgrade, than everything breaks and I devote an entire weekend trying to fix everything. Constantly ssh-ing in and fixing things via command line is the absolute worst use of my time

I need to avoid this. Would using Forge make this easier?

**Im looking for some advice on these matters from folks who have experience with packages / services necessary. **Ive already googled lists of potential ideas/tech to accomplish this and dont need yet another list.

Sep
14
1 month ago
Activity icon

Replied to Making Sense Of Password Reset

Thank you @jlrdw and @snapey. This was helpful.

btw, the biggest problem was a little setting in Atom IDE (exclude VCS Ignored Paths) which was preventing my searches from traversing into the vendor directory.

I won't even pretend to understand every part but I can generally see what's happening.

I spent over an hour just trying to figure out these lines:

public function sendResetLinkEmail(Request $request)
{
    $this->validateEmail($request);

    // We will send the password reset link to this user. Once we have attempted
    // to send the link, we will examine the response then see the message we
    // need to show to the user. Finally, we'll send out a proper response.
    $response = $this->broker()->sendResetLink(
        $request->only('email')
    );

    return $response == Password::RESET_LINK_SENT
                ? $this->sendResetLinkResponse($request, $response)
                : $this->sendResetLinkFailedResponse($request, $response);
}

It's like a labyrinth of code. Each time I follow where it's going it leads me somewhere else. It's very tricky because it's super minimal but resides in so many places. It's well structured but damn it's hard to follow!

Activity icon

Replied to Making Sense Of Password Reset

I figured it was something like that but how come my search for "showLinkRequestForm" comes up empty? Doesn't this method (trait?) have to exist somewhere?

Activity icon

Started a new Conversation Making Sense Of Password Reset

I'm working with my laravel 5.7. I'm baffled by the login/auth/password logic. I'm trying to follow the route of the code and can't make any sense of it.

For instance:

running> php artisan route:list I can see this:

    password/reset | ... Auth\[email protected]

So I checkout the class: ForgotPasswordController and there is no method: showLinkRequestForm()

So I'm thinking that maybe this is a "behind the scenes" Laravel treat so I'm thinking it's inhereted from somewhere, so..

I head up to: Find>Find in Project (I'm using Atom IDE)

and search for "showLinkRequestForm"

... no results

What the heck is going on here?

The http://127.0.0.1:8000/password/reset page certainly does load, but I can't follow any of the logic.

Need some help here please.

Sep
11
2 months ago
Activity icon

Started a new Conversation Pass Model By Reference?

I'm getting an error:

Indirect modification of overloaded property App\Task::$errors has no effect

I'm pretty sure this is one of those "pass by value" instead of "by reference" issues.

I have a model: Task $task Which I'm passing to another class

The $task contains an attribute: $task->errors;

Which I continually add error messages to as an array. I run into trouble when inside a class and doing this:

public function getBrandsList(Task $task){ $task[] = 'Another error.'; }

I would have thought that the following would have rectified this but it doesn't:

public function getBrandsList(Task &$task){ ...

The following works but it sure looks and feels sloppy:

public function getBrandsList(Task $task){ $task->errors[] = array_merge($task->errors, ['Another error.']); }

Is there is cleaner way to do this? Is there a way to pass my Task $task model by reference?

Thanks