5 Good 9mm Luger Loads for Personal Defense

5 Good 9mm Luger Loads for Personal Defense

https://ift.tt/2U5EooR

The 9mm Luger is everyone’s caliber. The 9mm is a powerful number well-suited to personal defense. The 9mm easily jolts 115 to 124-grain bullets to well over 1100 fps. +P or higher-pressure loadings may reach 1300 fps.

The 9mm is not quite as good as some of its fans think, but it is a better cartridge than most of its detractors would have you believe. It has evolved into perhaps the ideal personal-defense caliber for most users.

The 9mm uses a .355-inch bullet. It cannot do the work of larger calibers, but it certainly outclasses smaller calibers. The 9mm offers all of the recoil most shooters are willing to master.

A number of very experienced shooters choose the 9mm based on excellent control, good practical accuracy and a good reserve of ammunition. A compact 9mm Luger handgun is easily controlled with practice.

A compact .40 S&W handgun or .38 Special small-frame revolver may be a bear to handle. Some of the finest handguns in the world are chambered for the 9mm Luger cartridge.

Many affordable handguns are chambered in 9mm as well. It is important to choose a loading with a good balance of expansion and penetration.

The 9mm needs good expansion to be effective, and all calibers must exhibit adequate penetration for good effect. Non-expanding FMJ loads have proven ineffective. The search was on for five good 9mm defensive loads.

Underwood 9mm Expansion
Underwood’s 124-grain 9mm exhibits good expansion.

When I was given this assignment, I resolved to test each loading not only for reliability and accuracy, but wound potential as well. I tested the loads without regard to advertised velocities or overstated claims.

There is a lot of misinformation regarding wound potential. A lot of folks don’t understand that questioning the veracity of a source is instrumental to understanding and using sources.

Misinformation is staggering. I use water for testing penetration and expansion because it is within 10 percent of gelatin results and much, much easier to work with.

While some will say this isn’t valid compared to gelatin testing, the answer is of course it is. As I stated, water and gelatin testing are very close to one another, usually within 10 percent in penetration and expansion results.

Neither bears a close correlation to flesh and bone. The primary advantage of gelatin is that the wound channel may be observed and even preserved. Water only supplies the end result. On the other hand, my work is easily double-checked.

I tested many loads, but ended up with five that I feel fill the most important niche roles of the 9mm Luger. I think they are excellent loads. For testing, I used a GLOCK 19 9mm handgun.

A handgun with a shorter barrel may be expected to produce less velocity, while a longer-barrel handgun will exhibit greater velocity.

With modern loads, the difference in expansion and penetration may be slight in either barrel length. Reliability is 100 percent in these loads. Accuracy is consistent at 15 yards.

1. Hornady 100-Grain Critical Defense Lite

This loading fills the need for a low-recoil loading for those of small stature, particularly in a compact handgun. Older shooters may also feel a need for lower recoil.

The Hornady load functions well despite lowered bullet weight. Velocity averaged 1140 fps. Penetration was 12 inches of water and expansion averaged 0.59 inches.

This is a credible choice that will serve well for recoil-shy shooters or those using the smallest 9mm handguns.

Hornady Lite 9mm Luger Ammo
The Hornady Lite 9mm 100-grain loads exhibit good expansion.

2. Fiocchi 115-Grain Extrema

This is a good go-anywhere, do-anything load. It works fine in every 9mm I have fired, and offers good accuracy and a clean powder burn. The 115-grain Fiocchi Extrema isn’t loaded too hot or too light, it is just right! Accuracy is excellent. The load averaged 1160 fps. Penetration was 16 inches and expansion a very consistent 0.55 inches.

Fiocchi Extrema
Fiocchi 9mm has proven reliable and accurate in a variety of the author’s handguns.

3. Hornady 115-Grain Critical Defense

The Critical Defense uses a polymer plug to instigate expansion. This works well against a variety of material. The Hornady Critical Defense load is loaded to 1151 fps.

