willvincent

Hire Me

Experience

300,135

360 Best Reply Awards

  • Member Since 2 Years Ago
  • 1164 Lessons Completed
  • 0 Favorites

3rd October, 2017

willvincent left a reply on Understanding About Helper. • 1 month ago

I would like to know if this breaking the flow of MVC pattern? Because we are running DB queries directly from helper method used in view file.

Yes, of course that breaks the MVC pattern. That's entirely the wrong way to do it.

11th May, 2017

willvincent left a reply on JSON File As A Data Source • 6 months ago

I dunno about doing it with eloquent, but you can pretty easily build a fake rest server around a json file with the json server nodejs package.

23rd April, 2017

willvincent left a reply on Make Php Artisan Serve Multi Threaded • 7 months ago

[2017-04-23 09:35:20] production.ERROR: RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. in C:\wamp64\www\GoAP\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php:43

You need to ensure you have the mcrypt extension installed and enabled. Check your wamp php config.

22nd April, 2017

willvincent left a reply on L5 - Best Way To Get User Timezone • 7 months ago

https://momentjs.com/timezone/

moment.tz.guess() will attempt to get the timezone name from the client browser.

The most foolproof method is to have the user manually set their own timezone.

21st April, 2017

willvincent left a reply on Laravel IDE • 7 months ago

There are already many IDE's that work great with PHP. I switch between sublime and phpstorm, and occasionally VSCode (though usually only for javascript or C# in it). There's not only no need for yet another IDE, but you'd be hard pressed to find a better IDE for php development than phpstorm.

willvincent left a reply on Learning JavaScript • 7 months ago

The ES2015 (aka es6) series would definitely not be a waste of time.

20th April, 2017

willvincent left a reply on How To Refactor Laravel PHP Code In Sublime ? • 7 months ago

I've never used it, but there is a refactor php package for sublime.

https://packagecontrol.io/packages/PhpSimpleRefactor

willvincent left a reply on Is It Possible To Connect Two Database Table Rows? • 7 months ago

@jlrdw but the OP isn't doing any sort of backups, this is simply about a different type of user.

There's literally no reason for anything more complex here than either a boolean column on the table indicating the user is an admin, or a user role system. No need for a separate table nor a second model pointing at the same table.

Good time to employ the KISS principle. ;)

willvincent left a reply on Laravel IDE • 7 months ago

artisan can already do some code generation, any more than what it does is pretty unnecessary and if you find more to be necessary for you, that's what snippets and live templates are for.

phpStorm is a great IDE for any php application, laravel or otherwise, a laravel specific IDE (which it seems is what you're asking for) is unnecessary and never need to developed.

willvincent left a reply on Is It Possible To Connect Two Database Table Rows? • 7 months ago

You can, sure.. that too seems somewhat unnecessary though ;)

willvincent left a reply on Syntax Error, Unexpected '<' In View • 7 months ago

Exactly, don't put a full block of PHP into your template, that's very bad practice.

That said, the specific problem(s) causing the error are the markup within your opening and closing php tags. That syntax is just entirely flawed.

willvincent left a reply on Query And Comparing 2 Tables • 7 months ago

Get list of product ids purchased by the specific user, then use those as part of a whereNotIn clause.

For example:

$purchased_ids = Purchase::where('user_id', 12)->pluck('product_id')->all();

$unpurchased = Product::whereNotIn('id', $purchased_ids)->get();

willvincent left a reply on Is It Possible To Connect Two Database Table Rows? • 7 months ago

Seems like it's probably unnecessary to have separate tables for these since they're pretty much just a different type of user, that could be handled with roles or even a simple boolean flag indicating that a user is an admin.

But, if you're determined to use two tables, and the ID in the admin table needs to match that of the id within the user table, why not just make the admin's ID an unsigned, non-nullable integer (not auto-incrementing) and manually set it to the same as the user ID when doing your inserts and updates?

willvincent left a reply on Search Not Work In Laravel 5.4 • 7 months ago

Either you didn't read the rest of my comment, or you must not really want help... "Doesn't work" isn't really useful. It tells us absolutely nothing about the real problem.

