willvincent

willvincent

Member Since 5 Years Ago

Central Minnesota

Experience Points
344,325
Total
Experience

0 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
1612
Lessons
Completed
Best Reply Awards
338
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 50
344,325 XP
Jan
21
5 days ago
Activity icon

Commented on Send SMS Notifications In 5 Minutes

Ugh.. you want to build yet another site requesting permission to display notifications in/from the browser?

Don't be that guy :D

Activity icon

Replied to Laravel Show Data Condition Based

If all you care about is 2018, just use a where clause on the query to only fetch the relevant books.

Jan
20
6 days ago
Activity icon

Replied to Permanent Redirect

Honestly permanent redirects are best configured in the http server config, not handled at the php framework level.. there's no point in bootstrapping the application just to return a 301. Certainly there are occasional situations where it may be useful, but generally if it's permanent it should just be part of the http config.. a temporary 302 is a different situation entirely, and might very well make more sense to live in the app..

Activity icon

Awarded Best Reply on Right Method To Request A Queue API

This sounds like a strange scenario.. but I think the way to approach this is to have a cron task that runs every minute, every 5 minutes, whatever frequency.. and it should first check if queue items are being processed by looking at a flag set in the DB or similar. If no items are being processed, initiate your api call to fetch an item from the queue -- this is where you'll set that items are being processed.. After receiving an item and processing it, hit the api again.. repeat until you get your empty state, at which point you then toggle the processing flag off again. Next time the cron job runs it'll see processing is not occurring, flip the flag, check the api, and either process items or toggle the flag back off.

Activity icon

Replied to Right Method To Request A Queue API

This sounds like a strange scenario.. but I think the way to approach this is to have a cron task that runs every minute, every 5 minutes, whatever frequency.. and it should first check if queue items are being processed by looking at a flag set in the DB or similar. If no items are being processed, initiate your api call to fetch an item from the queue -- this is where you'll set that items are being processed.. After receiving an item and processing it, hit the api again.. repeat until you get your empty state, at which point you then toggle the processing flag off again. Next time the cron job runs it'll see processing is not occurring, flip the flag, check the api, and either process items or toggle the flag back off.

Jan
18
1 week ago
Activity icon

Replied to Laravel Strange 419 Behavior

But its happenings when user doesn't login long time.

There's your answer right there.. the session is expiring invalidating the csrf token.

Jan
17
1 week ago
Activity icon

Replied to Overriding Package Method

Not at all, you were binding to a class path value, captcha is bound to the string captcha

Activity icon

Awarded Best Reply on Overriding Package Method

hrmm.. actually I guess you don't need to override the service provider