Penetration was ideal at 16 inches, and expansion was excellent at 0.58 inches. This is a good general-purpose defense load.

Hornady Critical Defense 9mm Luger
Note excellent expansion with the Critical Defense bullet.

4. Underwood 124-Grain JHP

I wanted to test at least one +P or maximum-effort loading. The Underwood loading clocks 1302 fps average. Recoil was the greatest of any load tested.

We probably would not use this one in a sub-compact pistol. Recoil would be greater, and greater slide velocity may lead to malfunctions. The load was reliable in the GLOCK 19 and accuracy was good.

Penetration was 18 inches and expansion the greatest of the test at 0.82 inches. That is a lot of wound potential.

Underwood 9mm Luger Ammunition
The Underwood load is high velocity and high energy, but did not exhibit excessive pressure signs.

5. Buffalo Bore 147-Grain JHP

Buffalo Bore also offers fast-stepping 9mm loads in 115 and 124-grain weight. I wanted to test a heavyweight 9mm. The industry standard for the 147-grain JHP seems to be 960 to 1000 fps.

This loading breaks 1047 fps average in the GLOCK 19. This is excellent velocity for a 147-grain bullet, yet recoil isn’t excessive. Reliability is good.

If you have the need for deep penetration against heavily-clothed attackers or feel that light cover is part of the likely scenario, this is a good choice. Penetration was 20 inches and expansion was a reliable 0.56 inches.

Buffalo Bore 9mm Luger Ammo
The Buffalo Bore 147-grain heavyweight is an interesting number.

When you choose personal safety gear, choose what is optimum for your use, not what is popular. Obtain training and build skills, or else resign yourself to defense at arm’s length.

Decide that defending yourself is possible, not impossible. It fails the power of my pen to describe the fear of a fight fought to the finish. Avoid it at all cost, but by the same token, be prepared with the best gear and supplies possible.

What is your favorite 9mm Luger defensive load? Why? Let us know in the comments section below!

Get the Best Deals on Guns, Ammo & Gear sent 3 days a week.


guns

via The Shooter’s Log https://ift.tt/2VbyLGM

June 3, 2020 at 08:43AM

SQL Query Formatting Tools Used At Percona

SQL Query Formatting Tools Used At Percona

https://ift.tt/305WbQy

SQL Query Formatting Tools

SQL Query Formatting Tools Used At PerconaPercona engineers often need to analyze and review complex SQL database queries. Good formatting can make these SQL queries much easier to understand and work with. Without clear formatting, queries can become confusing and hard to debug.

Online query formatting services provide one set of solutions. Examples are Code Beautify, FreeFormatter, and sqlformat.org. However, many users are not comfortable sharing their queries with third-party services, especially if your SQL code contains confidential information.

This article examines alternatives to online tools for SQL query formatting tools that have been successfully used by Percona engineers. These solutions come in different types:

  1. Plug-ins to your code editor or IDEs.
  2. Database Management tools
  3. Terminal Tools

Let’s examine these options.

Code editor or IDE

Most modern code editors have functionality or plug-ins for formatting queries. We checked Visual Studio Code and Sublime because these popular code editors are available for Linux, Mac, and Windows.

Visual Studio Code knows how to format SQL queries, as well as available Extensions for working with databases, for example, “SQLTools – Database tools”. Sublime does not have SQL formatting as standard functionality, but it is easy to add it through Package Control. Several packages are available for Query formatting, and we used Sql​Beautifier.

In this case, you need to copy the request to the code editor and save it to a file. It turned out that most of the Percona team use console tools.

SQL query formatting

Sublime

 

DBA tools

Special database management and monitoring software also have functionality for query formatting.

MySQL Workbench

MySQL Workbench enables a DBA or developer to visually, generate, and manage databases.

The Workbench allows you to format an SQL query into a new SQL tab and click the “Beautify/reformat the SQL script” button.