willvincent left a reply on Send SMS Notification • 7 months ago

First check if the one you want to use already has a channel provider: http://laravel-notification-channels.com/

If you can't find it, write your own custom provider

willvincent left a reply on Clicking On The Server Link Does Not Work • 7 months ago

That part of the output from that command doesn't appear as a link for me. Where are you seeing it at a link? Or are you just assuming that it should be a link?

willvincent left a reply on Search Not Work In Laravel 5.4 • 7 months ago

You've provided a lot of code which is nice, but you're not really being clear about the issue.. just saying "It doesn't work" isn't really very descriptive. How does it not work? What is happening that shouldn't be, or what is not happening that should be. Any error messages?

If that javascript is the entire JS, your issue is probably that you're not waiting for the dom to be ready before attempting to bind autocomplete to your search element. Simply wrapping a document ready function around your JS might be all that's necessary.. without more information though that's a total stab in the dark.

(function ($) {
  $(document).ready(function() {
    $('#searchname').autocomplete({
      source : '/autocomplete', // <-- this should be sufficient
      minlength: 1,
      autoFocus: true,
      select: function(e,ui){
        //$('#id').val(ui.item.id);
        //$('#name').val(ui.item.value);
      }
    });
  });
})(jQuery)

The first & last lines aren't necessarily required, but it's a good convention to use and works even if jquery isn't bound to the dollar sign variable name for one of several reasons that can be the case.

willvincent left a reply on Deployed Changes Aren't Showing On Site • 7 months ago

To be clear you want opcache enabled.. your performance would very noticeably suffer without it.

But since you are running nginx, restarting that process won't make a difference, you need to restart your php-fpm process.

willvincent left a reply on Deployed Changes Aren't Showing On Site • 7 months ago

You've probably got php opcode caching or something along those lines enabled on the server. So while you don't need to reboot the server you would probably need to restart the webserver and/or php processes.

willvincent left a reply on Sending Email After Specific Date • 7 months ago

Are you working in a windows environment? It doesn't have cron.

19th April, 2017

willvincent left a reply on Sending Email After Specific Date • 7 months ago

@sandstorm as @jekinney suggested, yes I think that makes the most sense in your case given the length of the delay you're looking for before taking action.

willvincent left a reply on What Relation Should I Use In This Case ? • 7 months ago

I think you've overcomplicating things by separating 'spell details' into its own table, considering that is simply the min/max damage values. Instead just include those on the spell directly, and as a user levels up, change which spell id's are associated with that user.

Not only will that be easier to query, but it's a considerably easier data model to maintain.

willvincent left a reply on Sending Email After Specific Date • 7 months ago

@jekinney's suggestion makes a lot more sense than shoving it into a queue to wait 50 days. Store the necessary information in the database, and check that table daily for any items that are now 50 days old, and process them, at which point you could either remove them or mark them as processed with a date stamp/etc.

Using a redis or similar queue, for this particular use case seems entirely wrong to me.

willvincent left a reply on Updating .env File • 7 months ago

I am sure there must be loads of better ways update it.

Why do you suspect that? The .env file should not exist in your repo, so the only way to manipulate it is directly on the server. You could use a different editor, but that's not better just different.

Really about the only other realistic option would be to edit it locally and then copy it onto the server with scp .. but again, that's not necessarily better, just different.

What you're doing is totally fine.

willvincent left a reply on Is 44 Requests Per Second Bad On An Internal Network? • 7 months ago

Using ab -n 100 I'm getting about 77 rps from asp.net core and around 44 from laravel. I'm trying to find ways I can improve this.

Neither of those numbers are very good...

There are also many variables at play when it comes to response times and throughput (requests per second). It could be that your server simply isn't tuned very well for higher volume traffic. I haven't configured apache in several years but the default number of concurrent connections allowed used to be fairly low.

nginx, in general, is faster and has a smaller memory footprint than apache.

mariadb, likewise, is generally faster with a smaller memory footprint than mysql. Migrating to those would very likely help boost performance.

