jbloomstrom

jbloomstrom

Programmer Analyst at Matanuska-Susitna Borough

Palmer

Member Since 3 Years Ago

Experience Points 95,605
Experience
Level
Lessons Completed 828
Lessons
Completed
Best Reply Awards 28
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.

27 Mar
8 months ago

jbloomstrom left a reply on Vue, Laravel, Echo Help

Do you have the Vue Devtools extension for Chrome? It's a huge help for these situations.

Can you inspect the data-project prop in the devtools extension. Does it have an id value? Is the project being passed to the TaskList component properly?

Are you remembering to pass the project object to the component?

Make sure you are passing it like this:

<task-list :data-project="project"></task-list>

or

<task-list v-bind:data-project="project"></task-list>

not

<task-list data-project="project"></task-list>

The last example will assign the literal string "project" to the prop value;

06 Feb
10 months ago
05 Feb
10 months ago

jbloomstrom left a reply on Need A Look At A Laravel 5.5 Feature Test

Check your $fillable or $guarded attribute on your Product model class.


class Product {

    protected $guarded = [];

    // or

    protected $fillable = [
        'title',
        'slug',
        'description'
    ];
}
18 Jan
10 months ago

jbloomstrom left a reply on Sort A Collection By A Relationship Value

Maybe you can manually sort the comments after you retrieve them from the database?

return $list->limit($limit)->get()->sortByDesc(function ($order,$key){
            return optional($order->orderContactNotes)->max('created_at');
        })
->transform( function($order) {
    $order->orderContactNotes = optional($order->orderContactNotes)->sortBy('created_at');
    return $order;
})
->values();

jbloomstrom left a reply on Sort A Collection By A Relationship Value

A couple things come to mind. First, I'm a bit unclear on what you're trying to accomplish. Can you post any errors or unexpected behavior that you are seeing?

I see that you are using limit in your query without specifying the order. That may give you unexpected behavior as the rows are not guaranteed to be in any particular order when they are returned from the database. In other words, you could perform the same query 100 times and get inconsistent results. See here for more about that.

jbloomstrom left a reply on Repositories

@omarsow94 Are you still getting the error? Can you post the rest of the stack trace from the error message and your ConversationRespository file?

17 Jan
10 months ago

jbloomstrom left a reply on Repositories

The error could be coming from a different file. Can you post the snippet from your laravel log that contains the full error message?

jbloomstrom left a reply on Repositories

Can you post the whole controller file?

jbloomstrom left a reply on Should A Controller Be Restricted To Creating/modifying Objects Specifically For That Model?

FWIW, when I am dealing with a resource that is a child of another resource (in your case database is a child of account) I like to be explicit with the scope of my controllers. For your example, I would have an AccountController for dealing with accounts, an AccountDatabaseController for dealing with databases that belong to a specific account, and maybe even a DatabaseController for dealing with all databases regardless of account (maybe for admin routes, etc.).

When you create your controller, you can specify a parent model to generate a nested (i.e. parent-child) resource controller. Like this:

php artisan make:controller AccountDatabaseController --parent="App\Account"

For your routes file, you can use "dot" notation like this to make nested routes:

Route::resource("accounts.databases", "AccountDatabaseController");

Hope that helps.

15 Jan
10 months ago

jbloomstrom left a reply on Problem Binding Vue Variable

@gabykant Did you check out the codepen? It seems to be working there. You may be getting a JS error, did you look at the browser console?

jbloomstrom left a reply on What Would You Choose? Firebase Or Pusher?

I like Pusher for its ease of use, but if you think you'll have more than 100 concurrent users you'll have to upgrade to one of their paid plans. Not sure if that influences your decision.

If you haven't ruled out socket.io as a possibility, this Laravel Echo Server is a great option - https://github.com/tlaverdure/laravel-echo-server.

jbloomstrom left a reply on Problem Binding Vue Variable

Perhaps Vue expects the option tags to have a value attribute?

<select v-model="test">
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="C">C</option>
</select>
<span>@{{test}}</span>
12 Dec
11 months ago

jbloomstrom left a reply on ERR_CONNECTION_REFUSED On Chrome But Not Firefox, Or Safari

Check your proxy settings in Chrome. Firefox can ignore system proxy settings, but Chrome uses the system proxy by default.

jbloomstrom left a reply on Best Practice - Local Environment And Production Environment

@zaster Snapey is correct. To avoid being surprised by a new, possibly incompatible version of a package I always run composer update in my dev environment and thoroughly vet the updates (e.g. run my test suite). I have composer install in my deployment script to ensure that only tested versions of packages end up in production. Hope this helps.