SQL query formatting

 

Percona Monitoring and Management (PMM)

Percona Monitoring and Management (PMM) is a free, best-of-breed, open-source database monitoring and management solution. PMM has the useful functionality of PMM Query Analytics, which allows you to immediately view requests in formatted form.

percona monitoring and management

 

Terminal tools

The most popular console tool for formatting queries in our team is sqlparse (sqlformat). The developers of the popular online service SQLFormat were very kind and provided the source code of their excellent tool (sqlparse). This simple and useful tool you can use on different platforms.

Docker

If you love Docker and do not want to install the tool on your system. Percona Support Engineer Agustín Gallego has packed the data script into a docker. Here is a simple instruction on how you can use it.

shell> docker pull guriandoro/sqlparse:0.3.1
shell> docker run --rm \
>   --network=none \
>   guriandoro/sqlparse:0.3.1 "SELECT several, columns from a_table as a join another_table as b where a.id = 1;"
SELECT several,
       columns
FROM a_table AS a
JOIN another_table AS b
WHERE a.id = 1;

Cool, right? 🙂

Ubuntu

It’s very simple, install the sqlformat package.

# apt install sqlformat

$ echo "SELECT several, columns from a_table as a join another_table as b where a.id = 1;" | sqlformat - -r -k upper
SELECT several,
       columns
FROM a_table AS a
JOIN another_table AS b
WHERE a.id = 1;

Mac

Install sqlparse using brew or another way to use the command sqlformat.

# brew install sqlparse

# echo "SELECT several, columns from a_table as a join another_table as b where a.id = 1;" |  sqlformat - -r -k upper

SELECT several,
       columns
FROM a_table AS a
JOIN another_table AS b
WHERE a.id = 1;

VIM

And if you love and use VIM, you can also install sqlformat and use it.

vmap <leader>sql :%!sqlformat - -r -k upper<CR>

Sqlformat in VIM

Conclusion

We looked at Sqlparse and Sqlformat tools and their use on Linux, Mac, or Windows. We would like to note that it is very convenient for developers to use the Code Editor or IDE, especially if you become a regular user. Additionally, specialized database software such as MySQL Workbench or PMM can help with query formatting. These are SQL query formatting tools that the Percona team has utilized successfully. Share your experience with these or other tools here in the blog comments.

technology

via MySQL Performance Blog https://ift.tt/1znEN8i

June 3, 2020 at 10:03AM

How Bathtubs Are Made

How Bathtubs Are Made

https://ift.tt/3dmVWVa

How Bathtubs Are Made

Link

South African bathroom fixture company Ceramic Industries takes us inside of their Betta Baths factory for a look at the production process for its bathtubs. Each one starts out as a flat sheet of acrylic, which is then heated and formed using vacuum molds, covered with a fiberglass and resin spray, then baked.

fun

via The Awesomer https://theawesomer.com

June 1, 2020 at 06:01PM

Killhouse Rules.

Killhouse Rules.

https://ift.tt/3dqzEBL

Today I was introduced to a set of rules that are too damned true. We all know them in one way or another or at least have the concepts, but it is good to see them formatted.

Enjoy!

guns

via https://gunfreezone.net

June 1, 2020 at 03:27PM

Perfectly Preserved 1,700-Year-Old Roman Mosaic Floor Found Under Vineyard in Italy

Perfectly Preserved 1,700-Year-Old Roman Mosaic Floor Found Under Vineyard in Italy

https://ift.tt/3eCmzWg

Officials in Negrar di Valpolicella, an Italian village midway between Milan and Venice, have made a startling discovery several meters below a vineyard: A perfectly preserved mosaic floor dating back to the 3rd Century A.D.

In 1922, hints of a Roman villa had been discovered on the site, but no successful excavations had been performed until now. "After countless decades of failed attempts," the municipality writes on their Facebook page, "part of the flooring and foundations of the Roman Villa have been located."

