wilk_randall

wilk_randall

Member Since 1 Year Ago

Experience Points 119,690
Experience Level 24

310 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 514
Lessons
Completed
Best Reply Awards 102
Best Reply
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.

21 Mar
1 day ago

wilk_randall left a reply on Laravel Roles

To me, it's more complicated to have two separate controller methods and two separate views when instead you could just have one conditional in a view that accomplishes the same thing. You're just making more work for yourself otherwise.

wilk_randall left a reply on Laravel Roles

@jlrdw

Some use in view, I don't like them in the view, that's why I like them in controller where possible.

How are you supposed to expose certain parts of a view based on a user's permissions if you don't check it in the view? The logic being performed to verify the role is still behind a method call and is no different than placing the same conditional inside a controller or somewhere else.

wilk_randall left a reply on How To Create Good Json File

And what is your question?

wilk_randall left a reply on Laravel Roles

@richiesh It's hard to say why it's not showing up for you. It appears you're using https://github.com/spatie/laravel-permission but I could be wrong. If so, I think if you want to check for multiple roles in that method, you need to pass it an array, but from what you've shown it looks like you have a string of all the group names, so the method is thinking you're only checking for one and and that the role's name is Group1,Group2,Group3,Group4.

If that's the case, it looks like you would just need to convert that string to an array and then pass that into the hasAnyRole function.

