https://media.notthebee.com/articles/d871d932-0f5a-4ce5-be61-f5cf139b9f49.jpg
Lol the kids were loving it. đ
Not the Bee
Just another WordPress site
https://media.notthebee.com/articles/d871d932-0f5a-4ce5-be61-f5cf139b9f49.jpg
Lol the kids were loving it. đ
Not the Bee
I’m proud to announce that our team has released a new package called spatie/laravel-stats. This package is a lightweight solution for summarizing changes in your database over time.
Here’s a quick example where we will track the number of subscriptions and cancellations over time.
First, you should create a stats class.
use Spatie\Stats\BaseStats;
class SubscriptionStats extends BaseStats {}
Next, you can call increase when somebody subscribes and decrease when somebody cancels their plan.
SubscriptionStats::increase();
SubscriptionStats::decrease()
With this in place, you can query the stats. Here’s how you can get the subscription stats for the past two months,
grouped by week.
use Spatie\Stats\StatsQuery;
$stats = StatsQuery::for(SubscriptionStats::class)
->start(now()->subMonths(2))
->end(now()->subSecond())
->groupByWeek()
->get();
This will return an array like this one:
[
[
'start' => '2020-01-01',
'end' => '2020-01-08',
'value' => 102,
'increments' => 32,
'decrements' => 20,
'difference' => 12,
],
[
'start' => '2020-01-08',
'end' => '2020-01-15',
'value' => 114,
'increments' => 63,
'decrements' => 30,
'difference' => 33,
],
]
Instead of manually increasing and decreasing the stat, you can directly set it. This is useful when your particular stat does not get calculated by your own app but lives elsewhere. Using the subscription example, let’s imagine that subscriptions live elsewhere and that there’s an API call to get the count.
$count = AnAPi::getSubscriptionCount();
SubscriptionStats::set($count);
By default, that increase, decrease and sets methods assume that the event that caused your stats to change happened right now. Optionally, you can pass a date time as a second parameter to these methods. Your stat change will be recorded as if it happened at that moment.
SubscriptionStats::increase(1, $subscription->created_at);
The implementation of this package is simple. The basic principles of event sourcing are being used: we don’t store a result, but only the changes.
The package stores all “events” in the stats_event table

