Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

jbloomstrom

jbloomstrom

Programmer Analyst at Matanuska-Susitna Borough

Member Since 5 Years Ago

Palmer

Experience Points
173,865
Total
Experience

1,135 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
1453
Lessons
Completed
Best Reply Awards
47
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 35
173,865 XP
Aug
05
3 months ago
Activity icon

Replied to Should I Have One Address Table Or Two?

I let the data model inform my database design choices. To create the model, I start with the nouns (the entities, objects, whatever you want to call them) -- these are the tables. It sounds like you have Realtors, Customers, and Locations.

Attributes of the nouns (e.g. a Customer's name, a Location's address) -- these are the columns. For your purposes, does a billing address seem like its own thing or just an attribute of a customer? One way to tell is by asking, "Can a customer have multiple billing addresses?" If yes, then you have a many-to-one relationship and Billing Addresses can be a table of its own. If not, then its probably sufficient to leave billing address details in the Customers table.

This is only one way to look at it. But I find it helpful to think about the data model in the abstract before making it concrete in the database design.

Jul
30
3 months ago
Activity icon

Awarded Best Reply on <x-slot> Usage In Blade Component Cookbook

Slots pass markup into a component. x-slot allows you to define named slots.

You may define the content of the named slot using the x-slot tag. Any content not within a x-slot tag will be passed to the component in the $slot variable:

https://laravel.com/docs/7.x/blade#slots

Activity icon

Replied to Select Statement Column Cast String To Integer

Maybe a custom accessor?

https://laravel.com/docs/7.x/eloquent-mutators#defining-an-accessor

// Student Model

protected $appends = [
  'subject5_number',
];

public function getSubject5NumberAttribute() {
  return (int) $this->subjects->subject5_number;
}
Activity icon

Replied to Store Image In DB

Could be a mass assignment issue on the Photo model. Did you set up your $fillable fields or unguard the model?

https://laravel.com/docs/7.x/eloquent#mass-assignment

Activity icon

Replied to API Resource: Using Count() With WhenLoaded()

I would look at using the withCount method. It's a trivial db query to get the count this way.

https://laravel.com/docs/7.x/eloquent-relationships#counting-related-models

Activity icon

Replied to Generate Dynamic Routes, But Keep Auth

Routes are resolved in the order that they are listed, so it could be as simple as moving Auth::routes() to the top of your routes file.

If that doesn't work, can you post the contents of your routes file?

Activity icon

Replied to <x-slot> Usage In Blade Component Cookbook

Slots pass markup into a component. x-slot allows you to define named slots.

You may define the content of the named slot using the x-slot tag. Any content not within a x-slot tag will be passed to the component in the $slot variable:

https://laravel.com/docs/7.x/blade#slots

Jul
29
3 months ago
Activity icon

Awarded Best Reply on VueJS Mutiple File Uploads

There are a couple really nice JS packages that you could look into that integrate nicely with Vue.

https://www.dropzonejs.com/

https://github.com/pqina/filepond

Jul
28
3 months ago
Activity icon

Replied to Need JS Advice: How To DYNAMICALLY Present Catgories In A View

Vue.js won't conflict with your jQuery or other JS. It may be overkill if you are just looking to do something simple though. Maybe check out Alpine.js.

https://github.com/alpinejs/alpine

Activity icon

Replied to VueJS Mutiple File Uploads

There are a couple really nice JS packages that you could look into that integrate nicely with Vue.

https://www.dropzonejs.com/

https://github.com/pqina/filepond

Activity icon

Replied to Need JS Advice: How To DYNAMICALLY Present Catgories In A View

I would use Vue.js for this. There is a free series here on Laracasts if you aren't familiar with it.

https://laracasts.com/series/learn-vue-2-step-by-step

Activity icon

Replied to SQLSTATE[HY000]: General Error: 1364 Field 'sliders' Doesn't Have A Default Value

Could be a mass assignment issue. Check your $guarded or $fillable property on your model.

// your model

protected $guarded = [];

// or 

protected $fillable = [
  // ... your other fillable fields
  'sliders',
];

https://laravel.com/docs/7.x/eloquent#mass-assignment

Activity icon

