wilburpowery

Full Stack Web Developer at BVMedia

Hire Me

Experience

66,340

23 Best Reply Awards

  • Member Since 1 Year Ago
  • 493 Lessons Completed
  • 0 Favorites

21st May, 2018

wilburpowery left a reply on Service Provider Routes Always Get 404, Even Though Exist In Route:list • 1 day ago

Does it still show up when running php artisan route:list?

wilburpowery left a reply on Got Error While Populating Database With Factory Method • 1 day ago

When you call the save method it expects it to be from an Model instance.

You should use create instead since you want to pass an array of data.

factory(App\Company::class, 10)->create()->each(function($u) {
        $u->users()->create(factory(App\User::class)->make(['company_id'=>$u->id, 'email'=> $u->email]));
    })->each(function($u){
        $u->dealers()->create(factory(App\Dealer::class,5)->make(['company_id'=>$u->id]));
    })->each(function($u){
        $u->programs()->create(factory(App\Program::class,5)->make(['company_id'=>$u->id]));
    });

Please take a look at this section of the docs to get a good grasp of the subject.

https://laravel.com/docs/5.6/eloquent#inserting-and-updating-models

18th May, 2018

wilburpowery left a reply on How Can I Send An SMS To Mobile With Laravel 5.6 On Localhost? • 4 days ago

Are you passing your values from nexmo in theenv() function? You shouldn't do that.

ENV files are to store credentials in a KEY-VALUE manner. For example for Nexmo, you would have something like this:

NEXMO_KEY=my_key NEXMO_SECRET=nexmo_secret

And then from you config/services.php file:

'nexmo' => [ 'key' => env('NEXMO_KEY'), 'secret' => env('NEXMO_SECRET'), 'sms_from' => '018xxxxxxxx', ],

What you pass inside the env() function should be the name of the key you want to fetch from the env file.

Also, check your storage/logs/laravel.log file to see what errors are happening.

17th May, 2018

wilburpowery left a reply on Can I Make REST Api And Use It On Route Web ? • 5 days ago

Are you using Laravel Passport?

If yes, there's a middleware you can include on your web group to consume your api from the frontend.

wilburpowery left a reply on Route - Why A String "[email protected]" And Not A Callback Controller::method() Or Similar? • 5 days ago

Also, Laravel loads all the controllers from the Container, so It woduln't be right to pass an instance of the Controller yourself.

wilburpowery left a reply on Route - Why A String "[email protected]" And Not A Callback Controller::method() Or Similar? • 5 days ago

Callbacks can't be serialized.

If you use callbacks in your route file you won't be able to cache it. Caching your routes will eventually make it faster so, yes. It's faster.

wilburpowery left a reply on Storage::put Vs Storage::putFile* • 5 days ago

Let's take a look at the source code.

public function put($path, $contents, $lock = false)
{
     return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
}
/**
 * Store the uploaded file on the disk.
 *
 * @param  string  $path
 * @param  \Illuminate\Http\File|\Illuminate\Http\UploadedFile  $file
 * @param  array  $options
 * @return string|false
 */
public function putFile($path, $file, $options = [])
 {
     return $this->putFileAs($path, $file, $file->hashName(), $options);
 }