Inside the StatsQuery class, you’ll find the heart of the package. In its get function, you can see that all events for a given period are retrieved, summarized and mapped to DataPoint classes.
We are going to use laravel-stats in Flare, our exception tracker for Laravel/PHP/JavaScript projects, to keep tracker of changes in subscribers and other key metrics. We hope that the package can be helpful in your projects as well.
As mentioned above, the package uses a lightweight event sourcy approach. If you want to know more about event sourcing, check out our upcoming premium course on event sourcing in Laravel.
I’d like to thank my colleague Alex, who did the bulk of the work creating spatie/laravel-stats.
Do also take a look at this list of packages our team has created previously. I’m sure there’s something there for your next project.
Laravel News Links
I’ve decided to make the @LaraBugEN code open source đĽł
Its not the most beautiful code, since its an very old project where even @PovilasKorop did an interview for with me, more on that in the readme â https://t.co/KxKIJWrfBa pic.twitter.com/pdmf06S3K6
â Dennis đââď¸ (@dennis_smink) April 12, 2021
Laravel News Links
https://opengraph.githubassets.com/6e36e884e6502b1c7a8e72f3288b5bdf3b55f42aab33ab347fdeed1936d81264/level39/dranzerDranzer is an open source Laravel app that allows you to scaffold production ready Laravel apps.Laravel News Links
https://www.pewpewtactical.com/wp-content/uploads/2021/03/Parent-Bug-Out-Bag-12-2048×1536.jpg
If thereâs one place you donât want something bad to happen, itâs when youâre 20 miles into the woods, and there are no signs of civilization anywhere.
The woods arenât exactly an inherently safe place.
Thatâs not to say that youâre walking into a green death trap every time you hit a trail, but it is to say that nature (and people) can be a beast.
As such, itâs best to be prepared to face whatever curveball may get thrown your way.
Unfortunately, Iâve spent enough years in the woods to see people placing themselves in bad situations.
But having a bit of pre-planning in place means the difference between life and death.
Out in the woods, youâre truly on your own, and you need to be able to do what it takes to keep yourself alive.
Thankfully, there are a number of steps that we can take to ensure that weâve done what we can to stay safe as we enjoy the beauty of the woods.
And guess what â weâve narrowed down some of this advice for you.
So without further ado (sorry, Iâve been reading Shakespeare lately), here are the top tips to consider before your next hike.
Arguably, this is one of the most important things you can do to stay alive while out in the woods.
If youâve ever seen 127 Hours â that movie where the guy has to cut his arm off with a dull multitool knifeâ it was the violation of this principle that caused such a drastic decision and outcome
I really have no problem with people hiking solo.
Thatâs the whole reason to go out in the woods in the first place, is it not? To get away from people?
But by always telling somebody where youâre going, and an approximate time youâll be back home, followed by a quick message once you get back home youâll have maintained a very important lifeline for yourself perchance something should go wrong.
If nobody knows where youâre at, then nobody will come for you.
This is a pet peeve of mine.
If youâre going to go out in the woods â even for a really quick day trip â at least bring some water and perhaps a granola bar with you out there.
I know that the idea of not having anything to carry seems appealing, but water, in particular, could potentially save your life.
We tend to underestimate Mother Nature when we go outside. And an incredibly hot day of hiking can dehydrate you very quickly.
This, in turn, can lead to some brutal headaches, an inability to make good decisions, and eventually, heat exhaustion or heat stroke.
Going out into the woods for relaxation and then ending up miserable because you couldnât bring something as simple as a water bottle rather defeats the purpose.
âCotton killsâ goes the famous backpacking adage. And thereâs a good reason for that.
Once cotton gets wet, it completely loses any insulative qualities that it had prior. You may as well be walking around naked.
Aside from the weather often changing very quickly while youâre out in the woods, thereâs also always the chance of slipping during a stream crossing or some other similar water accident.
By wearing clothes made of nylon, polyester, or some other water-resistant material, youâll be much safer while youâre out.
Personally, I enjoy hiking at night. The peace of the woods is incredible in the dark, the stars are like nothing youâve ever seen, and itâs just fun.
However, a lot of people end up night hiking by accident.
What I mean by this is that mountains and trails can often be rather deceiving. What we think should only be a 3-hour hike where you will be back home in time for dinner can easily turn into a 5-hour hike where you donât get home till well after dark.
Thereâs nothing wrong with this but attempting to hike in the dark without a flashlight is a good way to end up breaking an ankle.
So, make sure that you have a flashlight of some sort with you when you go out in the woods. Better yet, bring a headlamp.
This will leave both of your hands-free for trekking poles or supporting yourself on nearby trees as you climb and descend.
Being safe should be a given.
But while out in the woods, Iâve witnessed a girl attempting to catch a baby bear and even somebody hanging off a 300-foot cliff for a photo, to name just a fewâŚ
Iâve also rock jumped at an area where a 20-something girl broke her hip and needed a hip replacement (she hit an underwater rock shelf). Then another 20-something ended up paralyzed from the neck down, followed by another 20-something found dead about a year after heâd gone missing.
Needless to say, I quit rock jumping there.
So have fun while youâre out there, but make sure that itâs safe fun as well.
I truly donât understand people who go out into the woods without a knife on their person.
Perhaps this is just part of being a Southerner â where granddadâs old pocketknife is just a part of our pants.
So, to not have some means of cutting things while out in the woods is foolish to me.
If you carry one regularly, you understand just how often you end up pulling the thing out daily.
But if youâre in the woods, the benefits of a knife improve substantially.
Perchance you do end up in a survival situation while out in the bush, youâll greatly improve your odds of making it through the wild in one piece with a quality blade on your person.
Making traps, skinning game, filleting fish, cutting paracord, making bandages, and crafting a shelter are but a few of the benefits derived from carrying a knife out in the woods.
So, make sure that you have one.
You may want to consider your local laws on this one â as everywhere is different â but I highly recommend traveling with a weapon of some sort.
There are weirdos out in the woods, too, and fighting off rabid bobcats with your hands doesnât sound fun to me.
In case you think Iâm fearmongering, just know that within the past 10 years, weâve witnessed: a man attacking people on the Appalachian Trail with a machete, murders on various trails, clowns in the woods, bobcats attacking people, cougar attacks, and much more.
If youâre looking for more information on the legality of carrying within a National Park, check out our article here.
To go out into the woods without some means of purifying water is just plain stupid.
Water is essential to life, and if you attempt to drink straight out of a stream or creek, youâre virtually guaranteed to end up with a debilitating form of diarrhea.
And that makes a bad situation much, much worse.
Besides, who wants to hike out to safety with brown pants?
No, itâs best to have some means of preventing such from ever happening in the first place. There are several convenient, light, and non-expensive means of doing such.
I personally prefer a SteriPen to purify my water, but a much more affordable option would be to take a LifeStraw out into the woods with you.
At roughly $25, hereâs simply no reason not to have one of these on your person.
Prices accurate at time of writing
Prices accurate at time of writing
You can read all about hiking and water purification in our article here!
Another requirement for hiking â carrying a high-quality topographic map of the region youâre traveling through.
Not only does this make the hike much more interesting (youâre able to determine just what exactly youâre looking at in the distance), but it also provides an incredible level of safety should you get lost.
However, you first must know how to read a map, which is fast becoming a forgotten skill set.
I consider the best maps on the market to be the National Geographic topo maps. Theyâre waterproof, beautiful, pretty tough, and pack down really well.
Prices accurate at time of writing
Prices accurate at time of writing
Having one of these on your person and having watched a couple of YouTube videos on reading a topo map will serve you well for the rest of your life.
Did you know that a lot of national parks actually allow hunting on them?
Thereâs nothing quite like being mistaken for a deer during rifle season. On the plus side, getting hit with a rifle round is a great way to lose weight!
However, if thatâs not your preferred method of weight loss, I highly recommend knowing when hunting season is in your area.
Figure out where people are likely to be hunting and make sure to wear blaze orange, stick to the trail, and make noise as you hike.
Lightning is a lot more terrifying when you donât have a house to run into.
Surprise turns in the weather have suddenly caught me unaware at the peak of a mountain in the middle of a thunderstorm in the past.
If such should happen to you, you need to do everything in your power to descend the mountain and get away from tall objects as fast as possible. Your life truly could depend upon it.
Donât shelter underneath a tree or in a cave either.
A tree is a natural lightning rod as it is, and if you shelter in a cave, lightning can easily travel through the rock and blow you away.
If you have no other options for shelter (e.g., a trail shelter) and you must find some way to ride the storm out while youâre out in it, you should do the following:
Aside from the noise disturbances, camping near a road brings the possibility for somebody to walk up to your tent in the middle of the night.
Call me paranoid, but I purposefully plan to spend the night as far away from any nearby road as possible when I go backpacking into the woods.
Weâve had some murders just off the road in the mountains, and I guess theyâve always stuck with me.
Itâs because of this that I make my tent as difficult to find for some serial killer taking an evening stroll.
Part of this is choosing a tent color that blends in with your surroundings. I highly recommend the Snugpack Scorpion 2 in part for this reason â in other part because it straight up rocks.
Prices accurate at time of writing
Prices accurate at time of writing
By this point, you probably donât post to social media that youâre on vacation at the beach while youâre on vacation at the beach.
Why? Because it tells the whole world that youâre not at home!
In the same vein, youâre going to want to avoid telling strangers your plans while youâre out on the trail.
Letting somebody who youâve never met in on the details of where you plan to sleep â in the middle of the woods with nobody else around â is probably a bad idea. Just sayinâ.
I donât want you to walk away from this article with the idea that hopping onto a trail in the woods is the beginning of a death trap. Itâs not.
Instead, I want to help you provide a layer of security while you hike.
As such, it only makes sense to do what we can to mitigate the risk that weâll face things happen.
Our list truly isnât difficult to follow and is most certainly not expensive either. You most likely have all of the gear already that you would need, and the rest is just active decision-making.
So, do what you can to take care of yourself and your family while youâre out in the woods.
Youâll enjoy yourself more freely with the knowledge that you have the means to take care of yourself should things go south.
Are there other ways to improve your safety? Let us know in the comments below! Ready to gear up? Check out our guides on the Best Portable Water Filters for Survival & Hiking and Best .410 Revolvers Perfect for Hiking.
The post Hiking Survival: 13 Ways to Stay Alive in the Woods appeared first on Pew Pew Tactical.
Pew Pew Tactical
https://i.kinja-img.com/gawker-media/image/upload/s–zSMm0Dj4–/c_fit,fl_progressive,q_80,w_636/hhrvxyfauvbgwuehaw19.jpg
From the very beginning of the new Mortal Kombat, it’s clear the filmmakers are trying something different with this particular video game adaptation. But, instead of us explaining that, why don’t you just watch it for yourself?
Warner Bros. just released seven minutes from the very, very beginning of the new film, which hits theaters and HBO Max on Friday. It reveals the start of arguably Mortal Kombat’s most famous rivalry, between Sub Zero (Joe Taslim) and Scorpion (Hiroyuki Sanada). However, it’s handled with a nice dash of emotion, a sign of how the rest of the film plays out too.
You can watch the footage below. Sort of. Since there’s a a lot of violence in it (Mortal Kombat is a very hard R-rated film) you have to watch it on YouTube. But we hope you’ll come back and discuss after you do.
Without spoiling too much, from the moment this clip cuts off, the fight between the two continues, reaches a conclusion, and the ramifications of that echoes centuries later, when the film picks up in the present day. Then, once that’s all established? Get ready for a massive showdown between Earth Realm and Outworld.
Another thing to notice is the music during the big action beats around five minutes in. If you got a little taste of the unforgettable Mortal Kombat song “Techno Syndrome” by the Immortals in there, you’d be right; the film’s composer, Ben Wallfisch, uses bits and pieces of it throughout.
See more when Mortal Kombat is released April 23.
For more, make sure you’re following us on our Instagram @io9dotcom.
G/O Media may get a commission
Gizmodo
https://avatars.githubusercontent.com/u/4967100?s=400&v=4
Generate migrations from existing database structures, an alternative to the schema dump provided by Laravel. A primary use case for this package would be a project that has many migrations that alter tables using ->change() from doctrine/dbal that SQLite doesn’t support and need a way to get table structures updated for SQLite to use in tests.
Another use case would be taking a project with a database and no migrations and turning that database into base migrations.
composer require --dev bennett-treptow/laravel-migration-generator
php artisan vendor:publish --provider="LaravelMigrationGenerator\LaravelMigrationGeneratorProvider"
Whenever you have database changes or are ready to squash your database structure down to migrations, run:
php artisan generate:migrations
By default, the migrations will be created in tests/database/migrations. You can specify a different path with the --path option:
php artisan generate:migrations --path=database/migrations
You can specify the connection to use as the database with the --connection option:
php artisan generate:migrations --connection=mysql2
You can also clear the directory with the --empty-path option:
php artisan generate:migrations --empty-path
Each database driver can have separate configs, as specified in config/laravel-migration-generator.php.
Want to customize the migration stubs? Make sure you’ve published the vendor assets with the artisan command to publish vendor files above.
There is a default stub for tables and views, found in resources/stubs/vendor/laravel-migration-generator/.
Each database driver can be assigned a specific migration stub by creating a new stub file in resources/stubs/vendor/laravel-migration-generator/ with a driver-prefix, e.g. mysql-table.stub for a MySQL specific table stub.
Stubs can be named using the (table|view)_naming_scheme in the config. See below for available tokens that can be replaced.
Table stubs have the following tokens available for the naming scheme:
[TableName] – Table’s name, same as what is defined in the database[TableName:Studly] – Table’s name with Str::studly() applied to it (useful for standardizing table names if they are inconsistent)[TableName:Lowercase] – Table’s name with strtolower applied to it (useful for standardizing table names if they are inconsistent)[Timestamp] – The standard migration timestamp format, at the time of calling the command: Y_m_d_His[Timestamp:{format}] – Specify a format for the timestamp, e.g. [Timestamp:Y_m]Table schema stubs have the following tokens available:
[TableName] – Table’s name, same as what is defined in the database[TableName:Studly] – Table’s name with Str::studly() applied to it, for use with the class name[Schema] – The table’s generated schemaView stubs have the following tokens available for the naming scheme:
[ViewName] – View’s name, same as what is defined in the database[ViewName:Studly] – View’s name with Str::studly() applied to it (useful for standardizing view names if they are inconsistent)[ViewName:Lowercase] - View's name with strtolower` applied to it (useful for standardizing view names if they are inconsistent)[Timestamp] – The standard migration timestamp format, at the time of calling the command: Y_m_d_His[Timestamp:{format}] – Specify a format for the timestamp, e.g. [Timestamp:Y_m]View schema stubs have the following tokens available:
[ViewName] – View’s name, same as what is defined in the database[ViewName:Studly] – View’s name with Str::studly() applied to it, for use with the class name[Schema] – The view’s schemaGiven a database structure for a users table of:
CREATE TABLE `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `first_name` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `last_name` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `timezone` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'America/New_York', `location_id` int(10) unsigned NOT NULL, `deleted_at` timestamp NULL DEFAULT NULL, `remember_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `users_username_index` (`username`), KEY `users_first_name_index` (`first_name`), KEY `users_last_name_index` (`last_name`), KEY `users_email_index` (`email`), KEY `fk_users_location_id_index` (`location_id`) CONSTRAINT `users_location_id_foreign` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
A tests/database/migrations/[TIMESTAMP]_create_users_table.php with the following Blueprint would be created:
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateTestActionRemindersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('username', 128)->nullable()->index(); $table->string('email', 255)->index(); $table->string('password', 255); $table->string('first_name', 45)->nullable()->index(); $table->string('last_name', 45)->index(); $table->string('timezone', 45)->default('America/New_York'); $table->unsignedInteger('location_id'); $table->softDeletes(); $table->string('remember_token', 255)->nullable(); $table->timestamps(); $table->foreign('location_id', 'users_location_id_foreign')->references('id')->on('locations')->onUpdate('cascade')->onDelete('cascade'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } }
These DBMS’s are what are currently supported for creating migrations from. Migrations created will, as usual, follow what database drivers Laravel migrations allow for
Laravel News Links
https://res.cloudinary.com/techvblogs/image/upload/v1617996645/banner/rjswos1leslvm0h4asbm.png
Laravel Sanctum provides a featherweight authentication system for SPAs (single page applications), mobile applications, and simple, token-based APIs. Sanctum allows each user of your application to generate multiple API tokens for their account. These tokens may be granted abilities/scopes which specify which actions the tokens are allowed to perform. Here are some reasons you might want to choose Sanctum over Passport:
First, open Terminal and run the following command to create a fresh laravel project:
composer create-project --prefer-dist laravel/laravel larasanctum-api
or, if you have installed the Laravel Installer as a global composer dependency:
laravel new larasanctum-api
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=<DATABASE NAME>
DB_USERNAME=<DATABASE USERNAME>
DB_PASSWORD=<DATABASE PASSWORD>
Read Also: Firebase Push Notification Laravel Tutorial
Now would be a good time to start the Laravel application to make sure everything is working as expected:
cd larasanctum-api
php artisan serve
Let’s add Laravel Sanctum to it. First, we need to install Laravel Sanctum into our application using Composer:
composer require laravel/sanctum
Next, we’ll publish Laravel Sanctum configuration and migration files using the following command:
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
Now, run the database migrations:
php artisan migrate
To use tokens for users, add the HasApiTokens trait inside the User model.
Open the app/Models/User.php file and add the following modifications:
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasFactory, Notifiable, HasApiTokens;
}
Edit your app/Http/Kernel.php file to add Sanctum’s middleware into your API middleware group.
'api' => [
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
],
Let’s start with registering for an account. In your terminal create the controller responsible for authentication by running the following Artisan command:
php artisan make:controller AuthController
Now open the routes/api.php file to create the route for registering a user:
use App\Http\Controllers\AuthController;
Route::post('/register',[AuthController::class,'register']);
Open app/Http/Controllers/AuthController.php and create a method to register a user:
use Illuminate\Support\Facades\Hash;
public function register(Request $request){
$post_data = $request->validate([
'name'=>'required|string',
'email'=>'required|string|email|unique:users',
'password'=>'required|min:8'
]);
$user = User::create([
'name' => $post_data['name'],
'email' => $post_data['email'],
'password' => Hash::make($post_data['password']),
]);
$token = $user->createToken('authToken')->plainTextToken;
return response()->json([
'access_token' => $token,
'token_type' => 'Bearer',
]);
}
First, we validate the incoming request to make sure all required variables are present. Then we persist the supplied details into the database. Once a user has been created, we create a new personal access token for them using the createToken() method and give the token a name of authToken. Because createToken() will return an instance of Laravel\Sanctum\NewAccessToken, we call the plainTextToken property on the instance to access the plain-text value of the token. Finally, we return a JSON response containing the generated token as well as the type of the token.
Next, create a route for the login user, open routes/api.php, and update the following code into a file:
Route::post('/login', [AuthController::class, 'login']);
Now add login method to AuthController
use Illuminate\Support\Facades\Auth;
public function login(Request $request){
if (!\Auth::attempt($request->only('email', 'password'))) {
return response()->json([
'message' => 'Invalid login details'
], 401);
}
$user = User::where('email', $request['email'])->firstOrFail();
$token = $user->createToken('authToken')->plainTextToken;
return response()->json([
'access_token' => $token,
'token_type' => 'Bearer',
]);
}
Add the routes that require authentication inside the middleware group. As the login route doesn’t use the authentication middleware, it goes outside the middle group.
routes/api.php
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
Route::post('/register',[AuthController::class,'register']);
Route::post('/login', [AuthController::class, 'login']);
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
Now, All sets to go, and Let’s test API routes.
Login User
Get Authenticated User
Thank you for reading this article.
It’d be a good idea to follow along with the simple demo app that can be found in this GitHub repo.
Read Also: Implement Passport In Laravel
Laravel News Links
https://theawesomer.com/photos/2021/04/how_steel_chain_is_made_t.jpg
Think of how strong a steel chain can be. Then imagine the forces that must be necessary to shape and connect its links. In this video from Engineering and Architecture, we get an up-close look at a specialized machine that takes lengths of steel wire, then scores, cuts, bends, and presses the pieces together.
The Awesomer
https://assets.amuniversal.com/b1716a10760001395579005056a9545dDilbert Daily Strip






