Uncovering the floor completely "will not come soon," the municipality writes, pointing out that "significant resources will be needed." They are also working "to identify the most suitable ways to make this archaeological treasure available and open and visible under our feet."

fun

via Core77 https://ift.tt/1KCdCI5

June 1, 2020 at 10:11AM

Learn How to Make Pretzels from Auntie Anne Herself on Facebook Live

Learn How to Make Pretzels from Auntie Anne Herself on Facebook Live

https://ift.tt/3gDawK3

Whether you got your Auntie Anne’s pretzel fix at the mall or the airport (do they exist anywhere else?), you may be missing those salty, buttery treats now that we’re not spending much time in either place. If this is the case, mark your calendar for Sunday, May 31 at 4 p.m. EST, when THE Auntie Anne herself (the chain’s founder Anne Beiler) will be doing a Facebook Live pretzel-making tutorial. The virtual class will take place at the home of the company’s current president, Heather Neary, but don’t worry: Auntie Anne herself will be there and doing the rolling.

The Auntie Anne’s pretzel recipe

Technically, they want you to order their DIY At-Home Pretzel Kit for the event, which, for $20, comes with most of what you need to make 10 pretzels, either in their original or cinnamon sugar flavor. Butter—a key component of these pretzels—is not included in the kit.

But if you don’t have time to order a kit, or want to save some money, there are several Auntie Anne pretzel copycat recipes out there, including these from Food.com, The Spruce Eats and Once Upon a Chef. The main thing you’ll be learning from Auntie Anne during the tutorial is how to actually form the pretzels, so making your own dough shouldn’t be an issue.

Back by popular demand

The DIY At-Home Pretzel Kits were initially a limited-time special for National Pretzel Day, but ended up being so popular, the company brought them back. “We heard from our guests loud and clear that they are missing our hand-rolled, golden brown pretzel snacks, and quite frankly, we’re missing our guests, too!” Neary said in a statement. “The DIY At-Home Pretzel Kit is not only a great way to satisfy those pretzel cravings, but also creates a fun activity for families to enjoy together while remaining at home.”

Even if you aren’t able to join the Facebook Live demonstration, the video will remain up on the Auntie Anne’s page after that for a quick tutorial whenever you have the time. Now every day can be Pretzel Day!

geeky,Tech,Database

via Lifehacker https://lifehacker.com

May 30, 2020 at 02:08PM

Laravel Packages I never wanna miss again

Laravel Packages I never wanna miss again

https://ift.tt/3eAWcQG

Let’s talk about my favorite topic: Laravel.

In Laravel, I often had the situation that I started building something where a package is already there out in the wild. Since I recognized that also for not so common topics packages are existing but also for niche problems, I check google out first before I start programming things. Best example:

I started building my own tax list for my first Product smartdb.io, where I have Stripe implemented for the billing. While researching for the way of writing the reverse charge on the receipt, I found the package from Marcel Pociot which is solving my problems totally: Vat Calculator

But now my list of Packages which I never wanna lose again:

Livewire

Writing reactive UIs is not so intuitive with vue. Ok, you can get it on your plate fast what you have to do, and packages like Interia.js are adorable, but this is nothing compared to livewire. With vue and laravel, you have to create a REST API first and then fire queries and requests to it. Or use Inertia.js, of course, this is making your life easier. With livewire, you can write everything directly in PHP, no need for big JS things. If you want to create something minimal but reactive like the burger-menu on your page, you can use alpine.js. Alpine.js is minimal and functional like tailwind, just check it out.

Horizon

Horizon is a package for managing your queues. It’s so lovely how easy it is to manage multiple, autoscaling queues with it. You can define what queues should run, how much throughput they can have and also what for timeouts etc. they have. Also, the failed jobs are visible in the UI, that’s so good!

Nova