Leveraging php opcode caching, and a different cache backend than the database or filesystem (memcache, for example), perhaps making use of the russian doll caching technique that Jeffrey covered in a series last year, tuning the webserver config, DB config and PHP config all would go a long way to dramatically increasing those numbers -- all before you start worrying about query optimizations and whatnot.

Yes, as has been mentioned with is always going to trigger an additional query, but that is instead of one extra query for each record, if you didn't "eager-load" the data. in many cases you certainly could use joins instead, whether or not that's a big optimization depends on the data though. It's likely the bottlenecks are occurring elsewhere -- some of which would simply be your network traffic and how that is routed and shaped, etc.

18th April, 2017

willvincent left a reply on How To Acomplished This Complex Structure • 7 months ago

Hmm.. maybe a groupby on the master category?

12th April, 2017

willvincent left a reply on Ways Of Loading Relevant User Info Without Hitting DB Every Time • 7 months ago

True @davestewart .. though not really if you need that info on the backend. Although at that point the question is whether or not you're really gaining much by not querying it from the DB again. :)

willvincent left a reply on Ways Of Loading Relevant User Info Without Hitting DB Every Time • 7 months ago

Probably about your only other realistic option would be to stick it into some sort of key/value store cache.. redis, maybe.

willvincent left a reply on Mention System • 7 months ago

Don't misunderstand what I said, I'm not suggesting regex wouldn't be involved at all, but that the entire frontend/backend collection of moving parts that need to be put in place is considerably more than just using preg_match_all() as you stated.

They're asking for a package for what is, to my mind, pretty obviously the mention behavior that is available here on this forum, as well as pretty common on various social networking platforms, facebook, google+, etc.

Otherwise they wouldn't have referred to it as a "mention system" parsing a pattern-matched string out of a blob of text is but one tiny piece of that.

willvincent left a reply on How To Daily Backup Database In Mysql ? • 7 months ago

@waltz Yeah, I know the code in my sample isn't as pristine as it can be, it was a quick get it in place project that I had to squeeze in amongst a bunch of other really higher priorities, but it gets the job done.

willvincent left a reply on Mention System • 7 months ago

@Cronix I very much suspect the desire is to have working autocomplete/etc like is the case on the forum here. a regex isn't going to accomplish that.

willvincent left a reply on Conditional Relationship Laravel • 7 months ago

Ok, how about this:

$active_users = User::where('status', 0)->pluck('id')->all();

$products = Product::whereIn('user_id', $active_users)->get();

willvincent left a reply on Mention System • 7 months ago

Did you try searching? Literally the first google result: https://github.com/unicodeveloper/laravel-mentions

:)

willvincent left a reply on Am I Just Stupid? • 7 months ago

If you're not using a proper IDE (with full codeintel/intellisense) that's the first thing to change. Something like phpStorm, that allows you to easily click on classes and methods and dig down into the code to see what's happening under the hood easily.

Along with that you'll need to install the IDE Helper package so that the intellisense functionality can actually figure out what to do with the facades' fake static methods.

And, as others have said, or at least alluded to, don't expect to just understand the framework right away. Stick with it, and start small until you really grok the concepts of how it works and you'll get it, it really is quite easy. Or, give up and use a different framework, or no framework. It's really up to you.

Laravel probably isn't for everyone... just like how many people prefer react to vue, they both accomplish the same thing, but to my eye vue is much cleaner and a helluva lot easier to get up to speed and be productive with. I find the same to be true of laravel vs most other frameworks.

willvincent left a reply on How To Daily Backup Database In Mysql ? • 7 months ago

As others have said, follow the installation instructions. the Spatie backup package is rock solid and awesome. :)

...and if you want to provide a web UI to delete, download, or manually create a new backup, here's some code I had whipped up for a project a while back, might save you some time:

https://gist.github.com/willvincent/bfbbfdd7521ffaf554abeb7fff1ab924

willvincent left a reply on Conditional Relationship Laravel • 7 months ago

This might be easier from the other side of the relationship:

User::with('products')->where('status', 0)->get();

willvincent left a reply on Run Phpunit On Save • 7 months ago