Awarded Best Reply on Polymorphic Relationship Returns Object.

If you're API endpoint is returning an object, it could be the result of using filter, reject, sort, etc on a collection. By default, the original keys are preserved unless you chain ->values() at the end of your collection pipeline.

See it in action here: https://laravelplayground.com/#/snippets/97464c16-ee1e-4589-a01b-8a3284aaf22c

(edit). Sorry, I didn't see your controller code at first.

success: function (data) {

  $('input[name="email"]').val('');

  $('select[name="contact_id"]').empty();

  $('select[name="contact_id"]').append('<option value="Choose">Choose Contact</option>');

  $.each(data, function (index, model) {

    $('select[name="contact_id"]')
      .append('<option value="' + model.id+ '">' + model.name + '</option>');

  });
},
Jul
27
3 months ago
Activity icon

Started a new Conversation Indicate "Scheduled" Lessons In The Feed

It's a small thing, but it would be nice if lessons that are in "scheduled" or "coming soon" status would be marked as such in the feed and search results--maybe with a little flair or badge.

Or if there was an additional filter in the search options to hide unpublished lessons, that would work too.

Thanks.

Activity icon

Replied to Polymorphic Relationship Returns Object.

If you're API endpoint is returning an object, it could be the result of using filter, reject, sort, etc on a collection. By default, the original keys are preserved unless you chain ->values() at the end of your collection pipeline.

See it in action here: https://laravelplayground.com/#/snippets/97464c16-ee1e-4589-a01b-8a3284aaf22c

(edit). Sorry, I didn't see your controller code at first.

success: function (data) {

  $('input[name="email"]').val('');

  $('select[name="contact_id"]').empty();

  $('select[name="contact_id"]').append('<option value="Choose">Choose Contact</option>');

  $.each(data, function (index, model) {

    $('select[name="contact_id"]')
      .append('<option value="' + model.id+ '">' + model.name + '</option>');

  });
},
Activity icon

Replied to Unable To Resolve NULL Driver For [Illuminate\Mail\TransportManager]

I was getting the same error. Are you by chance using this package to inline your mail css?

https://github.com/fedeisas/laravel-mail-css-inliner

The error was caused by the service provider in the package.

There is an open PR for the issue here: https://github.com/fedeisas/laravel-mail-css-inliner/pull/90

Jul
25
4 months ago
Activity icon

Awarded Best Reply on Blocking A Multi-origin Request (Cross-Origin Request)

I suggest reading up on CORS (Cross-Origin Resource Sharing). Browsers block CORS requests by default as they could present a security risk. Developers must explicitly allow CORS requests at the server level to avoid getting blocked by the user's browser.

With Laravel, you could accomplish this by editing your Apache config to set the appropriate headers in the return response, but the easiest way I have found is to just use a middleware to handle it automatically.

See https://github.com/fruitcake/laravel-cors

Jul
24
4 months ago
Activity icon

Awarded Best Reply on Write A Migration Where A Column Checks Multiple Columns For A Unique Value?

If Column A is unique and Column B is unique, then the combination of A+B will always be unique. You don't need to add further checks.

Edit. Sorry, it took me a while to catch on. You want to make sure values in A will never be repeated in A or B and vice versa. It is possible at the database layer, but not with a UNIQUE constraint (which only works on one column). You would have to use a CHECK constraint on your table, which may or may not be supported by your particular database.

https://www.w3schools.com/sql/sql_check.asp

Jul
23
4 months ago
Activity icon

Replied to Laravel 7 Resource Controller Edit & Update Example With FormRequest??

https://laravel.com/docs/7.x/views#passing-data-to-views

public function edit(Book $book){ 
    return view('books.edit', compact('book'));	
}

or

public function edit(Book $book){ 
    return view('books.edit')->with('book',$book);	
}

https://laravel.com/docs/7.x/helpers#method-route

public function testEditSuccess() {
    // Set up database as necessary...
    // Get the Book to be edited, or maybe its ID?
    // Then:

    $response = $this->get(route('books.edit', ['id' => 1]));
    // Check the response...
}
Activity icon

Replied to Write A Migration Where A Column Checks Multiple Columns For A Unique Value?