If you didn’t buy Laravel Nova yet, go for it! It’s such a good admin-tool for all your apps, and you can just pay for it if you go live with your app because the license is not limited at your local machine, only for production apps. I also build whole management apps with nova. For example, our Community “Bitkom”: We made a management System for online orders with it, and just with it and mailgun.

Laravel Gravatar

No need for explanation: Never build an upload for an avatar in your MVP again. Here is the package: thomaswelton/laravel-gravatar

Telescope

Debugging your laravel web-application never was more comfortable than with telescope. It’s so pleasant for development purposes. GitHub

socialite

With Laravel socialite, the Social authentification is so secure and comfortable. You want your users to login with GitHub, Facebook, Google, or others? With socialite, it’s done in under 5 minutes. Get it

Cashier

If you start your own SaaS or Shop with laravel, you’ll have the moment to collect money from your users. With cashier and Stripe, it’s easy. Cashier link

Sushi

Sushi was a sponsor package from Caleb Porzio, which is creating Eloquent Models from an array instead of a database connection. Now it’s free to get here: GitHub. I can describe my use-case of this package at best with “better ENUM”. I use it for long lists of countries, specs, or others that are more or less static, for example, taxes, AWS region mappings to AMIs, and such things.

Laravel Debugbar

You all should know it. I use it for years, and I love it. I’ll not explain it too much, but you can debug your MySQL queries, Gates, views, and all other things you need to debug with it. You see how many Queries are executed, you see which views got rendered and all these goodies. Get it

To be honest, I think this list is not complete. Maybe I’ll add a second list and a third and so on. But for now, these are the packages I don’t want to miss.

programming

via Laravel News Links https://ift.tt/2dvygAJ

May 29, 2020 at 10:06AM

Fisher Space Pen Short Video & Pen Review

Fisher Space Pen Short Video & Pen Review

https://ift.tt/2XeVwu5

Fisher Space Pen — the only pen that writes frozen, under water, and in zero gravity — will be heading back to space with NASA astronauts tomorrow, if all goes according to plan. And that’s what didn’t happen a couple days ago, when the SpaceX launch was delayed.

Here’s a short video about that and about the company’s past & current contributions to the writing industry; the only ballpoint pen that’s been on every manned American space mission since Apollo 7, and a newer all-brass pen with antimicrobial properties (popular lately due to the COVID-19 coronavirus scare).

At the 2020 SHOT Show Range Day this past January, I was the happy recipient of a Tradesman Yellow Cap-O-Matic Space Pen, which I immediately put to work.

Two views of my Tradesman Yellow Space Pen (Photo © Russ Chastain)
Two views of my Tradesman Yellow Space Pen
(Photo © Russ Chastain)

The SHOT Show is a busy time, with dozens of meetings and new products each day. While I keep extensive notes electronically on my phone, there’s no substitute for jotting down a quick handwritten note on a business card or pamphlet to remind you of that moment in time once you get back to your room — and eventually back home. After a whirlwind like the SHOT Show, that stack of business cards you amassed won’t mean much without those scribbles telling to to send email, write up a new product, or contact the company for a review sample.

My usual drill is to pick up free pens here & there on the Show floor, and find out which ones are useful via “trial by fire.” Different pens “like” different surfaces, and not every one will write on every business card or slick printed brochure.

This time, I used my Space Pen almost exclusively for all of that work, with no letdowns. My only “iffy” note was on a very shiny business card, on which most pens won’t write well. The Fisher pen wrote well, but the slick surface didn’t allow the ink to soak in at all, and some of the ink was wiped off with handling before it dried.

In other words: the Fisher Space Pen is the best pen I’ve ever owned.

The two parts of the pen body are threaded together, with the pressurized ink cartridge inside. (Photo © Russ Chastain)
The two parts of the pen body are threaded together, with the pressurized ink cartridge inside.
(Photo © Russ Chastain)

It’s the Cap-O-Matic model, which is a click-to-retract style of pen… but instead of a button at the back end of the pen, you “click” the entire rear cap portion (the part with the clip). The entire mechanism is contained in that cap; the lower part is a painted brass tube containing the ink cartridge.