This post from a month ago provides what is apparently a working solution to this: https://laracasts.com/discuss/channels/testing/laravel-mix-and-phpunit?page=1

willvincent left a reply on Vue 2.2.* Broke My Code • 7 months ago

What's your source on that @jekinney? That is not mentioned in the docs. Of course I've personally always just used the es2015 shorthand for methods and computed properties in vue myself.. :)

willvincent left a reply on Not Loading Relationship • 7 months ago

Yeah, that looks like a much more usable data format for how you're using it :)

willvincent left a reply on Generating Unique Strings For A URL • 7 months ago

Sounds like what you want is the Hash IDs package.

You don't necessarily need it, but there's also another package that provides a laravel wrapper around it you could use if you prefer using facades..

willvincent left a reply on I'm Starting To Hate Laravel • 7 months ago

You should take the time to familiarize yourself with the multitude of PHP packages out there. There are so many.

Stop assuming you know thing one about me or anyone else here. As I've stated, I have TWO DECADES of experience in this business. I'm well aware of what is available.

willvincent left a reply on My Axios Always Returns An Error No Matter What... • 7 months ago

Ok, well it's catching an error... console log the error and see what the error is.

11th April, 2017

willvincent left a reply on My Axios Always Returns An Error No Matter What... • 7 months ago

You'd want to ensure a 200 response code is returned.

But you're getting an error.. what's the error?

willvincent left a reply on Full Page Overlay Plugin • 7 months ago

There's really nothing special about a loading indicator, pretty easy to roll your own.