@if (auth()->user()->hasAnyRole(explode(',', $page->permissions))
     Test
@endif

wilk_randall left a reply on Laravel Roles

Try writing your conditional like this instead:

@if(auth()->user()->hasAnyRole($page->permissions))
Test
@endif

You don't need the {!! when you're in a blade directive.

18 Mar
4 days ago

wilk_randall left a reply on How Can I Rename Column In Laravel Using Migration?

@jlrdw not by default, you have to pull it in manually

wilk_randall left a reply on How To Change Http://127.0.0.1:8000/ Name Like App.dev

If you're on windows, I recommend using something like laragon, which allows you to do stuff like that right out of the box.

14 Mar
1 week ago

wilk_randall left a reply on How To Post Data To Laravel Using Ajax

@gathuku In your controller, do something like this:

foreach ($request->get('selected') as $id) {
     // do something with $id
}

Also, FYI you can do a dd for an ajax request and see the results in the network tab of your browser's dev tools. In my opinion it's easier to do it that way than using Log

wilk_randall left a reply on Vue Login Vs Standard Form

Replies like that are just ignorant. There's nothing wrong with using JavaScript to handle your forms if you're still using server side validation. It's not like you're connecting directly to the database from your client side scripts.

wilk_randall left a reply on Vue Login Vs Standard Form

I see no problem with it and actually do it myself on sites I build in laravel. I also think that using ajax provides a better user experience for most forms on a site.

I don't think there is any benefits necessarily from doing it either way. I think it's more of a matter of personal preference really.

wilk_randall left a reply on What Is The Difference This Form Action Link ?

@towhid it doesn't really matter which one you use

wilk_randall left a reply on How To Post Data To Laravel Using Ajax

Two things:

  1. For things like this, you don't need to use new Array(), instead use var selected = [];

  2. data should be an object, to try this instead: data: { selected: selected },

12 Mar
1 week ago

wilk_randall left a reply on Shortest Url

so style it then

wilk_randall left a reply on Shortest Url

Why does it matter how long the url is?

11 Mar
1 week ago

wilk_randall left a reply on Not Allow A User To Fill A Form Input Unless Previous Input Is Valid

If you use vue, this can be done pretty easily

<template>
     <form>
          <input v-model="field1">
          <input v-model="field2" :disabled="! field1">
          <input v-model="field3" :disabled="! field2">
    </form>
</template>

<script>
     export default {
           data () {
                return {
                      field1: null,
                      field2: null,
                      field3: null
                };
           }
     };
</script>

Obviously this is a pretty basic example, but that's pretty much all you would need to do for it.

wilk_randall left a reply on Add Captcha Dynamically On Login Failure

Why not just throttle the requests?

08 Mar
2 weeks ago

wilk_randall left a reply on Selecting Row Number 2

Sounds like a bad design to me if the id changes, just saying.

07 Mar
2 weeks ago

wilk_randall left a reply on Duel Roles

@jlrdw Hey, whatever works for you. I understand that access control definitely isn't a one size fits all kind of thing.

wilk_randall left a reply on Duel Roles

I usually use a pivot table and have many-to-many relationship between users and roles. It might be a little complex for your needs, but I often base just use https://github.com/spatie/laravel-permission for managing user access throughout the application.

wilk_randall left a reply on Base Url

@towhid That APP_URL is mostly for the console, tests and emails.

@davy_yg Are you serious? The documentation is right here... https://laravel.com/docs/5.8/urls

You can see the value if outputs by looking at the page source or doing a simple dd. I mean come on, this is just simple debugging and reading documentation...

06 Mar
2 weeks ago

wilk_randall left a reply on Completion Percentage Based On Time, Not On Quantity

I think it makes more sense the way it is by showing the percentage of videos you've completed in the series. Who cares how long each video is in terms of your completion percentage.

03 Mar
2 weeks ago

wilk_randall left a reply on How Can I Get Vue To Work Without The Defer Attribute?

Just remove the defer attribute? Kind of hard to help you with no code shown.

02 Mar
2 weeks ago

wilk_randall left a reply on How To Modify Laravel Auto-generated Authentification

@cronix My bad, I forgot Laravel uses the first route that is defined with that signature.

wilk_randall left a reply on How To Modify Laravel Auto-generated Authentification

@cronix Wouldn't the /login route you showed in your last example get overwritten by Auth::routes() since it's declared before them?

28 Feb
3 weeks ago

wilk_randall left a reply on Use @include For Components

If it's a component, typically you use @component to use it.

@component('textfield')
     @slot('name', 'email')
     @slot('type', 'email')
@endcomponent

Although, in your case you don't have a {{ $slot }} part, so include also makes sense to use. It's just up to you which way you want to write it.

https://laravel.com/docs/5.7/blade#components-and-slots

Also, check out this thread as well: https://stackoverflow.com/questions/44212318/laravel-blade-advantage-of-slot-component-vs-include

26 Feb
3 weeks ago

wilk_randall left a reply on How To Format Json Data In Laravel?

In your ajax function you have to json decode your result

$.ajax({
    url: '..',
    success: function (response) {
        response = JSON.parse(response);
        console.log(response);
    }
});
24 Feb
3 weeks ago

wilk_randall left a reply on The Correct Way To Structure Databases

With what you provided, I would give your forms table a user_id field with foreign key to it, and your fields table a form_id field with foreign key to it. I get where you're going with this, but the form is the one that really owns the field, not the user. When you pull the user's forms, each form will know how to retrieve its fields, so no other foreign keys are really necessary.

23 Feb
3 weeks ago

wilk_randall left a reply on Access Axios Data In Mounted

Your component isn't going to wait to mount until your ajax call is completed. Is there some specific reason you need to access those properties in mounted?

22 Feb
1 month ago

wilk_randall left a reply on How To Go In Infinite Foreach If There Is A Child

@skycoder Your getTree function is recursive, so yes it is what you need

wilk_randall left a reply on How To Go In Infinite Foreach If There Is A Child

@munazzil That does the exact same thing they already have. What @arukomp said is correct, a recursive function needs to be used.

19 Feb
1 month ago

wilk_randall left a reply on Pass Data From Blade To Vue.js

According to the code you have here, this.$el is going to refer to your <div class="container" id="like"> element. If you're going to use PHP to iterate through your records, you can pass the id through to the click event handler, like this:

<td><button v-on:click="whichId({{ $post->id}})"<img src="/images/heart.svg" width="30"></button></td>

In your script:

methods: {
    whichId (postId) {
          console.log(postId);
    }
}

wilk_randall left a reply on Please Suggest Me To Build A Filter Like Below Link

Are you not able to upgrade nova? The package says that it's part of the core now.

16 Feb
1 month ago

wilk_randall left a reply on Pdf In Laravel :(

Also FYI, you don't need to create multiple threads for the same question.

wilk_randall left a reply on Pdf In Laravel :(

You probably have to enter your view name like this:

$pdf = \PDF::loadView('orders.show', compact('order'));

wilk_randall left a reply on Pdf In Laravel :(

$pdf = \PDF::loadView('orders/show', compact('order'));
14 Feb
1 month ago

wilk_randall left a reply on Axios Access

Imports (I think) only work if you use a build tool like Webpack. If you're not doing that, I suggest following the link @snapey posted.

wilk_randall left a reply on Axios Access

You can place it in whatever file you need it. Once you import it, you can call it from wherever you need it.

wilk_randall left a reply on Axios Access

import axios from 'axios';

axios.post('/some/endpoint', { foo: 'bar' })
    .then(({ data }) => {
         // handle successful response
    })
    .catch(error => {
          // handle error
    });
13 Feb
1 month ago

wilk_randall left a reply on How To Guard A Model Attribute For Save()

@stationhead That's what the mutator is for; it prevents that value from ever being changed.

wilk_randall left a reply on How To Guard A Model Attribute For Save()

You can add it to $guarded if you ever mass assign fields to the model, and you could make a mutator on the model like this since you are using a database trigger to update it:

public function setPostCountAttribute($count)
{
      // retrieve current value
      $count = $this->attributes['post_count'];

      $this->attributes['post_count'] = $count;
}
10 Feb
1 month ago

wilk_randall left a reply on HTML After AddClass Color Not Change Untill Click Somewhere On Page

You could just use toggleClass instead of the unnecessary conditional.

$('.' + id).toggleClass('post-add-icon post-add-icon-liked');
08 Feb
1 month ago

wilk_randall left a reply on Validate Vue Object In Laravel Controller

If you're still passing the data to the controller as an array inside of urgent, then just do this:

Urgent::create($attributes['urgent']);

wilk_randall left a reply on Validate Vue Object In Laravel Controller

Well then if you're calling Urgent::create($attributes) it should create the model record correctly, unless you haven't provided those attributes in the model's $fillable array or just made $guarded = [] on the model.

wilk_randall left a reply on Validate Vue Object In Laravel Controller

What happens if you dd($attributes) in your controller?

wilk_randall left a reply on Validate Vue Object In Laravel Controller

Do you have those fields in $fillable on your model?

wilk_randall left a reply on Validate Vue Object In Laravel Controller

In your rules, try this:

'urgent.title' => 'required|min:5|max:24',
...

If you don't like doing that, then make the ajax request like this instead:

axios.post('/urgent', { ...this.urgent });

wilk_randall left a reply on Validate Vue Object In Laravel Controller

You're trying to validate on the data itself and not the request object. Try this instead:

$attributes = request()->validate([
     ...
]);