But you do need to override the app->bind('captcha'... that's in there.

so instead of the app->bind you're doing, just use this:

$this->app->bind('captcha', function ($app) {
            return new App\Hrpp\Helpers\Captcha\CaptchaGenerator(
                $app['Illuminate\Filesystem\Filesystem'],
                $app['Illuminate\Contracts\Config\Repository'],
                $app['Intervention\Image\ImageManager'],
                $app['Illuminate\Session\Store'],
                $app['Illuminate\Hashing\BcryptHasher'],
                $app['Illuminate\Support\Str']
            );
        });
Activity icon

Replied to Overriding Package Method

hrmm.. actually I guess you don't need to override the service provider

But you do need to override the app->bind('captcha'... that's in there.

so instead of the app->bind you're doing, just use this:

$this->app->bind('captcha', function ($app) {
            return new App\Hrpp\Helpers\Captcha\CaptchaGenerator(
                $app['Illuminate\Filesystem\Filesystem'],
                $app['Illuminate\Contracts\Config\Repository'],
                $app['Intervention\Image\ImageManager'],
                $app['Illuminate\Session\Store'],
                $app['Illuminate\Hashing\BcryptHasher'],
                $app['Illuminate\Support\Str']
            );
        });
Activity icon

Replied to Overriding Package Method

So you've extended the captcha class.. now also extend the captcha service provider class, and override it's register method to return your captcha class not the default. then rebind the captcha service provider to use your extended service provider class

Activity icon

Replied to Overriding Package Method

No, create isn't a method on the service provider..

I don't know what exactly you're wanting to alter from the default behavior, but you have to ensure that the register method of the service provider returns an instance of your class that extends the base captcha class.. because the register method, as I mentioned above, is returning a new instance of the base captcha class directly -- ie: it's not resolving the captcha class from the service container -- ever.

Activity icon

Replied to Overriding Package Method

You'll need to override the service provider to instantiate an instance of your overridden class.

The captcha class itself is not bound to the service container, but rather it's provider is, the provider returns an instantiated object.. so your app->bind is effectively worthless here.

Also extend the service provider, and override its register method to instantiate an instance of your overridden captcha class.

Jan
15
1 week ago
Activity icon

Replied to How To Get Top Root Parent Category Of A Sub-category

At my job we have unlimited-depth hierarchies of organizations in our system. An organization can have children, those children can have children, etc.. to an infinite (theoretically) depth, and sitting at the top of it all is the organization that represents ourselves.

The way I keep track of these is that each organization has a parent_id relating it to it's parent, it also has an "ancestor_tree" field that is the collection of ancestors all the way back up to the top.

That might look something like this, for an organization that's 4 levels deep:

-1-4-17-30- it's parent_id is 30. Similarly, if you look at the ancestor tree field on the parent record, that is: -1-4-17-

This is fairly easily achieved by copying the ancestor tree from the parent record, and appending the parent's id to the end for any newly added item. It's a little more involved if something with children gets moved under a new parent, but that too isn't too terrible difficult..

With this pattern, you could simply look at the first id in that string of ancestors, that'll always represent your top level.

The other convenient thing here is I can also quickly find any descendants of any arbitrary item by searching where ancestor_tree LIKE %-5-%.. if 5 is the id I want to find descendants of.

Activity icon

Replied to Add Values On Two Arrays

$array_new = array_map(function () {
    return array_sum(func_get_args());
}, $array1, $array2);

Doesn't matter if lengths differ, or even if a string sneaks in there for some reason...

Tinker output to prove it:

>>> $a = [100,50,200,155,173];                                                                                                                                                        
>>> $b = [200,100,75,'banana'];                                                                                                                                                                
>>> $c = array_map(function() {                                                                                                                                                                return array_sum(func_get_args());                                                                                                                                                             }, $a, $b);

=> [
     300,
     150,
     275,
     155,
     173,
   ]
Jan
14
1 week ago
Activity icon

Replied to Fetching Nested Groups Along With Their Nested Groups.

and for this reasons he must implement something more smarter to handle unknow nested children

He must ?

I'm not going to assume I fully understand the use case, you shouldn't either.

If the nested data doesn't change often, simply caching the tree when it does change, and then always serving the cached tree is a sufficiently robust and performant approach.

If requirements are more complex, data changes frequently, etc.. yes another approach may be better. But just arbitrarily throwing packages into the codebase isn't the best way to develop software. It's much better to fully understand the use case, and then build/adopt existing code accordingly.

Since no information about use case was provided, it would be foolish to just assume you are correct and I am wrong.

Activity icon

Replied to What's Wrong With My Sql Query?

So now you have the join in the correct place, but as I indicated in my first comment, I'm fairly certain you can't reference rooms in your subquery without also joining it within the subquery.

Activity icon

Awarded Best Reply on Laravel Vue Asynchronous CRUD

Token and/or API Key in the request header would be the standard option.

Since you're only consuming this internally you might also want to check out Inertia which would remove the need to create the API routes, while still avoiding the page reload. It's really pretty slick.

Activity icon

Replied to Save Date Value In Database

Did you define that field in your model as a date? ie:

protected $dates = [
    'seen_at',
];

As described in the docs?

Activity icon

Replied to What's Wrong With My Sql Query?

Join clause invalid.

SELECT ___
FROM ____ 
JOIN ___ ON _____
WHERE ___
AND ___
Activity icon

Replied to What's Wrong With My Sql Query?

You probably need to join rooms in the subquery as well, I believe rooms.id is not actually available to the subquery as currently written

Also join should not be in the where clause. :)

Rework to this order:

SELECT ___ FROM ___ JOIN ____ WHERE ___

Activity icon

Replied to Fetching Nested Groups Along With Their Nested Groups.

This is actually not too terribly difficult. You can use a global scope to add a with('children') to every query of that model unless explicitly requested without children

(Untested, but) at it's most basic it should be simply adding this to the boot() method of your model that has children...

static::addGlobalScope('children', function (Builder $builder) {
    $builder->with('children');
});

And then to query without the children: MyModel::withoutGlobalScope('children')->get()

Probably wise to consider caching if you are going to be doing this though, as it would support an infinite (or whatever looping limits are in place I guess) depth, and could generate many queries.

Activity icon

Replied to Laravel Vue Asynchronous CRUD

Token and/or API Key in the request header would be the standard option.

Since you're only consuming this internally you might also want to check out Inertia which would remove the need to create the API routes, while still avoiding the page reload. It's really pretty slick.

Jan
08
2 weeks ago
Activity icon

Awarded Best Reply on Bootstrap Dynamic Form Rows And Columns In Blade

Previous answers here seem stuck on the how to display a grid thing, rather than the actual question of how to dynamically generate the appropriate markup.

You're going to have to group items by row, then loop through each row, in the order of the column order value, and then generate the appropriate column markup for each item.

I would recommend partials for probably both the row AND column items, potentially for each field type as well. But the key here is to get items into the correct order and into the correct data structure first.. before that data is handed off to blade to parse.

I would accomplish this by ensuring you're using orderBy clauses on your query to sort by row then column, and then use a transformer of some sort to iterate through each record shuffling the records into a multi-dimensional array representing rows with columns per row...

ie:

$rows = [];

foreach ($items as $item) {
  if (!$rows[$item->row - 1]) {
    array_push($rows, []);
  }

  array_push($rows[$item->row - 1], $item);
}

return $rows

Which in your case would end up with a data structure like this:

Array
(
    [0] => Array
        (
            [0] => stdClass Object
                (
                    [name] => name
                    [type] => text
                    [label] => Name
                    [row] => 1
                    [column] => 1
                    [size] => 6
                )

            [1] => stdClass Object
                (
                    [name] => model
                    [type] => text
                    [label] => Model
                    [row] => 1
                    [column] => 2
                    [size] => 6
                )
        )

    [1] => Array
        (
            [0] => stdClass Object
                (
                    [name] => date_of_purchase
                    [type] => date
                    [label] => Date of Purchase
                    [row] => 2
                    [column] => 1
                    [size] => 6
                )

        )

)

Then you can simply iterate through each row, and within each row, iterate each column, and populate your markup dynamically.

Dec
17
1 month ago
Activity icon

Replied to Check If Appointment Date Already Exists

@nakov your first solution was better. Based on the original post, the task is to determine if the new request overlaps an existing one, so checking whether the requested start date is same or greater than any existing start AND same or less than any existing end will find overlaps.

Otherwise it's just checking for identical starts, which is likely to lead to double bookings -- even if it satisfies current rules.

The issue with your previous example was the >= and <= were reversed

Dec
16
1 month ago
Activity icon

Replied to How To Deal With The Back Button In Vue?

@chrisgrim That might be the only real acceptable reason to interrupt normal navigation, so long as it's not something you do everywhere ... carry on :)

Activity icon

Replied to How To Deal With The Back Button In Vue?

If you use html5 routing with vue-router, back button support is automatic ... beyond that -- please don't hijack the default behavior of the back button, it's endlessly frustrating for the user for things to not behave normally.

Activity icon

Replied to Memory Exhausted After So Much Loops. Back To Eloquent

Yea, so you can accomplish the same with use of a map() in javascript pretty painlessly, as I mentioned, might be a better option, especially given that the dates are already being included in the correct order, so you don't also need to worry about sorting...

Dec
13
1 month ago
Activity icon

Replied to Notifications Are Broken

No worries! Mostly just posted to bring it to your attention, I can survive without 100% functionality. ;)

