wilk_randall

wilk_randall

Member Since 1 Year Ago

Experience Points 105,280
Experience
Level
Lessons Completed 483
Lessons
Completed
Best Reply Awards 86
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

12 Nov
1 day ago

wilk_randall left a reply on Tighter Coupling Between Laravel (PHP) And Vue (JS)

say something like return view('category.blog.index')->withVue(['articles' => $articles]);, which would be able to pass 'articles' in as a Vue component prop...

You can already pass in data from php to vue as a prop:

<articles :articles="{{ json_encode($articles) }}"></articles>

wilk_randall left a reply on Are There Any Tutorials On Laracasts To Learn About App.js?

You could really just write everything in vanilla javascript. Frameworks just make your life easier.

wilk_randall left a reply on How To Change Models Directory Without Any Problem?

There's no need to extend the command for something simple like this. All you need to do is php artisan make:model Models/ModelName -m and it will put it in a Models directory and will also put Models in the model's namespace.

wilk_randall left a reply on Implement A "policy" Using Slug

Why not just make the endpoint something like /user/profile, and always just use the authenticated user's profile? Wouldn't that be a cleaner solution?

wilk_randall left a reply on Are There Any Tutorials On Laracasts To Learn About App.js?

This is es6 JavaScript and there is a series on laracasts about it here: https://laracasts.com/series/es6-cliffsnotes

11 Nov
2 days ago

wilk_randall left a reply on Schema - Dynamic Prefix On Primary Key

I don't think what you're doing makes a lot of sense but... you can set the incrementing property on your model to false, and then generate your id through an observer on your model on the creating or created event.

wilk_randall left a reply on What Is The Best Host Service For A Laravel Project?

It's kind of subjective as what people consider "best" hosting providers. For a Laravel project, you usually want to use a vps through a provider such as linode or digital ocean.

10 Nov
3 days ago

wilk_randall left a reply on How Can I Iterate Through A Multi-level Collection?

You could do this with a recursive function:

public function yourDeleteFunction()
{
     $this->deleteChildren($folder);

     $folder->delete();
}

private function deleteChildren($folder)
{
     foreach ($folder->children as $child) {
         if ($child->children->count() > 0) {
               $this->deleteChildren($child);
         }

         $child->delete();
     }
}
09 Nov
4 days ago

wilk_randall left a reply on Named Routes In Vue

@abdulaziz @cmdobueno Take a look at this package: https://github.com/tightenco/ziggy

I've recently started using this one in a pet project I'm working on and it seems to work well. To me, it seems cleaner to generate a static js file with your routes in it that you can reference as needed in your JavaScript, rather than sending the routes through a blade.

wilk_randall left a reply on How To Using Mysqli Num Rows In Laravel

mysqli is very outdated and you really shouldn't be using that. If you're trying to use plain php then just use PDO, but since you're using Laravel you're better off using eloquent like @yakagi suggested.

If you're just going to stick with outdated technologies, why even bother using Laravel?

08 Nov
5 days ago
07 Nov
6 days ago

wilk_randall left a reply on Manually Authenticating Users And Ban Function Not Working

You have to check if the user's account is active after sign in. If not, log them out and redirect. You don't even need to overwrite Laravel's login function to do this. You can just define the authenticated function on your controller and it will be called after Laravel is done authenticating.

wilk_randall left a reply on Controllers

Typically you make one controller per resource (model usually). I mean, you can have a controller be responsible for more than one resource, but it's not really a good practice to do that. Depending on the resource, sometimes it's also best to split a controller into more multiple controllers to become more RESTful.

You may find this lesson, and others in this series beneficial to watch: https://laracasts.com/series/laravel-from-scratch-2018/episodes/6

wilk_randall left a reply on Laravel And Vue Lesson

If you're familiar with webpack, you can use Vue inside of Laravel no problem. It's not really much different. I think some of the videos in the learn vue 2 series covers integration with Laravel

05 Nov
1 week ago

wilk_randall left a reply on @can('role') Condition Based On Roles Instead Of Permissions

Why not just make another blade directive for role?

@role('manager')
    // users with manager role can access this area....
@endrole
02 Nov
1 week ago

wilk_randall left a reply on Change Password Field On Edit My Profile Page

@munazzil

You think that in case user forgot what he can do?

You should never assume your end-users know what they can and cannot do or that they know how the system works.

