Categories
Fixing Stuff Laravel Samuel

Update Laravel Column To Allow NULLABLE Entries

We had a client request today that 2 fields on their user creation page be updated to allow for NULL entries. Once we updated the site to Laravel 5.6 the new stricter settings were throwing errors with these blank input fields. Luckily in our case both columns did not have any data in them, so this made our change relatively straightforward. Jumping into it we first created new migrations for both columns:

//Update column to allow null entries

/**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('historical_overtime', 32)->nullable()->after('shift_code');;

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('historical_overtime');
        });
    }

From Here we pulled up phpMyAdmin and dropped our old columns using the code:

ALTER TABLE users DROP COLUMN middle_name;
ALTER TABLE users DROP COLUMN historical_overtime;

We then deployed our new migration files to our the live server, ran them to install the new DB columns and away goes our error. For future reference the error code we fixed with this is:

SQLSTATE[2300]: Integrity constraint violation: 1048 Column 'middle_name' cannot be null

If the DB columns would have had information in them, instead of deleting them we could have updated them using the code below:

public function up()
{
    Schema::table('users', function (Blueprint $table) {
        // change() tells the Schema builder that we are altering a table
        $table->integer('middle_name')->unsigned()->nullable()->change();
    });
}
Categories
Fixing Stuff Laravel Samuel

Laravel – Sorting A Date Time Column By Month/Day and Excluding Year

We had an interesting request come in from a client today. They have a big list of user birthdays that they want to display on the front end of the ir employee intranet site. In order to protect employees actual age they only want the month and day of the employees birthday to show, that way people can essentially wish them happy birthday but not know their true age. In essence the client wanted a list of birthdays like this:

Employee 1 12/1
Employee 2 12/4
Employee 3 12/5

To add a little complexity to this task the client wanted us to sort the birthdays by day so that they were listed in chronological order. Sorting this list is pretty easy with the orderBy command, this is what we came up with first:

$birthdays = User::where('birth_month', $current_month)->where('active', 1)->orderBy('birthdate', 'asc')->get();

The issue we ran into with the code above is that it sorted by year, then day. Even though we are not showing the year on the front end, it is still saved in the database as a full date/time string of day-month-year. The code above ended up giving us a list like this:

Employee 1 12/4/1990
Employee 2 12/1/1992
Employee 3 12/5/1992

Any employees who had the same birth year were grouped together and then sorted by date. To fix this we had to change from orderBy to orderByRaw. In practice the code we ended up using looks like this:

$birthdays = User::where('birth_month', $current_month)->where('active', 1)
->whereMonth('birthdate', $current_month)
->orderByRaw('DATE_FORMAT(birthdate, "%m-%d")')
->get();

The code above ended up working perfectly for the client. You will see that the orderByRaw code above uses the m-d portion of the date/time string but it does not use the year portion. With this code we are left with a list like this:

Employee 1 12/1/1992
Employee 2 12/4/1990
Employee 3 12/5/1992

Categories
Fixing Stuff Samuel

Fixing A Samsung Twin Cooling Fridge That Is Leaking

This post is a step by step guide for fixing a samsung fridge that is leaking water. In my case water was leaking down into the crisper at the bottom of the fridge. To Fix This Issue we will be removing the evaporator cover from the fridge and cleaning out the water tray…. don’t worry if you have limited experience with refrigerator repair, I had none before attempting this as was able to complete this fix relatively easy.

– – – Update 3/8/2021 – – –

My good friend Ol’Brute was using this page to make this same repair on his Samsung fridge and he took it a step farther, finding an item you can buy that will permanently fix the manufacturing defect with the fridge so that it won’t ice up again in the future.  You can still go through the steps below to fix the iced up fridge, however while you are doing that you can also install this piece and prevent any future freezing:  https://www.amazon.com/SAMSUNG-DRAIN-EVAPORATOR-REFOEM-Original/dp/B008KFG9NO

Step 1:
Unplug the fridge then empty all of the contents out, and take out all of the drawers.

Step 2:
Unscrew the Cover

  • Take out both bottom screws
  • pop the cover off the middle section
  • once the small cover is off then take out the hidden screw that is behind the cover

Evaporator Cover

Helpful Hints For this Step
– The small cover in the middle has hooks on either side. Take a small flathead screwdriver and pry one side out and it will pop out easy.
– Once you remove the small cover if there is ice built up underneath, take a hair dryer and melt the ice until you can access the screw.

Step 3:
Remove the Cover. This step is the most challenging step of the entire process so take your time and make sure not to break the cover. The best way to remove this is to pull from one side. There are small brakets on each side, once you put pressure on one side the entire cover will bow in the middle and the brackets on the side you are pulling will slide out, and then the entire cover can rotate sideways and easily slide out.

Pull the right side of the cover towards the left until it bows in the middle and slides out

Helpful Hints For This Step
– If you have trouble getting the cover off you can take a flathead screw driver and slide it under one side. From there you can gently pry until the cover slides out.
– If you get very stuck on this step, take a hair dryer and heat up the cover, depending on how much ice has built up ice could be keeping the cover panel locked in place.

Step 4:
Unplug the evaporator. There will be two wires that you need to unplug, pictured below:

Step 5:
Take the hair dryer and melt all of the ice frozen in the bottom of the metal tray, pictured below:

Step 6:
Boil water and melt the remaining ice stuck in the drain hole:

Helpful Hints For This Section
– It took me 5 different pours of boiling water before the ice fully melted. Once the ice melts you will hear water drain down to the pan at the bottom of the fridge. Go ahead and pour a couple more small amounts of boiling water after the ice melts to help clean the line.
– If the ice is really stubborn in the drain hole, put a flat head screw drive and take a hammer and very lightly tap the screw drive. Do not hit it very hard, this is only to try and loosen up the ice a bit.

Step 6:
Reassemble the fridge, plug it back in and then bask in the satisfaction that you just solved a problem with your own two hands and fixed your fridge without paying a single dime to anyone!

Categories
Fixing Stuff Julia

Making Your Rental Work (A Preparation)

I got permission from my landlord to make small, surface level updates around the house. And the first room I’m pumping myself up to tackle is the bathroom. We have an old light wood vanity with a surface that is slightly discolored after years of use, no matter how hard I scrub. So, I’ve done a little research and I’m planning to make purchases in early October. I think all I need is the following and the space is going to look 100% better.

Vanity Update:

  • Screwdriver
  • TSP cleaning solution
  • Sandpaper to remove the finish on the wood
  • Primer
  • Half-gallon can of paint
  • Painter’s tape (for the floor and mirror since I’ll paint the trim of it too)
  • two new pull handles

To update the countertop:

  • Xacto knife
  • Removable vinyl contact paper in ‘marble
  • Rubbing alcohol
  • Smoothing device (like a credit card or gift card)

Other:

 

Eventually I’d also like to buy removable wallpaper and/or repaint the bathroom, but I think this will be more than enough to start. I already love the shelf we hung when we moved in, and the shower curtin/handtowels/rug we have.
I’ll post an update with photos of supplies and the before/during/after photos when this gets underway. Posting this “prep” is working to hold myself accountable to actually start and finish this project.

Categories
Fixing Stuff Phase Two Samuel Sisters House

Repairing Spray Foam Roof

In July we embarked on a huge project. Tuckpointing and placing brick caps on the roof at the sisters house. This job ended up looking fantastic and I’m going to outline the steps below:

Phase 1: Repairing the Bricks
During this phase we hired a local bricklayer to come in and re-tuck point each chimney stack. In addition to the chimneys we also had him rebuild 3 knee walls in the front of the house. Pictures of this process are below:

Chimney, uncovered and open to the elements

Crumbling Chimney

Uncovered Chimney w/no flue cap in place

Chimneys capped with new concrete topper and flue cap

Chimneys capped with new concrete topper and flue cap

Chimneys capped with new concrete topper and flue cap

Knee wall being repaired. We had to cut the spray foam roof and re-tuck point 3 scores of bricks

Phase Two: Repairing the Spray Foam Roof
Once all of the brick work was completed it was time to repair the spray foam roof. Initially we wanted to hire this job out because neither my dad or myself had any previous experience installing spray foam. Finding a contractor to complete the job actually turned out to be a massive headache. It finally reached a point where I ended up pouring into researching how to install spray foam and where to actually get the stuff. In the end we were able to find the exact product we needed:

Spray Foam repair kit:
We purhcase this kit: https://www.energyefficientsolutions.com/Roof-Spray-Foam.asp?item=FOAM060

Spray foam sealer (this is applied over the foam to protect it from the sun + its an added layer of waterproofing):
We purchased this sealer: https://www.energyefficientsolutions.com/white-roof-coating-paint.asp

Tips for installing spray foam:
It turns out the spray foam is relatively straightforward to install. There is definitely a bit of a learning curve and during the process I learned several great tips and techniques:

  • Temperature is crucial. Buy an infrared thermometer to ensure your foam tanks and the roof are the ideal temperature. I purchased this thermometer from Amazon and it worked perfectly: https://amzn.to/2PB8TyZ
  • Apply the spray foam in the morning, around 9:00 a.m. If you wait longer the sun will heat up your roof to much. I was amazed that at 11:00 a.m. the roof material and bricks were already 122 degrees fahrenheit
  • When operating the spray foam gun, shoot the gun in quick bursts. This works way better than constant trigger pressure. The ideal motion is right to left at 1 foot per second then right to left again. Continue this all the way down the area you need to cover and you will get great results
  • This kit comes with two types of nozzles. The fan nozzle is the best one to use, it creates a wide even spray.

Foam installed and sanded down

Foam installed and sanded down to be as flush as possible.

First Layer of Sealer painted on

First Coat of sealer painted on.

Categories
Fixing Stuff Laravel Samuel

FIxing Laravel Query

We had a query that was breaking several pages after a client removed information that was referenced from another table (even thought the system explicitly warns them from removing this info lol). To fix the errors messages the client was receiving we needed to update our controller so that our database lookup only included items with vehicles present. To do this we made the following changes in two files:

Changes to our Inquiries Controller:
Step 1:
Replacing our DB lookup:
Old Query: $inquiries = Inquiry::all();

New Query: $inquiries = Inquiry::whereHas('vehicle_id')->get();

Step 2:
Fixing error message: Illuminate\Database\Eloquent\Builder::whereHas() must be an instance of Closure, none given'

Instead of using whereHas we were able to fix the error message by simply using has. This was a simple error in hindsight, we don’t need to query to lookup multiple items, we only need to know if the inquiry HAS a vehicle associated with it.

Our Final working fix: $inquiries = Inquiry::has('package.vehicle')->get();

Changes to our separate view files:
We also had issues related to inquiries on 4 other pages. The system references inquiries on part types as well and these pages all referenced an individual view file, so instead of refactoring this code into a controller we took the path of least resistance and made the changes below:

Original code:
@foreach($inquiries as $inquiry)
package; ?>
vehicle; ?>

{!! link_to_route('inquiries.show', $inquiry->id, ['id' => $inquiry->id]) !!} {!! link_to_route('vehicles.show', $vehicle->display(), ['id' => $vehicle->id]) !!} {!! link_to_route('packages.show', $package->display(), ['id' => $package->id]) !!} {{ $inquiry->getType()->name }} {{ $inquiry->getEngine()->name }} {{ $inquiry->getDriveTrain()->short_name }} {{ $inquiry->getMarking()->name }} {!! Helper::sortDollarAmount($inquiry->getPrice()) !!} {{ $inquiry->name }} {{ $inquiry->agency }} {{ $inquiry->email }} {{ $inquiry->displayPhone() }} {!! link_to_route('inquiries.excel', 'Excel', ['id' => $inquiry->id], ['class' => 'success']) !!}
 / {!! Form::deleteModelLink('Inquiry', $inquiry->id, 'inquiries') !!}

@endforeach

Changed Code:
@foreach($inquiries as $inquiry)
package; ?>
vehicle; ?>

@if($vehicle)

{!! link_to_route('inquiries.show', $inquiry->id, ['id' => $inquiry->id]) !!} {!! link_to_route('vehicles.show', $vehicle->display(), ['id' => $vehicle->id]) !!} {!! link_to_route('packages.show', $package->display(), ['id' => $package->id]) !!} {{ $inquiry->getType()->name }} {{ $inquiry->getEngine()->name }} {{ $inquiry->getDriveTrain()->short_name }} {{ $inquiry->getMarking()->name }} {!! Helper::sortDollarAmount($inquiry->getPrice()) !!} {{ $inquiry->name }} {{ $inquiry->agency }} {{ $inquiry->email }} {{ $inquiry->displayPhone() }} {!! link_to_route('inquiries.excel', 'Excel', ['id' => $inquiry->id], ['class' => 'success']) !!}
 / {!! Form::deleteModelLink('Inquiry', $inquiry->id, 'inquiries') !!}

@endif
@endforeach