Recent Learnings: Part 2

A few of the concepts I've learned over the past few days.

PHP / Laravel

1 Carbon

When working with data and time I can make use of more functionality if I use the Carbon class which is part of Karavel Framework.

use Illuminate\Support\Carbon;

In my method

$dob = Carbon::parse('2016-10-15')->format('y-m-d');

There is a ton more I can do to:

Learn more about Carbon class here.

For example set a timezone for the project.

Carbon::getTimezone

no arguments

returns CarbonTimeZone

Get the TimeZone associated with the Carbon instance (as CarbonTimeZone).

Carbon::setDate

$year, $month, $day

returns Carbon

Set the date formated as gregorian year, month and day numbers.

2 Compact multiple variables for use

The ability to work with variables passed from controller to blade file.

public function view_dog_records()
{
    $dogname = 'Hector';
    $breed = 'Mixed';
    $dob = Carbon::parse('2016-10-15')->format('y-m-d');
    $mother_health_history = 'anxiety';
    $father_health_history = 'unknown';
    $sibling_health_history = 'cushings disease';
    return view('dogtracker.view-dog-records', compact('dogname', 'breed', 'dob', 'mother_health_history', 'father_health_history', 'sibling_health_history'));
}

Make use of these using blade with the blade command {{ $dogname }} wherever I want this to show up.

<button>Start Tracking {{ $dogname."'s" }} Allergies</button>

CSS

Double background image.

Instead of faffing around in Canva I can add a non-destructive image gradient overlaying the 1st background image. I can even have multiple background images if I want.

Use a comma to make the addition and a comma for any other parameters which may affect them.

See it in action in my code pen,

For the layout, I followed a Youtube tutorial by Kevin Powell

Where I learned about grid-template-rows