put does indeed only use file_put_contents. `putFile on the other hand is used to save on the disk a file that has been uploaded (Http Request).

wilburpowery left a reply on Laravel Passport Series • 5 days ago

Taylor already created a video for Passport. Have you seen it?

https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/13

wilburpowery left a reply on Authentication - Logs In At The Second Time • 5 days ago


if (Auth::attempt(['email' => $request->email, 'password' => $request->password, 'active' => 1], true)) {
            $user = Auth::loginUsingId($user->id, true);
}

The `attempt` method logs the user in if the credentials are valid. And then you're login in the user again using `loginUsingId`. I'm guessing the problem might come from this.

Try removing the `$user = Auth::loginUsingId($user->id, true);`.

wilburpowery left a reply on Array Pass In Modal Using Jquery • 5 days ago

I always recommend to give Vue.js a try. It makes all of this easy.

Jeffrey has a free series on Vue.js here: https://laracasts.com/series/learn-vue-2-step-by-step

wilburpowery left a reply on Regarding Group • 5 days ago

You can check the Laravel.io Slack channel.

wilburpowery left a reply on Array Of Policies As A Collection • 5 days ago

Why don't you take a look at the Bouncer package? https://github.com/JosephSilber/bouncer

14th May, 2018

wilburpowery left a reply on Best Way To View A PDF File In A New Tab • 1 week ago

You might want to take a look at file download responses.

https://laravel.com/docs/5.6/responses#file-downloads

wilburpowery left a reply on Counter With JS/Laravel • 1 week ago

I think this is a great time to introduce Vue.js to yourself.

https://laracasts.com/series/learn-vue-2-step-by-step

3rd May, 2018

wilburpowery left a reply on Access Component Vm Inside Of Non-arrow Function • 2 weeks ago

let vm = this; right after defining the graphOptions computed property? That way you could do something like this:

 positioner: function () {
   vm.positionTooltip(this.now)
 },

wilburpowery left a reply on Vue Why Props And Data Use Same Syntax As This.test? • 2 weeks ago

I'm really not sure about this. I'm guessing it first looks in the data properties for it, if it doesn't find it, it looks for it on the props object. If it isn't anywhere, it throws an error.

I'd love to get more info on this myself.

wilburpowery left a reply on How To Create A Link In Javascript With Laravel • 2 weeks ago

let tag = document.createElement('a');
tag.setAttribute('href', 'https://google.com');

Is that what you're looking for?

wilburpowery left a reply on Getting Last Inserted ID With Laravel Ask Question • 2 weeks ago

Can we see your migration file? Make sure you have the notification_template_id column as a increments().

13th April, 2018

wilburpowery left a reply on Better Way To Submit Json Data In Post Test • 1 month ago

$this->getJson() and $this->postJson()?

Are you using Laravel? We need a little more info about what you're using. :)

wilburpowery left a reply on How To Deal Invalid Urls In Laravel 5.5/vue.js2.5 Application ? • 1 month ago

You mean 404 routes? Laravel takes care of those for you by default. Or are you building an SPA?

wilburpowery left a reply on Route Validation • 1 month ago

I wouldn't create a new middleware for simply doing that check. I'd do it directly in the controller method.

You can do something like this:

abort_if(auth()->user()->id != $client->user_id).

If you use something like Policies it can be even better, you'd be able to refactor to something like this:

abort_if($user->can('view', $client))

wilburpowery left a reply on Route Validation • 1 month ago

I wouldn't create a new middleware for simply doing that check. I'd do it directly in the controller method.

You can do something like this:

abort_if(auth()->user()->id != $client->user_id).

If you use something like Policies it can be even better, you'd be able to refactor to something like this:

abort_if($user->can('view', $client))

wilburpowery left a reply on Nested Foreach/GroupBy - Laravel Decorators? • 1 month ago

I'f theres only a few groupBy clauses, I generally just chained them like the example from @bobbybouwmann. It helps to keep it very simple sometimes. :)

14th March, 2018

wilburpowery left a reply on [Symfony\Component\Debug\Exception\FatalThrowableError] • 2 months ago

Did you update anything in the vendor file? Try deleted the vendor file and running composer install again.

15th February, 2018

wilburpowery left a reply on Composer View Is Not Loading Variable Into View • 3 months ago

Please take time to format your code correctly. Use the code syntax.

wilburpowery left a reply on Store New Conference -no Errors But The Conference Is Not Stored • 3 months ago

Is there anything in your log file?

12th February, 2018

wilburpowery left a reply on Production.ERROR: PDOException: SQLSTATE[HY000] [2002] Connection Refused In.... • 3 months ago

Also, you might have mysql running on another port. By default the .env file has it set up for 3306. You might want to check that also.

wilburpowery left a reply on Production.ERROR: PDOException: SQLSTATE[HY000] [2002] Connection Refused In.... • 3 months ago

Local or development?

Looks like mysql is not started in your environment. Maybe you don't have it configured to start automatically and you need to start it manually?

We really need more info about the error. :)

6th February, 2018

wilburpowery left a reply on To Display Logged In Username In Top Div. • 3 months ago

Could I ask why are you doing the Auth manually?

Here's what the php manual says about HTTP cookies. http://php.net/manual/en/features.cookies.php

5th February, 2018

wilburpowery left a reply on Invalid Request (Unexpected EOF) • 3 months ago

Unexpected EOF means “unexpected end of file”. Maybe you have some error in your code?

2nd February, 2018

wilburpowery left a reply on Font Awesome 5 Using Laravel-Mix On Laravel 5.5 • 3 months ago

Why are you importing FontAwesome 5 from your app.js file??

wilburpowery left a reply on ANY SMS API /Service Where I Can Send Sms For Free For Development. [ I'm Willing To Pay For Production ] • 3 months ago

Nexmo offers some credit to use for development purposes. If you need more credit, simply get in contact with them and they'll give you a bit more. Their customer support is really great.

https://www.nexmo.com/

31st January, 2018

wilburpowery left a reply on Duplicate Queries., Different `where` Statements • 3 months ago

I think Query Scopes is the way to go. https://laravel.com/docs/5.5/eloquent#query-scopes

Assuming your model name is DB1:

// ignoring class declaration

public function scopeOfEmails($query, array $emails)
{
    return $query->whereIn('email', $emails);
}

Then you would use it as follows:

$query = DB1::ofEmails($verified_user_domains)->get();
$total_clean_count = DB1::ofEmails($verified_user_domains)->where('isspam',false)->count();
$total_spam_count = DB1::ofEmails($verified_user_domains)->where('isspam',true)->count();

Might be a little more code to write, but a lot easier to understand and maintain IMO.

29th January, 2018

wilburpowery left a reply on Angular & Laravel On Forge • 3 months ago

You can keep both separate. Or, do all your Angular code in resources/assets/js folder. Laravel by default ships with Vue.js but it's very easy to switch it out for anything you want to use.

wilburpowery left a reply on Server To Handle 100K Daily Traffic • 3 months ago

A VSP will do. You should pay for a plan than can handle your expected traffic. Digital Ocean has some good plans.

https://www.digitalocean.com/pricing/

wilburpowery left a reply on How To Prevent Ajax To Repeat Firing The First Request Upon Completing The Second Request • 3 months ago

You are adding both events listeners to the document object. To prevent them from firing at the same time, add the event listener to different objecta. ex: two different buttons.

28th January, 2018

wilburpowery left a reply on Best Structure For Vue.js SPA And Laravel Together? • 3 months ago

Hey @MyLibrary I developed a few months ago a full SPA with Vue.js and Laravel. I'll share you the repo.

https://github.com/wilburpowery/cashflow-assistant/tree/master/resources/assets/js

But this is the basic structure I always follow when working with Laravel and Vue.js with SPA's. My Structure

25th January, 2018

wilburpowery left a reply on Single Login System For Mobile And Web App !? • 3 months ago

You can indeed use Passport. You can build your entire backend as an api and simply use the CreateFreshApiToken to consume your api without sending a token on every request in your front end with Javascript. Your mobile app will need to fetch a token and send it on every request to validate the request. Getting started with Passport is very easy. You can even generate Password grant tokens that that are good if you simply want to send an email and password and receive a token that identifies that user.

Hope it helps.

19th January, 2018

wilburpowery left a reply on What Is Wrong Here? • 4 months ago

No. Same error. First time I've ever seen this. Really weird.

wilburpowery left a reply on What Is Wrong Here? • 4 months ago

No. I have no idea what is wrong. Same error.

wilburpowery started a new conversation What Is Wrong Here? • 4 months ago

// Controller
$channels = Channel::paginate(20);
return view('admin.channels.index', compact('channels'));

// View file
 @forelse($channels as $channel)
        @forelse($channels as $channel)
                <tr>
                    <td>{{$channel->name}}</td>
                    <td>{{$channel->slug}}</td>
                    <td>{{$channel->description}}</td>
                    {{--  <td>{{ $channel->threadsCount }}</td>  --}}
                </tr>
            @empty
                <tr>
                    <td>Nothing here.</td>
                </tr>
            @endforelse
            {{ $channels->links() }}            

I'm getting this error:

(2/2) ErrorException Method links does not exist.

wilburpowery left a reply on SWITCH TO LINUX • 4 months ago

Ubuntu is good. But If you don't have a lot of knowledge on the command line, I'd switch to Ubuntu Desktop. (It has a user interface). https://www.ubuntu.com/desktop

17th January, 2018

wilburpowery left a reply on Should A Controller Be Restricted To Creating/modifying Objects Specifically For That Model? • 4 months ago

This talk from Adam Wathan should help you out. Really great advice! https://www.youtube.com/watch?v=MF0jFKvS4SI

15th January, 2018

wilburpowery left a reply on Auth Login Function Error • 4 months ago

Overriding Laravel's auth is soo simple. And by simply running the make:auth command, you get a lot of things out of the box.

Want to update where the user should be redirected after login? Simply change the following code on your LoginController.

/**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/where-ever-you-want';

wilburpowery left a reply on Map() Not A Function • 4 months ago

Seems strange. The map function is from the Array prototype. It should not give any errors in any environment.

wilburpowery left a reply on Work For Laracasts (Web Designer) • 4 months ago

He will hire another developer sometime this year. Not only PHP though, but some good content should come from the new guy. I can feel a very exiting year coming for Laracasts :)

wilburpowery left a reply on Redirect With Flash Message • 4 months ago

You need to do it from the controller.

return redirect('/some-page')->with('flash', 'Whatever message you want');
Edit Your Profile
Update

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