01 Dec
1 year ago

jbloomstrom left a reply on Losing This Scope While In Component Method.

You could also use es6 arrow syntax.

createToken() {
    console.log(this.stripeEmail);
    
    this.stripe.createToken(this.card).then( result => {
        if (result.error) {
            // Inform the user if there was an error
            var errorElement = document.getElementById('card-errors');
            errorElement.textContent = result.error.message;
        } else {
            // This should show the email now
            console.log(this.stripeEmail);
        }
    });
}
25 Oct
1 year ago

jbloomstrom left a reply on Data Tampering Prevention

You're right. I forgot to add the part for updating the middleware group. I've updated the answer.

jbloomstrom left a reply on Pagination Unavailable When Filter Function Is Used

Does it work without the filter() part?

jbloomstrom left a reply on Best Caching Solution?

Some things to consider. If you haven't already, try out your site with DebugBar. It can help reveal the cause of slowness (slow queries (caching will help), too many queries (eager loading could help), etc.). You can find it here. https://github.com/barryvdh/laravel-debugbar

For caching, I personally use Redis. It's pretty straightforward to get set up, and there are some helpful videos here to help you get started.

jbloomstrom left a reply on Pagination Unavailable When Filter Function Is Used

In your search method in the controller, the $prices variable is not defined anywhere.

jbloomstrom left a reply on VueJS Multi Language Inputs

Do you have any code you can share as a starting point?

jbloomstrom left a reply on Get All Entries Created At Specific Date

Consider querying all the deposits at once and then using a group function to group by day. It will ease the load on your database to do it all in one query. Like this:


// get all the deposits for the last month
$all_deposits = Deposit::where('created_at','>',Carbon::now()->subMonth())->get();

// now group by the created date
$all_deposits->groupBy( function($deposit) {
    return $deposit->created_at->format('Y-m-d');
});
16 Oct
1 year ago

jbloomstrom left a reply on DNS Issues With Nginx And .money TLD

OP seemed concerned about the time it took for propagation. I was simply sharing my experience.

13 Oct
1 year ago

jbloomstrom left a reply on Passing Data To Components

Friendly tip, you're more likely to get replies if you wrap your code blocks with 3 backticks



jbloomstrom left a reply on DNS Issues With Nginx And .money TLD

FWIW, I have been using Route53 to host my DNS for some time now. Propagation takes mere minutes usually.

10 Oct
1 year ago

jbloomstrom left a reply on Data Tampering Prevention

The approach I typically take is to make the id part of the API endpoint.

// routes/api.php
Route::delete("posts/{id}", "[email protected]");

Then protect your API routes with the api middleware to make sure only logged in users can access those routes.

// RouteServiceProvider.php
...
   /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }

Then use a Policy to see if the user is allowed to perform the operation on the given post. https://laravel.com/docs/5.5/authorization

// PostPolicy.php

...
   /**
     * Determine if the given post can be deleted by the user.
     *
     * @param  \App\User  $user
     * @param  \App\Post  $post
     * @return bool
     */
    public function delete(User $user, Post $post)
    {
        return $user->id === $post->user_id;
    }
28 Sep
1 year ago

jbloomstrom left a reply on Relationship Properties Are Not Visible?!

if you want to always return the children, you can set the $with property on the model.


// Category.php

class Category extends Model {

    ...
    protected $with = [
        'children'
    ];
    ...
}

Or if you want to get deeply nested relationships, you can use dot notation:


// Category.php

class Category extends Model {

    ...
    protected $with = [
        'children.children.children.children' // will get children 4 layers deep
    ];
    ...
}

jbloomstrom left a reply on How Can I Session-out & Logout - When IP Address Is Changed ?

I would add a last_known_ip column to my user model. I would then make a custom middleware that compares the current ip to the last_known_ip. If they match, then proceed, else destroy session and logout.

function getRealUserIp(){
    switch(true){
      case (!empty($_SERVER['HTTP_X_REAL_IP'])) : return $_SERVER['HTTP_X_REAL_IP'];
      case (!empty($_SERVER['HTTP_CLIENT_IP'])) : return $_SERVER['HTTP_CLIENT_IP'];
      case (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) : return $_SERVER['HTTP_X_FORWARDED_FOR'];
      default : return $_SERVER['REMOTE_ADDR'];
    }
 }

jbloomstrom left a reply on Relationship Properties Are Not Visible?!

Can you post your migration too? In short, you want to store the parent_id on the category model, not the children.

class Category extends Model {
    ...
    protected $fillable = [
        'name',
        'parent_id'
    ];
    ...
}