If Column A is unique and Column B is unique, then the combination of A+B will always be unique. You don't need to add further checks.

Edit. Sorry, it took me a while to catch on. You want to make sure values in A will never be repeated in A or B and vice versa. It is possible at the database layer, but not with a UNIQUE constraint (which only works on one column). You would have to use a CHECK constraint on your table, which may or may not be supported by your particular database.

https://www.w3schools.com/sql/sql_check.asp

Activity icon

Replied to Queue Worker Only Processes 2 Jobs Then Stops

Logging is configured in the config file config/logging.php. The default logging destination is storage/logs/laravel.log.

https://laravel.com/docs/7.x/logging

You can test jobs by running them synchronously from php artisan tinker and watching for errors (or PHP running out of memory).

e.g.

php artisan tinker

# tinker
App\Jobs\YourJob::dispatchNow($arg1, $arg2);

https://laravel.com/docs/7.x/queues#synchronous-dispatching

Activity icon

Replied to Queue Worker Only Processes 2 Jobs Then Stops

Have you reviewed the logs for exceptions? I have had this happen to me where some part of my app threw an exception and it crashed my queue worker.

I have also seen it when PHP ran out of memory, so maybe check your php configuration. If your jobs are memory intensive, consider splitting the work into multiple jobs.

Jul
22
4 months ago
Activity icon

Replied to Laravel-echo-server Not Working In Server

@danlog Check the config in laravel-echo-server.json, by default it will use http and port 6001. If you use https it has additional config options to specify the ssl cert and key files.

Activity icon

Awarded Best Reply on Laravel Totem Cron Task Manager Is Unable To Read Env File

Use config files, that's the only thing that should be reading from .env.

https://laravel.com/docs/7.x/configuration

(edit) Here is a bit of explanation. https://andy-carter.com/blog/env-gotcha-in-laravel-when-caching-configuration

tldr: When the config is cached, Laravel will not read in new values from .env.

Activity icon

Replied to Blocking A Multi-origin Request (Cross-Origin Request)

I suggest reading up on CORS (Cross-Origin Resource Sharing). Browsers block CORS requests by default as they could present a security risk. Developers must explicitly allow CORS requests at the server level to avoid getting blocked by the user's browser.

With Laravel, you could accomplish this by editing your Apache config to set the appropriate headers in the return response, but the easiest way I have found is to just use a middleware to handle it automatically.

See https://github.com/fruitcake/laravel-cors

Activity icon

Replied to Laravel Totem Cron Task Manager Is Unable To Read Env File

Use config files, that's the only thing that should be reading from .env.

https://laravel.com/docs/7.x/configuration

(edit) Here is a bit of explanation. https://andy-carter.com/blog/env-gotcha-in-laravel-when-caching-configuration

tldr: When the config is cached, Laravel will not read in new values from .env.

Activity icon

Replied to Write A Migration Where A Column Checks Multiple Columns For A Unique Value?

You only want the combination of student_code and chaperone_code to be unique, not to make the individual columns unique.

$table->string('student_code');
$table->string('chaperone_code');
$table->unique(['chaperone_code', 'student_code']);
Activity icon

Replied to Laravel-echo-server Not Working In Server

Hard to say without knowing more details, but have you opened the appropriate ports in the server firewall?

(edit): Network tab on the Server Details page. Unless you have changed it from the defaults, it should be TCP 6001 for http and TCP 6002 for https.

Activity icon

Commented on Testing With HTTP Fakes And Livewire

It's a small thing, but it would be nice if lessons that are in "scheduled" or "coming soon" status would be marked as such in the feed and search results--maybe with a little flair or badge. I was excited when I saw 3 new lessons in the feed, but then a little disappointed when 2 of them were not ready yet. Again, it's small thing.

Jun
03
5 months ago
Activity icon

Replied to Resizing An Avatar From FB Using Socialite/intervention

Not too familiar with Intervention, but it looks like you are forgetting to save, so the changes are happening in memory but not persisting to disk.

$tempPath = storage_path("temp"); // change this to reflect your preference for the temp image.

$resizedImg = Image::make($profile_pic)->fit(500, 500)->save($tempPath);

