alexandersix

alexandersix

Member Since 3 Years Ago

Columbia, SC

Full-Stack Web Developer at Self-Employed

Experience Points 9,360
Experience Level 2

640 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 92
Lessons
Completed
Best Reply Awards 0
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.

24 Jul
11 months ago

alexandersix started a new conversation Problem With Laravel Policies & Models

I am currently working on implementing Policies into my application, and I'm working on a policy for the User::show method.

I put a method on my User model called isAdmin() (it does what it says on the tin), and I'm trying to call it within my UserPolicy's view() method, but I'm getting a BadMethodCallException (Method Illuminate\Database\Query\Builder::isAdmin does not exist.)

Is there something I'm missing that is causing my Policy's User $user parameter to be a Builder object instead of a User Model object? I'll paste my code below for reference!

// UserPolicy.php:
class UserPolicy
{
    use HandlesAuthorization;

    /**
     * Determine whether the user can view the model.
     *
     * @param  \App\User  $user
     * @param  \App\User  $model
     * @return mixed
     */
    public function view(User $user, User $model)
    {
        $current_user = User::find($id); // I added this just in case I needed to retrieve the model from the DB

        return ($current_user->isAdmin()) || ($current_user->isInterviewer()) || $user->id === $model->id;
    }
}

// User.php
class User extends Authenticatable
{
    use HasApiTokens, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'first_name', 'last_name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * Checks to see if the current user is an Interviewer
     *
     * @return boolean
     */
    private function isInterviewer() : bool
    {
        return $this->role_mask & 2;
    }

    /**
     * Checks to see if the current user is an Admin
     *
     * @return boolean
     */
    private function isAdmin() : bool
    {
        return $this->role_mask & 1;
    }
}

Thanks!

06 Jul
2 years ago

alexandersix left a reply on Vue Says My Property Isn't Defined, But I Think It Is...?

@bunnypro Ah, I didn't even think to include that--yes, it IS showing up in my Vue Devtools with the correct key.

@vapenation We've already tried that.

alexandersix left a reply on Vue Says My Property Isn't Defined, But I Think It Is...?

@jimmck I tried that and it also didn't work. Also, for the past 3 or so Laravel/Vue projects that I've done, I've never had to put a data object as the value of the key "data" inside the Vue data object--I generally can just put my variables inside the Vue data object. I'm not sure if I'm understanding you correctly though.

05 Jul
2 years ago

alexandersix left a reply on Vue Says My Property Isn't Defined, But I Think It Is...?

@MaverickChan The word "data" can be used as a variable outside of the Vue instance from what I understand from the docs. Changing it had no effect.

@jimmick The data that I have inside my Vue object IS an object. I've tried instantiating it as an object outside the Vue instance and inside both as a global and local variable. I haven't found a working combination in that.

I really don't think it's a problem with the Vue install or anything, because I spun up a new Laravel install and got everything working right off the bat, so I'm not really sure what the problem was. I'll keep searching and post here if I find an answer.

alexandersix left a reply on Vue Says My Property Isn't Defined, But I Think It Is...?

@alenabdula Yeah, that's why I finally decided to come here and see if anyone had any ideas--I think it's something with the way that Laravel is handling it (not necessarily something that was written into the framework, most likely something that I've done wrong haha).

That code doesn't work for some reason, and I'm very not sure as to why.

alexandersix left a reply on Vue Says My Property Isn't Defined, But I Think It Is...?

@jaydeluca That also didn't work, sadly. This isn't a Vue component, just a regular old instance of Vue, so I don't think data() is correct. I believe that you use data() only when you're creating a template, since the data has to be rendered dynamically as the component is rendered. Could very well be wrong about that though haha. Either way, still no dice. ?

alexandersix left a reply on Vue Says My Property Isn't Defined, But I Think It Is...?

@alenabdula Sadly that didn't do it. It DID hide the h1 though, so "blah" is coming back falsey.

alexandersix started a new conversation Vue Says My Property Isn't Defined, But I Think It Is...?

Ok, so I've hit a roadblock and was hoping someone here could lend a hand at figuring out what I'm missing!

I've installed a fresh install of Laravel 5.4 and I'm trying to just simply print out some data from the included VueJS instance in app.js (included below), but I keep getting the "property is referenced but not defined" error. Any chance someone sees my mistake? I think I've been staring at it for too long to find it!

Here's app.js

require('./bootstrap');
window.Vue = require('vue');

Vue.component('example', require('./components/Example.vue'));

var data = {
    blah: 'Hello World!',
}

const app = new Vue({
    el: '#app',
    data: data,
});

And here's app.blade.php

<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name') }}</title>

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    {{-- <link href="https://fonts.googleapis.com/css?family=Tangerine:400,700" rel="stylesheet"> --}}
</head>
<body>
    <div>
        

        <div id="app">
            @yield('content')
        </div>
        
    </div>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}"></script>
    
    @yield('scripts')
</body>
</html>

And finally, here's my partial, people.blade.php:

@extends('layouts.app')

@section('content')
    <section class="hero is-info is-large">
        <div class="hero-body">
            <div class="container">
                <h1 class="title">People: @{{ blah }}</h1>
            </div>
        </div>
    </section>

    <example></example>

    
@endsection

@section('scripts')
    <script>

    </script>
@endsection

One more thing to note--the instance is definitely being loaded, because the included Example.vue component works fine!

Thanks in advance for the help!