I do a lot of workshop work, which is tough on my things… things like clothes, phone cases, and pens. After 4 months of tough service, my Tradesman pen is doing just fine, with the only casualty being a little lost paint & exposed brass.

My pen has lost a little paint during 4 months of hard use. (Photo © Russ Chastain)
My pen has lost a little paint during 4 months of hard use.
(Photo © Russ Chastain)

Perhaps best of all, it’s easy to spot and easy to identify; there’s very little chance anyone can pick it up and walk away with your pen, thinking it’s theirs — and if you leave it lying on a workbench or desk, it’s easy to spot among the clutter. The Tradesman bright yellow finish is glossy and covers every exterior surface of the pen, including the inside of the clip.

All Fisher Space Pens are lifetime guaranteed for quality against all manufacturing defects.

Company longevity is always a concern when you read the words “lifetime guarantee,” but when a company has been making good on their Space Pen products for more than helf a century, you can have confidence in their staying power.

After the Show, I ordered two more Cap-O-Matics; one in TrueTimber Strata Camouflage and one in the Firefighter motif.

Cap-O-Matic Space Pens in Firefighter (top), TrueTimber, and Tradesman Yellow (bottom). (Photo © Russ Chastain)
Cap-O-Matic Space Pens in Firefighter (top), TrueTimber, and Tradesman Yellow (bottom).
(Photo © Russ Chastain)

The TrueTimber version is a wrap, which means there’s no camo below the clip. It has a slightly-textured finish, which is nice for gripping the pen. This is the pen I can see hunters carrying to fill out their hunting licenses or tags, often with shaking (and possibly bloody) hands. There’s no doubt it’ll do this job better than most, and should have no problem writing on your tags.

Firefighter version of Fisher Cap-O-Matic Space Pen. (Photo © Russ Chastain)
Firefighter version of Fisher Cap-O-Matic Space Pen.
(Photo © Russ Chastain)

The Firefighter model has an all-over matte black finish enhanced by red lines on the pen clip and the lower body of the pen. It writes like a champ, and for every one sold, Fisher will make a donation to help injured firefighters and their families.

Each Cap-O-Matic Space Pen comes in this attractive "shuttle gift box." (Photo © Russ Chastain)
Each Cap-O-Matic Space Pen comes in this attractive “shuttle gift box.”
(Photo © Russ Chastain)

Engraving is available on some models, including the Red Line Firefighter and Blue Line Police models, with the first line free (up to 30 characters/spaces per line). Up to two more lines can be added at $4 per additional line, for a maximum of 3 30-character lines.

Some people don’t carry a pen. That’s cool; no worries. But I have long been one to carry a pen most of the time. Need to fill out a form or sign a receipt? Use your own pen, not some grubby cheapo that’s been handled by every snot-wiping nose-picker who came before you. Need to endorse a check or fill out a deposit form at the bank? Same thing.

Although I don’t worry about my current Fishers wearing out, I can’t help but drool a little over the original AG7 Astronaut Pen or maybe even the black Titanium Nitride version. Decisions, decisions…

And if you’re going to carry a pen, you might as well make it a good one with a lifetime guarantee. That’d be Fisher Space Pen of Boulder City, Nevada, USA.

The post Fisher Space Pen Short Video & Pen Review appeared first on AllOutdoor.com.

guns

via All Outdoor https://ift.tt/2yaNKUu

May 29, 2020 at 01:40PM

How to filter a list using Laravel query builder and checkboxes

How to filter a list using Laravel query builder and checkboxes

https://ift.tt/3gxVQfq

Let’s set the stage…

We have a list of products that we need to filter. For example, we have a storefront that sells sporting apparel. Each product has a brand (Nike, Adidas etc.) and a category (t-shirts, shoes etc.). We’ll show brands and categories as a list of checkboxes. The user should be able to click on the desired brand and/or category (one or more), then click filter, which will refresh the page showing the filtered results.