Activity icon

Replied to Notifications Are Broken

and, just as suddenly as it broke now it's working again .. :)

Activity icon

Replied to Laravel Vs Lumen

Lumen is very bare bones compared to Laravel... and there's not enough information here for anyone to make this determination for you, but it's very likely the extra parts that are included by default in laravel vs lumen will be appreciated. Sure you could add blade to lumen, but it's just as easy (easier maybe) to disable parts of laravel you don't need.

And processing thousands of jobs/hour is easily doable with laravel too.. unless you're looking at thousands of jobs per minute I wouldn't sweat it much personally.. but again, don't know the full requirements, so can't really answer the question.

I would assume there will be some need of authentication, along with just hitting a few external apis, and providing a UI for scheduling and reviewing logs, etc.. I also suspect this will very likely grow beyond what you may initially think is very simple into more complex, as things more often than not do. :)

Could you do it in lumen regardless.. .of course. You could build it in plain old vanilla php too.. or javascript, or python, etc..

Activity icon

Replied to Notifications Are Broken

Of course I have tried clearing cache, etc...

There is an issue with the laracasts code, thus why I posted this in Feedback --- for Jeffrey :)

Activity icon

Replied to Memory Exhausted After So Much Loops. Back To Eloquent

I'd probably come at this from a different direction.. select employees with appointments.