wilk_randall left a reply on Change Password Field On Edit My Profile Page

@the_lar Typically you don't populate a password field with data since it's encrypted and will never be the same string every time

01 Nov
1 week ago

wilk_randall left a reply on How To Send Request To An External Api

That's not really what request is for. You're better off using curl or Guzzle

31 Oct
1 week ago

wilk_randall left a reply on Best Practises For Handle Ajax Requests

I see no reason to create separate route files and controllers for ajax operations. If it's the same resource as something else, just use the same controller unless what you're doing with the ajax request makes sense to be in its own dedicated controller.

30 Oct
2 weeks ago

wilk_randall left a reply on Adding Phone Prefix To Phone Number Variable In My Component

As far as I'm aware, you can't use curly brackets curly brackets inside of attributes. This would work instead:

:href="`tel:+34 ${APP.globals.appBookingPhone}`"

wilk_randall left a reply on Configuring Nginx On Windows

@ashokvishnu - As @lostdreamer_nl had stated before, use Laragon. It's very easy to setup for windows and has a lot of the things you need for a server. There, now you have a solution.

29 Oct
2 weeks ago

wilk_randall left a reply on How To Make Condition Time

I don't think you necessarily need to create a custom rule. You should be fine just doing this:

'time' => 'required|date_format:"H:i"|before:' . date('H:i')

wilk_randall left a reply on Is Vuex Compatible With Laravel 5.6 ??

Vuex, like any other javascript library, is compatible with ANY version of laravel. That being said, I use it in my own projects and I recommend using it if your application is getting more complicated.

26 Oct
2 weeks ago

wilk_randall left a reply on How To Manage Your Global Vue Component?

@goatshark - Just curious, but why do this:

var SomeComponent = Vue.extend(require('./SomeComponent.vue'));

When you could instead do this?

import SomeComponent from './SomeComponent';

wilk_randall left a reply on Do Not Query If Primary Key Field Is Empty

That's really up to you. If you show your queries, we might be able to actually help you.

wilk_randall left a reply on How To Manage Your Global Vue Component?

@zerogpm - That's typically how you do it. You can do whatever kind of JavaScript you want in Laravel, it does not matter.

wilk_randall left a reply on Laravel - Js Sections Of Different Blade Files Making Conflict

Sounds like you need to use a stack: https://laravel.com/docs/5.7/blade#stacks

You would do something like this in your layout blade:

@stack('js')

And then in your blades:

@push('js')
    // your scripts here
@endpush

wilk_randall left a reply on Laravel 1.0

@Benko - It might never have been published in the repository. Version 3 might be the earliest you will be able to download.

wilk_randall left a reply on Passing Data From A Blade Template To A Laravel Controller

As you described, you are trying to send the data back to the controller. This is normally done in a request, which you would use a form for.

Maybe it would be more helpful if you showed some of the code of what you're trying to do.

wilk_randall left a reply on How To Manage Your Global Vue Component?

You should really only make a component global if you truly need it to be. Typically, it's better to import the component when you need it and make it a child of the component that is using it.

wilk_randall left a reply on Passing Data From A Blade Template To A Laravel Controller

It's not really any different from anything else: use a form...

25 Oct
2 weeks ago

wilk_randall left a reply on Is Laravel Really Bad For Performance?

You also need to keep in mind the quality of your own code. You could be using the most efficient language/framework out there, but if your code is not very efficient or written very well, it's going to negatively affect the performance of the application.

24 Oct
2 weeks ago

wilk_randall left a reply on Checking Value

You are trying to use toArray on a query builder. You need to finish the query with I'm guessing first() in this case since your constraining your query by the id.

If you actually modified your query to be more like the second example @vladv had suggested, you wouldn't have gotten the error you are posting.

wilk_randall left a reply on Check User's Roles In Checkbox

This might not be the most efficient way of doing it, but you could do something like this:

<label><input class="uk-checkbox" type="checkbox" :checked="hasRole(role.id)" @input="toggleRole(role.id)">{{ role.name }}</label><br />
data {
     return {
            roleIds: this.user.roles.map(role => role.id)
     };
},

methods: {
     hasRole (roleId) {
          return this.roleIds.includes(roleId);
     },

    toggleRole (roleId) {
         if (this.hasRole(roleId)) {
               return this.$delete(this.roleIds, this.roleIds.indexOf(roleId));
        }

        this.roleIds.push(roleId);
    }
}
22 Oct
3 weeks ago