Packages

The only package we’ll be using is Spatie’s Laravel query builder. It extends Laravel’s default Eloquent builder by making filtering through large lists easier. Check it out on Github or on Spatie docs. I’ve started using it recently and it has a very fluent API.

Schemas

These models have typical one-to-one relationships, product-to-brand and product-to-category.

I’ve kept the columns to a bare minimum. Product table looks something like this:

$table->text('id'); $table->text('name'); $table->text('description'); $table->text('category_id'); $table->text('brand_id'); $table->text('thumbnail')->nullable(); $table->text('large_preview')->nullable(); 

Category table:

$table->text('id'); $table->text('name'); 

Brand table:

$table->text('id'); $table->text('name'); 

Layout

To get a feel of what this looks like on the front end, we have a column on the left side which lists brands and categories. Each item has a checkbox. The user can check the desired checkbox items and click the filter button.

laravel query builder checkboxes

Below is the snippet for the left panel blade partial. I’ll skip the styling.

<p>Brands</p> @foreach ($brands as $brand) <label class="m-checkbox"> <input name="brand" type="checkbox" value="" @if (in_array($brand->id, explode(',', request()->input('filter.brand')))) checked @endif >  </label> @endforeach <p>Categories</p> @foreach ($categories as $category) <label> <input name="category" type="checkbox" value="" @if (in_array($category->id, explode(',', request()->input('filter.category')))) checked @endif >  </label> @endforeach <button type="button" id="filter">Filter</button> 

Everything is pretty straight forward. The @if conditional is there so once the form is submitted, we can catch the selected id’s through request() object and use them to tick the checkboxes.

Product list renders something like this, again skipping the styles.

@foreach ($products as $product) <p></p> <p></p> <button>Add to Cart</button> <hr> @endforeach 

Javascript

Laravel query builder can filter models based on URL parameters. We’ll use javascript to refresh the page with selected brands and categories. We’re trying to stay away from submitting forms with arrays as names. I have not really found a good way to submit form arrays without swapping brackets with URL safe characters. The query string doesn’t looking appealing when you swap it out. JS method will keep the URL pretty. This also keeps the request() object variable clean, plus it opens the door to other ideas, like submitting through Ajax or Livewire.

<script> function getIds(checkboxName) { let checkBoxes = document.getElementsByName(checkboxName); let ids = Array.prototype.slice.call(checkBoxes) .filter(ch => ch.checked==true) .map(ch => ch.value); return ids; } function filterResults () { let brandIds = getIds("brand"); let catagoryIds = getIds("catagory"); let href = 'products?'; if(brandIds.length) { href += 'filter[brand]=' + brandIds; } if(catagoryIds.length) { href += '&filter[category]=' + catagoryIds; } document.location.href=href; } document.getElementById("filter").addEventListener("click", filterResults); </script> 

When the filter button is clicked, you can collect all the id’s for brand and category. Internally, the getIds function collects all the checkboxes with brand or category names, then filters through, collecting the values of checked checkboxes.

document.location.href=href refreshes the page with the url containing the brand and categories to filter.

document.getElementById("filter").addEventListener("click", filterResults); adds the click event to the filter button.

Controller

The index controller below, without URL parameters, will show all the products. When url parameters are supplied, products will be filtered. Check out Spatie docs for more options.

public function index() { $categories = Category::all(); $brands = Brand::all(); $products = QueryBuilder::for(Product::class) ->allowedFilters([ AllowedFilter::exact('brand', 'brand_id') AllowedFilter::exact('category', 'category_id'), ]) ->get(); return view('products.index', compact('products', 'brands', 'categories')); } 

I hope this helps in your filtering with Laravel project. If you have a question, drop a comment and I’ll be sure to get back to you.

programming

via Laravel News Links https://ift.tt/2dvygAJ

May 28, 2020 at 10:06AM