Welcome to Rants and Raves!
I kept hearing that I needed to write, so here is the blog that I ended up starting.
It is mostly an accounting of my progression through creating a web site, nuances with code, and tips about what I did to make things work.
In there you will find sprinkled about some gems of life, and letting loose fun.
Enjoy!
Ride Through That Storm
2023-02-23
A bit stormy today. It snowed all night, and it's been precipitating all day across several states. I say precipitating because it started as snow, but as we got a little bit South and more East it transitioned through sleet to rain. A bit gloomy I suppose, and there was perhaps a little bit of potential for crashes if the storm wasn't being respected. But really, there wasn't much to worry about if you used a little bit of caution. Most people have a tendency to overly fear a little bit of bad weather, and then there are those few that don't give enough respect. It is hard to get just the right amount of caution, especially when there are others on the road. On the other hand it is easier to gauge how much respect to give when you see the others that didn't and are now on the side of the road. I will give props to those that do a good job of helping keep the roads clear and help those that are unfortunate enough to suffer at the hands of the inclamite weather.
Yay... Job Hunting...
2023-02-22
I have started applying for official jobs again, it is not something I enjoy doing. Often it's a lot of jumping through hoops and bending over backwards for nothing. One of the things that I like least is experience mismatch. There are plenty of things where I just simply haven't spent enough time doing the one thing, that's understandable. The problem is when a company wants a decade of experience for an entry level position, and because of that the entry level person can't get the experience. I do understand that companies want the best they can get, and don't want to spend a lot of time and money having to train up someone enough to start benefiting from the new hire. But they need to realize that there is a difference between entry level experience and pay. It seems to me that they are trying to replace a vacancy with the same level of experience, but not give the same amount of pay because they are a new hire and thus "entry level". I do appreciate the companies that are willing to read between the lines and look at the candidate as a whole, which I also realize can be a challenge. There are many places that are overwhelmed with applicants which is why so many of the resume sites emphasize that you have 10-30 seconds to impress HR, if they even see your application. Then again, it's always been about having connections and who you know, hasn't it? Honestly, the whole thing's a mess and there's not really anything I can do to change it, just gotta play the games.
Laravel Accessors And Mutators
2023-02-21
Earlier I made note of adding functions to a model in order to do something like make a full name from the first and last name, but there's more that can be done there. Laravel Accessors & Mutators are predefined-ish functions that can be used to manipulate the DB data when accessing or saving it, respectively. Using these you can make sure all of your blog post titles are capitalized before presenting them:
public function getTitleAttribute($value)
{
return ucwords($value);
}
Or make sure an email is all lower case before saving it:
public function setEmailAttribute($value)
{
$this->attributes['email'] = strtolower($value);
}
This format is good for Laravel 8, but definitely not for Laravel 10.
https://laravel.com/docs/8.x/eloquent-mutators
You can technically do a lot more inside of the function before it returns or saves the data, but I anteed to make a note about the functions inside of the accessor and mutator here and in the Laravel docs. These are using built in PHP functions, not the Laravel helper functions.
https://www.php.net/manual/en/ref.strings.php
https://laravel.com/docs/8.x/helpers
If you use the Laravel helper functions you will need to add the appropriate namespaces, but not if you can use the PHP ones.
Redirect To Intended With 'Auth' Middleware
2023-02-20
I was having an issue where my login would timeout and after logging in it would not redirect me back to the intended page I was trying to access. I had assigned the 'verified' middleware to a group of web routes, and that did handle the security of needing to be logged in and verified to access the resource, but wasn't doing the redirect. After a little research it seemed like I needed to add the 'auth' middleware to the group. So I went from:
Route::middleware(verified)->group(function(){ ... });
To:
Route::middleware(['auth','verified'])->group(function(){ ... });
I tried to find some documentation to confirm that having multiple middleware defined like this worked as an AND or an OR, but it the small looking I did was not definitave. I did my own test and determined that they work as an AND, the user needs to have an account for the 'auth' AND needs to have that email vervied for the 'verified' to access anything within that group.
https://laravel.com/docs/10.x/middleware#assigning-middleware-to-routes
https://laracasts.com/discuss/channels/laravel/redirect-intended-not-working-after-login?page=1
https://stackoverflow.com/questions/40822882/adding-multiple-middleware-to-laravel-route
Use String Matching For Conditional
2023-02-19
If you want to do a partial string comparison as your conditional condition you can simply use:
stristr('thing to look in', 'thing to look for')
If the second item is located in the first then it should return true, otherwise it should return false. So you can end up with something like:
if(stristr('thing to look in', 'thing to look for')){
match found
}else{
no match
}
https://www.php.net/manual/en/function.stristr.php
Functions In Laravel Models Make Life Easier
2023-02-18
If you have some information broken out in the DB but is often good to have combined, such as names, you can make a function in the model to do so:
public function fullName() {
return $this->firstName . ' ' . $this->middleName . ' ' . $this->lastName;
}
And then use the function in the rest of your code:
$user->fullName();
https://laracasts.com/discuss/channels/eloquent/how-to-combine-firstname-lastname-and-middlename
This idea could be used to centralize functions that you find you often do with a model.
Use Laravel Table Schema Builder In Controller
2023-02-17
It is possible to manipulate the DB in the Laravel controller just like you can in the migrations. Just add:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
to the beginning of the controller and you can utilize the:
Schema::create/table('table_name', function (Blueprint $table) {
$table->id();
...
$table->timestamps();
});
format.
https://laravel.com/docs/9.x/migrations#migration-structure
https://laracasts.com/discuss/channels/general-discussion/how-to-include-schema-builder-in-a-controller
Back To Final Fantasy XI
2023-02-16
Well I am now officially paying for FFXI. Spent some time playing and getting a feel for the system, luckily my internet connection was solid enough until just before I was going to quit anyway. Odd things in how it performs, like crashing if you switch to another program. Not sure if that's on purpose, but it would be nice if you could look at a webpage without having to completely log in again. It would also be kind of nice if there was the option to toggle the expansions. There's enough going on to start with that getting bombarded with tidbits of story arcs that I am not going to be able to keep track of until the next instalment happens. Anyway, I got a few levels and my first trust while working through the first starter adventure quests.
Coloring Of The Navbar
2023-02-15
Bootstrap has some nice color presets for buttons, but a little bit more complex when it comes to the navbars. By default the navbar utilizes the light class and you can change to the navbar-dark class for dark backgrounds. These are to be used with the background color bg-* classes, or you can use inline styling to enter a custom color code.
https://getbootstrap.com/docs/5.2/components/navbar/#color-schemes
If you are looking for more customization of the colors here or in general you should definitely look into playing with the CSS variables themselves. I have not done so yet, but it is definitely a potentially powerful tool.
https://getbootstrap.com/docs/5.2/components/navbar/#css
Adventures On The Other Side Of The Country
2023-02-14
We did some quick travelling in order to take care of some legal BS. I do have plenty of complaints about how the airlines, but I do enjoy flying for the most part. It is really cool how we are able to move so fast through the air with the ground so far away. It is also usually pretty incredible to get a bigger picture of what humans have accomplished on the ground, yet how small and insignificant we still are. Another fun thing about travelling is getting to experience a new vehicle. We were only going to be there for 24 hours so we did decide to rent a sports car for only a little bit more which was a lot of fun. I think it was a '22 Mustang, and it wanted to go fast. Sure, I certainly did play with it, but it didn't take hardly any effort to go zoom, suddenly be 30 over the speed limit, and not hardly feel it. Anyway, I do recommend spoiling yourself by renting a higher end car every once in a while. Another thing to note was our dinner at Season 52, a fancy seasonal restaurant and wine bar so don't expect a bargain meal. Due to the seasonal aspect of the restaurant it does have some less traditional items, but also some more standard items for the less adventurous. We aren't actually very big on drinking but this time our adventuring found a pineapple mixed drink that sat pretty decent with us. They have very reasonable sized portions, and the gnocchi soup, steak, and dessert we got were very delicious and worth the $100 with tip we spent. There were definitely some setbacks to the trip, like forgetting our keys to the storage unit and PO box, the PO ???ACCIDENTALLY??? "closing" our PO box and sending some packages back..., and having to cancel our blood donation because dealing with the government turned into yet another fiasco. Ultimately we were successful, and the timing for travelling was pretty good.