jbloomstrom

Programmer Analyst at Matanuska-Susitna Borough

Experience

95,255

28 Best Reply Awards

  • Member Since 3 Years Ago
  • 825 Lessons Completed
  • 7 Favorites

27th March, 2018

jbloomstrom left a reply on Vue, Laravel, Echo Help • 6 months ago

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;

6th February, 2018

jbloomstrom left a reply on Need A Look At A Laravel 5.5 Feature Test • 8 months ago

@Kirk.Franklin Happy to help!

5th February, 2018

jbloomstrom left a reply on Need A Look At A Laravel 5.5 Feature Test • 8 months ago

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


class Product {

    protected $guarded = [];

    // or

    protected $fillable = [
        'title',
        'slug',
        'description'
    ];
}

18th January, 2018

jbloomstrom left a reply on Sort A Collection By A Relationship Value • 9 months ago

@Roni Happy to help!

jbloomstrom left a reply on Sort A Collection By A Relationship Value • 9 months ago

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 • 9 months ago

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 • 9 months ago

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

17th January, 2018

jbloomstrom left a reply on Repositories • 9 months ago

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 • 9 months ago

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? • 9 months ago

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.

15th January, 2018

jbloomstrom left a reply on Problem Binding Vue Variable • 9 months ago

@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? • 9 months ago

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 • 9 months ago

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>

12th January, 2018

12th December, 2017

jbloomstrom left a reply on ERR_CONNECTION_REFUSED On Chrome But Not Firefox, Or Safari • 10 months ago

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 • 10 months ago

@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.

1st December, 2017

jbloomstrom left a reply on Losing This Scope While In Component Method. • 10 months ago

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);
        }
    });
}

25th October, 2017

jbloomstrom left a reply on Data Tampering Prevention • 11 months ago

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 • 11 months ago

Does it work without the filter() part?

jbloomstrom left a reply on Best Caching Solution? • 11 months ago

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 • 11 months ago

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

jbloomstrom left a reply on Import Excel File To Database With Mapping Each Field Dynamicaly • 11 months ago

FYI, PHP has a native function for parsing CSV to Array.

http://php.net/manual/en/function.str-getcsv.php

jbloomstrom left a reply on VueJS Multi Language Inputs • 11 months ago

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

jbloomstrom left a reply on Get All Entries Created At Specific Date • 11 months ago

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');
});

16th October, 2017

jbloomstrom left a reply on DNS Issues With Nginx And .money TLD • 1 year ago

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

13th October, 2017

jbloomstrom left a reply on Passing Data To Components • 1 year ago

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 • 1 year ago

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

10th October, 2017

jbloomstrom left a reply on Data Tampering Prevention • 1 year ago

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;
    }

28th September, 2017

jbloomstrom left a reply on Relationship Properties Are Not Visible?! • 1 year ago

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 ? • 1 year ago

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?! • 1 year ago

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 • 1 year ago

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

26th September, 2017

jbloomstrom left a reply on Compile JavaScript To IE11 (ES5?) • 1 year ago

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

22nd September, 2017

jbloomstrom left a reply on Vue And Passing Account_id With Axios • 1 year ago

No need to reinvent the wheel. Check out http://hashids.org/

21st September, 2017

jbloomstrom left a reply on Inject Content In Component From Other Component • 1 year ago

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 • 1 year ago

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? • 1 year ago

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 • 1 year ago

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 • 1 year ago

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 ? • 1 year ago

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.

14th August, 2017

jbloomstrom left a reply on What Are You Working On ? • 1 year ago

@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.

8th August, 2017

jbloomstrom left a reply on Laravel Not Reading .env File In Homestead • 1 year ago

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 • 1 year ago

Can you post the whole component?

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

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'});
    }
}
...

23rd June, 2017

jbloomstrom left a reply on Laravel Mix Tons Of Errors • 1 year ago

@wjamyers Happy to help!

5th June, 2017

jbloomstrom left a reply on Laravel Mix Won't Run On A Fresh Install • 1 year ago

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 • 1 year ago

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 • 1 year ago

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


// Post.vue

...

props : [ 'post', ... ]

...

Edit Your Profile
Update

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