Then iterate through each employee's appointments and remap the array.

Is there a reason you need the hour to be the array key? Is there another way to achieve the same result without it being the array key?

For example, if an array of objects is passed to Javascript, you could pretty trivially convert an array of objects to an object with those keys with a map() ...

something like this, for example...

for (const user of users) {
  const appointments = {}
  user.appointments.map(item => appointments[item.startDateTime.split(' ')[1]] = item)
  user.appointments = appointments
}

Of course at that point, you might as well just do a simple loop in PHP to transform it too..

In any case, likely the problem wasn't so much that you were looping before, but that you were initially selecting too much and thus looping inefficiently.

Activity icon

Replied to Notifications Are Broken

Yes timestamps have been an issue for a long time, but this thread is about the notification issue.

Dec
12
1 month ago
Activity icon

Replied to Notifications Are Broken

Email again, same result in flyout menu..

and the notification indicator never goes away because I can't see them to mark them viewed.

Activity icon

Replied to Notifications Are Broken

Still broken for me, though I did get an email notification about your reply.

Activity icon

Started a new Conversation Notifications Are Broken

I have a bell icon over my profile image in the top right corner indicating notification(s), and in the flyout menu the little blue indicator dot also appears for the notifications tab, but that tab contains no content.

This has been going on for maybe 2 weeks or so now.. Looks like there's a JS issue, when I toggle open the flyout menu, the following appears in the console:

vendor.js?id=3e9700e722cfc0eded2a:1 

TypeError: Cannot read property 'path' of null
    at app.js?id=5f9d9a7fcca34426d015:1
    at a.ge [as _l] (vendor.js?id=3e9700e722cfc0eded2a:1)
    at a.<anonymous> (app.js?id=5f9d9a7fcca34426d015:1)
    at a.t._render (vendor.js?id=3e9700e722cfc0eded2a:1)
    at a.r (vendor.js?id=3e9700e722cfc0eded2a:1)
    at pn.INkZ.pn.get (vendor.js?id=3e9700e722cfc0eded2a:1)
    at new pn (vendor.js?id=3e9700e722cfc0eded2a:1)
    at vendor.js?id=3e9700e722cfc0eded2a:1
    at a.INkZ.Tn.$mount (vendor.js?id=3e9700e722cfc0eded2a:1)
    at a.INkZ.Tn.$mount (vendor.js?id=3e9700e722cfc0eded2a:1)
Dec
09
1 month ago
Activity icon

Replied to Going Vanilla PHP - Only Real Experience With Laravel

Laravel doesn't add a whole lot of overhead.. I guess it's not super necessary if you're building a small one-off script with no useful output to manipulate a file or something, but it provides such a nice environment within which to build apps of basically every sort, I don't know why you'd really bother not using it, honestly.

Sure you could but.. why?

Activity icon

Replied to Calculating Retirement Date

Short of someone commiting the functioning code to your codebase you've been given the solution in several ways -- and you even pseudocoded the logic for it yourself.

What were you actually expecting from people?

Dec
06
1 month ago
Activity icon

Replied to Eloquent Query To Filter Same Column Values

I think the way to accomplish this is by getting the count of occurrances of product_id where filter id is one of the required values, and then only selecting where that count is the same number as the number of filter ids..

For example:

SELECT v.product_id
  FROM (
      SELECT product_id, count(*) AS matches 
        FROM product where filter_id IN (2,4)
    GROUP BY product_id
  ) AS v
WHERE v.matches = 2

Obviously to build this dynamically you'd need to replace the IN (2,4) with a placeholder and pass in the array, and replace the where clause to use the count of the array rather than 2.

The output will be product id(s) and can then be used to populate a whereIn clause to load product models.

Activity icon

Replied to Errormessage That Job Runs To Long