Storage::disk('s3')->put($path, $tempPath, 'public');
Activity icon

Replied to Calling Stripe's Javascript APIs From PHPUnit?

I'll just add that there is a reason there is not a "backend" way of doing it. In 99.999% of cases you do not want customer credit card data hitting your backend server for Payment Card Industry (PCI) compliance reasons, which is a bigger topic than can be addressed in a forum post. Suffice it to say, it brings your server and everything on the same network into "scope" and thus requires compliance.

This is why getting the payment token is handled in JavaScript on the user side. The user's browser sends the credit card data directly to Stripe's server and thus Stripe takes on the burden of PCI compliance.

I understand this is for testing and you may already be aware of all this, but it may be useful to anyone else who is curious.

Some light reading if you want more: https://stripe.com/guides/pci-compliance

Activity icon

Awarded Best Reply on Collection Merge

What you're looking for is union. https://laravel.com/docs/7.x/collections#method-union

It works by comparing keys, so you'll want to group each collection by date first.


$collection1 = collect([
    ['date' => '2020-06-03','requested1' => 'a', 'requested2' => 'b'],
    ['date' => '2020-06-04','requested1' => 'c', 'requested2' => 'd'],
    ['date' => '2020-06-05','requested1' => 'e', 'requested2' => 'f'],
])->groupBy('date');


$collection2 = collect([
    ['date' => '2020-06-05','requested1' => 'g', 'requested2' => 'h'],
    ['date' => '2020-06-06','requested1' => 'i', 'requested2' => 'j'],
    ['date' => '2020-06-07','requested1' => 'k', 'requested2' => 'l'],
])->groupBy('date');

// if a key is found in both collections, 
// the value from collection1 will be used
$merged = $collection1->union($collection2)->values()->collapse();

/*

Illuminate\Support\Collection {#1211
     all: [
       [
         "date" => "2020-06-03",
         "requested1" => "a",
         "requested2" => "b",
       ],
       [
         "date" => "2020-06-04",
         "requested1" => "c",
         "requested2" => "d",
       ],
       [
         "date" => "2020-06-05",
         "requested1" => "e",
         "requested2" => "f",
       ],
       [
         "date" => "2020-06-06",
         "requested1" => "i",
         "requested2" => "j",
       ],
       [
         "date" => "2020-06-07",
         "requested1" => "k",
         "requested2" => "l",
       ],
     ],
   }

*/


Activity icon

Replied to Collection Merge

If you're getting the original rather than duplicate then reverse the order of the operation.

e.g. instead of

$original->union($duplicate);

use

$duplicate->union($original);
Activity icon

Replied to Collection Merge

What you're looking for is union. https://laravel.com/docs/7.x/collections#method-union

It works by comparing keys, so you'll want to group each collection by date first.


$collection1 = collect([
    ['date' => '2020-06-03','requested1' => 'a', 'requested2' => 'b'],
    ['date' => '2020-06-04','requested1' => 'c', 'requested2' => 'd'],
    ['date' => '2020-06-05','requested1' => 'e', 'requested2' => 'f'],
])->groupBy('date');


$collection2 = collect([
    ['date' => '2020-06-05','requested1' => 'g', 'requested2' => 'h'],
    ['date' => '2020-06-06','requested1' => 'i', 'requested2' => 'j'],
    ['date' => '2020-06-07','requested1' => 'k', 'requested2' => 'l'],
])->groupBy('date');

// if a key is found in both collections, 
// the value from collection1 will be used
$merged = $collection1->union($collection2)->values()->collapse();

/*

Illuminate\Support\Collection {#1211
     all: [
       [
         "date" => "2020-06-03",
         "requested1" => "a",
         "requested2" => "b",
       ],
       [
         "date" => "2020-06-04",
         "requested1" => "c",
         "requested2" => "d",
       ],
       [
         "date" => "2020-06-05",
         "requested1" => "e",
         "requested2" => "f",
       ],
       [
         "date" => "2020-06-06",
         "requested1" => "i",
         "requested2" => "j",
       ],
       [
         "date" => "2020-06-07",
         "requested1" => "k",
         "requested2" => "l",
       ],
     ],
   }

*/