Here's one I've used recently, as you can see the majority of it is just CSS (which mostly came from here: http://loading.io/)

You should be able to generate css at loading.io and then just replace the css in the component below (except for the .loading-indicator .cover and .loading-indicator .cover.dark clauses)

<template>
  <div class="loading-indicator" v-if="$parent.loading">
    <div class='uil-ring-css' style='transform:scale(0.6);'>
      <div></div>
      <h2>Loading...</h2>
    </div>
    <div class="cover" :class="{'dark': cover}"></div>
  </div>
</template>

<script>
  export default {
    props: ['cover'],
    computed: {
      style() {
        if (typeof this.cover === 'undefined' || !this.cover) {
          return false;
        }
        return true;
      }
    }
  }
</script>

<style>
  @-webkit-keyframes uil-ring-anim {
    0% {
      -ms-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    100% {
      -ms-transform: rotate(360deg);
      -moz-transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      -o-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }

  @-webkit-keyframes uil-ring-anim {
    0% {
      -ms-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    100% {
      -ms-transform: rotate(360deg);
      -moz-transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      -o-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }

  @-moz-keyframes uil-ring-anim {
    0% {
      -ms-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    100% {
      -ms-transform: rotate(360deg);
      -moz-transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      -o-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }

  @-ms-keyframes uil-ring-anim {
    0% {
      -ms-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    100% {
      -ms-transform: rotate(360deg);
      -moz-transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      -o-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }

  @-moz-keyframes uil-ring-anim {
    0% {
      -ms-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    100% {
      -ms-transform: rotate(360deg);
      -moz-transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      -o-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }

  @-webkit-keyframes uil-ring-anim {
    0% {
      -ms-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    100% {
      -ms-transform: rotate(360deg);
      -moz-transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      -o-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }

  @-o-keyframes uil-ring-anim {
    0% {
      -ms-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    100% {
      -ms-transform: rotate(360deg);
      -moz-transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      -o-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }

  @keyframes uil-ring-anim {
    0% {
      -ms-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }
    100% {
      -ms-transform: rotate(360deg);
      -moz-transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      -o-transform: rotate(360deg);
      transform: rotate(360deg);
    }
  }

  .uil-ring-css {
    background: #fff;
    width: 200px;
    height: 200px;
    z-index: 1000;
    margin: auto;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    box-shadow: 0px 0px 20px 10px rgba(0, 0, 0, 0.3);
    border-radius: 22px;
  }

  .uil-ring-css h2 {
    position: relative;
    top: 66px;
    left: 36px;
  }

  .uil-ring-css > div {
    position: absolute;
    display: block;
    width: 160px;
    height: 160px;
    top: 20px;
    left: 20px;
    border-radius: 80px;
    box-shadow: 0 6px 0 0 #18bc9c;
    -ms-animation: uil-ring-anim 1.2s linear infinite;
    -moz-animation: uil-ring-anim 1.2s linear infinite;
    -webkit-animation: uil-ring-anim 1.2s linear infinite;
    -o-animation: uil-ring-anim 1.2s linear infinite;
    animation: uil-ring-anim 1.2s linear infinite;
  }

  .loading-indicator .cover {
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 900;
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0;
  }

  .loading-indicator .cover.dark {
    opacity: 1;
  }

</style>

Usage is basically just including the component, maintaining a 'loading' data element on the parent element, and then optionally passing 'true' to the cover prop when placing the component in your template somewhere.

Basically:

<loading-indicator :cover="true"></loading-indicator>

It would probably make the most sense to include this at the top-most layer of your app, directly inside the root attribute the vue app binds to, and maintain the 'loading' data attribute on your root vue app. It can be toggled between true & false by triggering events when you make ajax requests/etc.

willvincent left a reply on My Axios Always Returns An Error No Matter What... • 7 months ago

Your controller method doesn't have a return.

willvincent left a reply on I'm Starting To Hate Laravel • 7 months ago

You keep preaching a bullshit position that one should not reinvent the wheel, but also one should always start "from scratch"

You can't have it both ways, and budgets don't typically allow you to build something, throw it away and then build it over from scratch. That way of thinking indicates that you are either not really a professional, or maybe you work for the government.

Yes, I'm definitely a huge laravel fan. Is it right for everything? No, definitely not. But your position is bullshit.

willvincent left a reply on PHP Unit Slowdown • 7 months ago

Are your tests running DB migrations? If so, are they interacting with an actual DB, or using sqlite in memory? Any tests interacting with external APIs over a potentially slow network?

If xdebug is enabled, disable it.

willvincent left a reply on I'm Starting To Hate Laravel • 7 months ago

The vast majority of the time it's better to start ground up by adding the components you really need.

That statement simply could not be more untrue.

Some components are coupled. Some overdone.

Every bit of laravel's core components can be either disabled or swapped out for alternate options, and as has been said by others previously even if there are portions of the core framework sitting unused it literally hurts nothing.

Frankly, it seems that you've joined this community expressly with the intent of tearing down the framework. You've been a member here for a week and the vast majority of your involvement has been in this thread criticizing the framework, and disparaging it's users -- anyone not serious enough about their craft, who deign to use the framework for anything other than prototyping.

You are wrong. Accept it or don't. There's really no point in continuing to argue how and why you are wrong.

willvincent left a reply on Tracking Popular And Trending Content • 7 months ago

Jeffrey covered this very topic in one of his redis videos.

You could certainly increment a 'views' value in the DB for each page, but that's going to incur a bunch of extra DB queries you otherwise wouldn't need.. Redis is pretty well suited to this sort of thing.

Number of views isn't going to tell you what's trending though, for that you need to keep track of number of views over time.

This sort of thing can get somewhat complex fairly quickly, so it really depends on what metric(s) you want to track and how. I recall using a module on a drupal site a few years back that provided an interesting approach for this sort of thing. Basically it would add "energy" to each thing as it was viewed, and that "energy" would decay at a rate defined by the configurable 'half-life period'.

The energy decays at a rate defined by the half-life period. For example, a view is worth 1 energy unit at the time of clicking, 0.5 energy units after one half-life period, 0.25 energy units after two half-life periods, and so on.

That gave you a pretty true view of what was actively trending by tracking views, but filtered through the lens of time.

Seems like an interesting thing to work on, maybe I'll build out something similar as a laravel package.

willvincent left a reply on How Can I Use TinyMCE With Laravel Mix? • 7 months ago

The issue you're likely running into now is that your tinymce init method is probably firing too early. If that's being executed before the #description element exists in the dom, for example, it's just not going to work properly.

I don't actively use tinymce, so can't really offer any more help, unfortunately.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.