11ms seems reasonably quick for a DB response. Strongly suspect something else is failing causing the job to retry several times until it hits the max retries and eventually fails.

I would add more debugging to the job itself to track what's actually happening/failing to happen

Activity icon

Replied to App.js Smaller On Production Server

But when I upload the file to my production server (AWS with Forge) and hard refresh the site chrome says app.js is only 351 kB. How can this be?

By default, local development builds don't minify but production builds do.

Activity icon

Replied to Calculating Retirement Date

The complete lack of effort displayed here on your part @inspiredprynce is pretty astonishing.

Dec
04
1 month ago
Activity icon

Replied to Packaging My App For Resale, How?

Frankly, I don't think spark has anything at all to do with what you're asking.. it and the laravel installer Ty linked to are completely different unrelated things.

Dec
03
1 month ago
Activity icon

Replied to Calculating Retirement Date

my brain is not processing information properly at the moment, i need someone to do that

It may be that software development isn't a good fit for you if you get stymied by such basic logic... food for thought.

Activity icon

Replied to Calculating Retirement Date

If you have the logic you need.. why can't you turn that into the appropriate code yourself? You'd already at least halfway to your solution.

Dec
02
1 month ago
Activity icon

Replied to Date To Julian Format

Julian is simply the last two digits of the year and the day of the year, seems like it ought to be pretty easy to sort that out on your own with carbon and a little string manipulation

Carbon has a dayOfYear() getter...

Nov
25
2 months ago
Activity icon

Awarded Best Reply on Make V-for Print Only One Object

@ftiersch has the right solution.

Use a computed property to create a filtered list to iterate over with a v-for, and if that list is empty, display your empty message, else the v-for.

ie:

<div>
  <p v-if="todaySantas.length < 1">No Santas today. :(</p>
  <div v-else>
    <ul>
      <li v-for="santa in todaySantas" :key="santa.id">{{ santa.name }}</li>
    </ul>
  </div>
</div>

and so forth.

Nov
21
2 months ago
Activity icon

Awarded Best Reply on Search A Record Or Relationship

You can't query against the payment plan like that because when you eager load via with() that generates a separate query.

If you want to query against fields in multiple tables you instead need to JOIN

Making some assumptions about your DB, I believe the query should look something like this:

$results = Transaction::whereHas('paymentPlan')
    ->leftJoin('payment_plans', 'transactions.payment_plan_id', '=', 'payment_plans.id')
    ->where(function ($query) {
      $query->where('transactions.transaction_ref', 'LIKE', '%' . request()->keyword . '%')
            ->orWhere('payment_plans.name', 'LIKE', '%' . request()->keyword . '%')
    })
    ->with(['paymentPlan'])
    ->paginate(15);

Note: I'm a bit rusty, so that may not be 100% accurate :)

But generally speaking, you need to join the tables, then define all your where clause options for the various columns across the various tables.

Activity icon

Replied to Search A Record Or Relationship

You can't query against the payment plan like that because when you eager load via with() that generates a separate query.

If you want to query against fields in multiple tables you instead need to JOIN

Making some assumptions about your DB, I believe the query should look something like this:

$results = Transaction::whereHas('paymentPlan')
    ->leftJoin('payment_plans', 'transactions.payment_plan_id', '=', 'payment_plans.id')
    ->where(function ($query) {
      $query->where('transactions.transaction_ref', 'LIKE', '%' . request()->keyword . '%')
            ->orWhere('payment_plans.name', 'LIKE', '%' . request()->keyword . '%')
    })
    ->with(['paymentPlan'])
    ->paginate(15);

Note: I'm a bit rusty, so that may not be 100% accurate :)

But generally speaking, you need to join the tables, then define all your where clause options for the various columns across the various tables.

Activity icon

Replied to Trying To Get Property 'email' Of Non-object

@clubcouleurs Regardless, my advice on how to properly debug the problem remains. Start where it throws the error and work backward until you find the cause.

Given the OP didnt' bother to post any of their own code, there was no way to provide any more insight that was already done..

I also stand by my comment that something ought to pick up on the fact that it's not got all the relevant information to run the normalizeRecipient() method, and throw an exception well before the default php error of trying to get property of a non-object occurs.

This would also highlight a good scenario where unit tests would be useful, assuming the non-success cases are adequately tested.

At the end of the day, regardless the project, or the users, the rule remains constant -- you cannot trust user input to be complete or valid.