wilk_randall left a reply on Change Primary Key

To me, it'd make more sense to have the product_id as a foreign key instead, especially if it isn't unique to the table.

21 Oct
3 weeks ago

wilk_randall left a reply on Passing Data To Dynamic Component

You can still pass props to dynamic components:

<component :is="widget.name" :styles="widget.styles"></component>

Something like that should work. You could even pass the entire widget to the component too, but it's up to you what you need to do. If you need to put the styles on the section tag, you could make a method that returns the styles needed from the given widget as well:

<section v-for="widget in widgets" class="linx-background flex flex-col justify-around"
                 :class="getWidgetClass(widget)"
>

</section>
methods: {
    ...

        getWidgetClass (widget) {
        // your logic to get the class
    }
}

wilk_randall left a reply on Searching Inside A Form Without Refresh

You are looking for Ajax. I recommend using (axios)[https://github.com/axios/axios] for making the ajax requests.

wilk_randall left a reply on Comparing Request Input With Database Value

I would use Carbon to compare the dates:

$project = Project::select('end_date')->where('p_id', $request->project_id)->first();

$projectEndDate = Carbon::parse($project->end_date);
$requestEndDate = Carbon::parse($request->end_date);

if ($projectEndDate->lt($requestEndDate)) {
    dd('store date');
}

dd('fail');

I did change a couple things because what you had wouldn't work. You were getting a collection of projects when you only needed the one. Also, you were trying to compare a collection of projects to a date, which also wouldn't work.

20 Oct
3 weeks ago

wilk_randall left a reply on How To Display Only Logged In User Data From Pivot Table

Try this instead:

$meetings = Meeting::with(['visitors', 'hosts'])->where('user_id', auth()->id())->get();

wilk_randall left a reply on Do I Need To Use Query Builder For This?

You can use either eloquent or the query builder as they both have almost all the same methods as each other. If you have a model, I'd recommend using eloquent, but it's ultimately up to you what you want to use.

19 Oct
3 weeks ago

wilk_randall left a reply on How Do I Pull Laravel Projects From Github That Don't Include The Framework Files?

Pull the files in like normal from github, then run:

composer install

php artisan key:generate

// etc

wilk_randall left a reply on Sorting By Appended Attribute

hmm, maybe try this instead:

protected $totalScore = null;

public function getTotalScoreAttribute()
{
    if (! is_null($this->totalScore)) {
        return $this->totalScore;
    }

    return $this->totalScore = $this->countTotalVotes();
}

wilk_randall left a reply on Checkout With Credit Card Validation In Laravel

@ralphdns - There's also authorize.net or even braintree. I do have some experience using authorize though, and I can say I highly recommend against using it however as it is a pain to use and their api (in my opinion) is very archaic. I recommend stripe or paypal as the others have mentioned.

wilk_randall left a reply on Sorting By Appended Attribute

I'm not sure what your accessor exactly does, but you could try caching the value on the model instance, maybe something like this?

public function getTotalScoreAttribute()
{
    if ($this->total_score) {
        return $this->total_score;
    }

    // your logic here
}

wilk_randall left a reply on Creating Global Helper Queryscopes In Laravel

You could always make it a trait and place it on the models you need the query scopes for.

wilk_randall left a reply on Wildcard Let's Encrypt

Well if you only have the two sites, you really don't need a wildcard necessarily. I would just create a cert for the subdomain and the domain and be done with it.

17 Oct
3 weeks ago

wilk_randall left a reply on Edit Passing Id

@Ishatanjeeb What you wrote will not work at all...

wilk_randall left a reply on [DELETE] Array To String Conversion

You can't delete discussions on this forum, so you could at least keep the question and post the solution so if others have the same question/problem they might be able to find yours and find their answer without having to ask the question themselves.

wilk_randall left a reply on Encrypted Columns

I agree with @Tray2. IMO you're just making more work for yourself to encrypt those types of fields. Sensitive data like credit numbers aren't normally searchable, so it's not really a big deal encrypting them since you won't have to worry about searching by that field (although a cc number shouldn't be stored on your server in the first place)

16 Oct
4 weeks ago

wilk_randall left a reply on Change Database Dynamically

@shez1983 - Okay, but you can have more than one database with multi-tenancy, just depends on how you want to structure it.