// migration

    Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
        $table->string('name');
        $table->unsignedInteger('parent_id')->nullable();
            $table->timestamps();
    });

jbloomstrom left a reply on Laravel API

I wouldn't have users pass their password in the request url. I would instead look at using api tokens. Here is a good article to get you started if you don't want to use passport. https://gistlog.co/JacobBennett/090369fbab0b31130b51

26 Sep
1 year ago

jbloomstrom left a reply on Compile JavaScript To IE11 (ES5?)

@EmilMoe Laravel Mix does this automatically when you call mix.js(...).

21 Sep
1 year ago

jbloomstrom left a reply on Inject Content In Component From Other Component

This is my preferred method of communicating between Vue components. Check out the global event bus pattern. https://alligator.io/vuejs/global-event-bus/

jbloomstrom left a reply on Vue Connecting To Laravel API

This is a common error. It's called CORS - Cross-Origin Resource Sharing. It's blocked by most servers as a security feature and has to be explicitly allowed to avoid getting the error. This package can help you get Laravel configured to allow it. https://github.com/barryvdh/laravel-cors

jbloomstrom left a reply on How Do I Pass A Variable Of Data From One File To Another File?

The best way that I have found to communicate between components is to use a "Bus" instance of Vue. Then you Bus.$emit an event from one component and Bus.$on listen for it on another component. https://alligator.io/vuejs/global-event-bus/


// app.js
...
window.Bus = new Vue();
...

// product.vue

...

methods : {
    updateCart() {
        Bus.$emit('UpdateCartData', { payload : { SOME_DATA_HERE } });
    }
},

...

// header.vue
...

mounted() {
    this.listen();
},

methods : {
    listen() {
        Bus.$on('UpdateCartData', (event) => {
            this.update(event.payload);
        });
    }
}
...

jbloomstrom left a reply on Use Bolean In Computed

You don't need to create a custom accessor just to cast to a boolean, you can use the $casts property on the model.

// your <model>.php file
...

protected $casts = [
    'published' => 'bool',
];
...

jbloomstrom left a reply on Shift Time Calculation Based On Given Times

Have you looked at Carbon? It has tons of useful methods for calculating the difference between dates. Also are you able to access a full datetime for these calculations?

$start = Carbon::parse('2017-09-21 08:00:00');
$finish = Carbon::parse('2017-09-21 17:00:00');

$finish->diff($start)->format('%H:%I:%S');
// 09:00:00

jbloomstrom left a reply on What Are You Working On ?

My latest project is (AdGoalie)[https://adgoalie.com] a simple web filtering service. It's a relatively simple project built on Spark, but I believe it has promise.

14 Aug
1 year ago

jbloomstrom left a reply on What Are You Working On ?

@Snapey RotaRota looks awesome, but it looks like you missed a word in your "About" section.

RotaRota is a site to enable organisations [to] coordinate the efforts of their volunteers
``  

Keep up the good work.
08 Aug
1 year ago

jbloomstrom left a reply on Laravel Not Reading .env File In Homestead

I just went through this. Look in your ~/.bashrc file. Mine had a line that set the environment to local.

jbloomstrom left a reply on Data Elements Not Getting Set

Can you post the whole component?

jbloomstrom left a reply on "ReferenceError: Flash() Is Not Defined" Even Though It Is

I have this in my app.js. I can then do flash.success('It works.') or flash.danger('Oops. There was a problem')

// app.js
...

// flash messaging
window.flash = {
    success(message) {
        Bus.$emit('flash', { message, type : 'success' } );
    },

    warning(message) {
        Bus.$emit('flash', { message, type : 'warning' } );
    },

    danger(message) {
        Bus.$emit('flash', { message, type : 'danger' } );
    },

    error(message) {
        Bus.$emit('flash', { message, type : 'danger' } );
    },

    notify(message) {
        Bus.$emit('flash', {message, type : 'notify'});
    }
}
...
23 Jun
1 year ago
05 Jun
1 year ago

jbloomstrom left a reply on Laravel Mix Won't Run On A Fresh Install

A couple questions.

  1. Where did you run npm install from? Windows or Homestead VM?
  2. Where did you run npm run dev from?

jbloomstrom left a reply on Testing A New Package: "Class Not Found" Error

I suspect it's failing to resolve the relative path. What if you use an absolute reference like this?


<?php
namespace MyName\MyPackage\Test;

//  use full absolute path
use \MyName\MyPackage\MyPackageClass;

...

jbloomstrom left a reply on Component Property Not Defined When Iterating Posts

Can you post your Post.vue? I suspect you need to add a post prop.


// Post.vue

...

props : [ 'post', ... ]

...