Chinese Scientists Regrow Tooth Enamel In 48 Hours With Phosphate Gel

hackingbear writes: A team of researchers at China’s Zhejiang University were able to create a gel that makes tooth enamel repair itself, they wrote in the science journal Science Advances, a development that could spell the end of fillings as an (unreliable) method to repair cavities which are one of the most prevalent chronic diseases in humans. The gel succeeded in making the enamel repair itself within only 48 hours. Though it now only manages to generate a layer of about 3 micrometres — about 400 times thinner than undamaged enamel, the researcher says the gel could be repeatedly applied to build up this repair layer. The team is now testing the gel in mice and hopes to later test it in people.



Share on Google+

Read more of this story at Slashdot.

via Slashdot
Chinese Scientists Regrow Tooth Enamel In 48 Hours With Phosphate Gel

LEGO Minifig Printing Factory

LEGO Minifig Printing Factory

Link

Beyond the Brick shares a noisy, yet hypnotic look inside one of the production lines at LEGO’s Kladno, Czech Republic, as a nearly endless stream of freshly-molded minifig parts roll out of sifting machines to be stamped with graphics to give them their identities. We love the part at the end showcasing all the designs.

via The Awesomer
LEGO Minifig Printing Factory

A Comparison of Techniques in Defending the Second Amendment

Warning Take Action Call Protest
Warning Take Action Call Protest

United States – -(AmmoLand.com)- In the past months, I have emphasized that it is not enough to fight hard for our Second Amendment rights, Second Amendment supporters need to fight smart, too. In today’s very hostile media climate, the approach we use in defending our rights will define how we come across to our fellow Americans. It might sound repetitive, but as we saw with the Ask Amy column which became a fiasco thanks to responses from some that were ill-thought out (at best), it is necessary.

Loyal Ammoland readers are very passionate about their Second Amendment rights. This is a good thing. When Beto O’Rourke and Eric Swalwell talk about mandatory buybacks of modern multi-purpose semi-automatic firearms, they seek to perpetrate an injustice in the form of punishing millions of Americans who did nothing wrong by infringing on their rights.

They are in the wrong, along with Everytown for Gun Safety, Michael Bloomberg, March for Our Lives, the Brady Campaign, and other anti-Second Amendment groups and politicians.

Those who have stood against the injustices that those groups seek to inflict on law-abiding Americans, like the NRA, and other pro-Second Amendment groups, are in the right by defending the Constitution and the Bill of Rights.

But while we know the facts and the truth about the purpose of the Second Amendment’s protection of our natural rights, far too many Americans don’t. How we talk about Second Amendment issues could determine if these Americans eventually see things our way or if they instead choose to go along with the likes of Beto O’Rourke, Eric Swalwell, Cory Booker, and Dianne Feinstein.

The fury we all feel about the intended infliction of injustice is a righteous anger. However, if we let that anger control us, we risk doing more harm than good. So, I’d like you to put yourself in the position of a suburban parent. They don’t own guns, they work, they take their kids to school and soccer games, and their knowledge of Second Amendment issues is often what is in the local paper and the news. You’re a neighbor they’ve been on friendly terms with, and maybe they’ve seen you wearing a NRA hat or noticed something that reveals your Second Amendment support. I’ll post two responses to a possible question or statement they might ask or make. Then ask yourself which one would be more likely to convince you to support the Second Amendment.

“That school shooting was horrible, why did it happen?”

  1. “People – real, live, allegedly lucid people – actually believe that this ‘shooting’ was real? Wow. That is difficult to believe. Just watch a single one of the interviews of the crisis actors involved and tell me with a straight face that the person has just witnessed about a dozen people being gunned down.”
  2. “I think wild guesses about what caused this won’t do anybody any good. It’s better to wait for the facts to find out what happened in this case. Right now, I’m just keeping the victims in my prayers.”

“Some Congressman wants to ban assault rifles and require people to turn them in. Do you think that’s a good idea?”

  1. “From my cold dead hands.”
  2. “What he is proposing is the infliction of a massive injustice on millions of Americans who had nothing to do with this or any other shooting by infringing on their rights. Justice Department statistics show that rifles of all types are used in murders less often than clubs, bare hands, or knives.”

“What is so bad about a red flag law?”

  1. “This American ain’t surrendering anything!”
  2. “The problem is that many of the proposals have serious problems, including a lack of due process and the failure to require those who are subjected to extreme risk orders to receive mental health treatment. In addition, civil commitment is another legal option on the books for individuals who are a threat to themselves or others. Sadly, those currently in office are unable or unwilling to use that option as well. But they are almost immediately demanding new laws in the wake of these tragedies.”

“But how can we address gun violence?”

  1. “Could you please kindly pull your head out of your butt, STFU and go away…. pretty please?”
  2. “There are solutions. We could enforce existing laws on the books to put away people with criminal records that illegally possess firearms. We can use harsh sentences for those who misuse guns in the course of committing crimes. We also support better policing. All too often, these tragedies can be prevented with tools that are available, but which those currently in office are unable or unwilling to use. Yet they are always demanding new laws on guns that target law-abiding citizens.”

“Why do you oppose universal background checks?”

  1. “Get your skull out of your backside and start standing firm on the constitution and the Second Amendment as written.”
  2. “Because background checks have not worked to prevent crime. Justice Department studies show that criminals acquire their guns illegally, usually through straw purchases, theft, or the black market. And mass shooters often pass background checks. Furthermore, in the past, anti-Second Amendment groups opposed instant background checks in favor of waiting periods.”

“So why do you oppose a license and registration for guns when we need a license to drive a car?”

  1. “Every one of these schemes are just a way to infringe and violate the Second Amendment rights of citizens.”
  2. “Licensing and registration schemes only would apply to law-abiding citizens. Courts have ruled that those prohibited from owning guns cannot be required to register guns, because it would violate their right against self-incrimination. In any case, criminals break the law to acquire their guns, usually through theft, straw purchases, or on the black market. Furthermore, some of the initial licensing laws, like New York’s Sullivan Act, were intended to deny Irish and Italian immigrants the right to have handguns for personal protection. Furthermore, many groups seeking gun control want registration in order to facilitate confiscation – which would be a massive injustice against millions of law-abiding Americans who have committed no crime.”

Again, I would encourage loyal Ammoland readers to compare these responses, placing themselves in the position of a fellow American who is on the fence, or leaning toward backing anti-Second Amendment legislation. Ask yourself, “Which response is more likely to make me more willing back the Second Amendment, or at least be willing to hear more?” Once you have come up with the answer, act accordingly.


Harold Hu, chison

About Harold Hutchison

Writer Harold Hutchison has more than a dozen years of experience covering military affairs, international events, U.S. politics and Second Amendment issues. Harold was consulting senior editor at Soldier of Fortune magazine and is the author of the novel Strike Group Reagan. He has also written for the Daily Caller, National Review, Patriot Post, Strategypage.com, and other national websites.

The post A Comparison of Techniques in Defending the Second Amendment appeared first on AmmoLand.com.

via AmmoLand.com
A Comparison of Techniques in Defending the Second Amendment

The DIY Guide on How to Buy Your Own Military Humvee

Military Humvee Right Quarter.
Military Humvee Front.
Military Humvee Left Qaurter.

The M998 High Mobility Multipurpose Wheeled Vehicle—or Humvee for short—first saw service with the U.S. military in 1984. In the intervening years, AM General produced 281,000 of these remarkable little trucks. Versatile, agile, powerful and tough, the Humvee transported a generation of soldiers on their various tactical missions around the globe. I was one of them.

Hornady RAPiD Vehicle Safe drawing

RELATED STORY

VIDEO: Hornady Unveils RAPiD Safe 4800KP & RAPiD Vehicle Safe

After some 33 years of hard service, the Humvee’s manifold strengths and scant weaknesses became apparent. The M998 was originally designed as a broad-application utility vehicle intended to support a military engaged in fighting World War III on the verdant plains of Western Europe. That the Humvee rendered such fine service when pressed into ambulance, ammo carrier, guided missile platform and armored gun-truck roles speaks to the remarkable versatility of the design.

Today’s asymmetrical battlefield, with its copious ambushes, IEDs and suicide bombers, was not the environment for which the Humvee was imagined. Nowadays, our troops downrange need something more mine resistant and better able to cope with the ubiquitous small arms and RPG attacks that define modern war. As a result, Uncle Sam is replacing Humvees in certain applications with the new Joint Tactical Light Vehicle (JTLV). While the Humvee will still be used in non-combat military roles for the foreseeable future, the advent of the JTLV offers a unique opportunity for American military vehicle enthusiasts. There are some pitfalls to consider, but if you have ever wanted your own Humvee, this is your chance.

Military Humvee: Where To Start

Ironplanet.com is a typical place to start. Its stock rotates daily, and its Humvees are sold via online auction. There are several other auction sites as well. Google is your buddy. The Humvees are being released directly from military installations all over the country. Each entry describes the vehicle’s location, odometer reading and other particulars. Auction prices typically run from $6,000 to 12,000 depending upon the state of the truck.

There are some basic questions answered for each particular entry, including ease of starting, effectiveness of the parking brake and condition of things like the seats, mirrors, gauges and lights. You’ll find detailed photographs. Some Humvee listings include the results of their most recent oil analysis. Certain sites offer video walkarounds as well. They really do a good job of offering a detailed remote description. The overall ambience is not unlike that of CarMax. Once you find the vehicle you want and win the auction, the real fun begins.

The vehicle transfers on a Form SF97 rather than a conventional title. A Humvee in this condition is not legal on public roads. This means you will have to make a road trip with a trailer to fetch your prize. There are fairly tight time limits involved, so plan your purchase when you have a little time.

Red Tape

These Humvees are sold as off-road vehicles only. This means they lack VINs and license plates. While this may be adequate for certain well-heeled folks with land or the occasional hunting club, the rest of us want a truck we can drive around town. Here your adventure takes on the complexion of your home state.

There are some states where you just cannot get these vehicles titled. To compare my home state of Mississippi to California or New Jersey, for instance, is like comparing Mayberry to Mars. In some states, emission controls and general draconian government crap conspire to make it all but impossible to own surplus military vehicles. If you live in one of these wretched locales, my advice would be to move.

By contrast, down here in the Deep South, we take our small government seriously. The titling process is laborious, but it can be done. You may have to take your truck to an inspection site so Highway Patrol inspectors can give it a once-over. I asked the nice Southern lady on the phone if I could drive the vehicle there or trailer it. She counseled that, so long as I explained to any law enforcement officers that I was driving it to get an official inspection, I should be good. I do so love the Deep South.

Title & Insurance

Once it gets a clean bill, you can apply for a title using the vehicle’s military serial number. Expect this to be onerous and complicated but doable. A local buddy bought eight of these things as an investment. Now, nine months later, two of them are still awaiting titles.

If all that seems too big a hassle, just pull up eBay and type in “military Humvees for sale.” You can find plenty of trucks with clean titles, but you pay a bit of a premium to have someone else manage the titling headaches. Be sure to check with your local tag folks to make sure the title will transfer to your state before you put money down.

I have used USAA for all my insurance needs since the moment I first donned a military uniform. I have nothing but good things to say about their customer service. However, after an hour on the phone, we determined that they simply could not insure a military-surplus vehicle. Not to fret, however; they transferred me to a contracted subsidiary. I ended up landing state minimum insurance on my Humvee registered as a farm truck through another car insurance company for next to nothing.

You do shoulder some liability with these vehicles. They are typically old, and you have no way of verifying their maintenance histories. Just remember that somebody has to pay for all those attorney billboards lining every major thoroughfare in America. Don’t let it be you.

Personal Wheels

My truck is 25 years old and reads just over 10,000 miles on the odometer. Keep in mind that military miles are not the same as civilian miles. The high-mileage, ragged-out vehicles we used when I was a soldier sometimes didn’t have more than 25,000 miles on them. My truck may indeed sport 110,000 miles, or it might have languished behind a National Guard armory someplace, essentially undriven for the past 25 years. I have no way of knowing. The chassis looks like it was stored outdoors for the past quarter-century, which it was, while the vehicle itself is mechanically tight and reliable.

The body on a military Humvee is made from riveted sheet aluminum, so it is all but impervious to corrosion. The steel bits will have varying degrees of rust, but that is addressed easily enough. The neatest thing about my Humvee, however, is that it is designed from the outset to be easily maintained. Even the bolts are designed so you can get at most of them with either standard or metric wrenches. I dedicated a couple of hard days to exploring and tweaking my truck and got almost everything of significance addressed. Quality desert tan Rust-Oleum spray paint doesn’t match perfectly, but it is a military vehicle, so that really doesn’t matter.

truckvault, strike guard technology, truckvault strike guard technology

RELATED STORY

TruckVault’s Strike Guard Technology: Next-Level Security

Military Humvee Final Touches

The military Humvee does not have ignition keys. Instead, there is a retractable cable underneath the dash that affixes around the steering wheel with a padlock. However, lots of folks sell aftermarket keyed ignition switches for $65 to $80. Installation requires that you open up the hole in the dash with a step drill bit, but this isn’t tough to do.

I sanded out the ugly spots and touched everything up with spray paint. My daughter and I crafted some stencils to customize the fenders, and I applied the unit designation of my first combat unit. I built up a pair of seat bottoms for the rear seats myself.

My tricked-out Humvee turns heads no matter where I go, and it’s simply great fun to drive. The 6.2-liter diesel engine should last a lifetime, and the truck has plenty of space and power for around-the-farm utility tasks. If you have ever considered a military vehicle of your own, now is the time. Useful, versatile and cool, a GI-surplus Humvee is, for the time being, within financial reach of the common man.

This article is from the August-September 2019 issue of Personal Defense World magazine. Grab your copy at OutdoorGroupStore.com. For digital editions, visit Amazon.

The post The DIY Guide on How to Buy Your Own Military Humvee appeared first on Personal Defense World.

via Personal Defense World
The DIY Guide on How to Buy Your Own Military Humvee

‘Why PHP Still Beats Your Next Favourite Alternative’

Long-time Slashdot reader Qbertino writes: On PHPday in Verona (Italy) Rasmus Lerdorf, creator of PHP, gave an enlightening talk on PHP and its history. 25 years of PHP (video of the talk) is ripe with details on PHP, the design choices behind the web’s favorite server-side templating language and with explanations on why what you may think of as an inconsistent mess actually makes perfect sense just the way it is. Very insightful, fun, interesting and a must-watch for PHP lovers and haters alike. Introducing one slide, Lerdorf remembers that in the 1990s, "the web looked like this — CGI bins written in C." But he also shows his first computers from the 1980s at the beginning of the talk, before moving on to screenshots of Gopher, and then of the Mosaic browser. "This changed everything. And not just for me, for everybody… "Everybody around at the time, playing with this stuff, and having had UUCP addresses and playing with Usenet and bulletin boards — it was very easy to see that this was going to change the world."



Share on Google+

Read more of this story at Slashdot.

via Slashdot
‘Why PHP Still Beats Your Next Favourite Alternative’

6 Ways to Add a Chat Room to Your Website

When you start a new website, the first thing you need is a reputable web host. For WordPress sites, we highly recommend WP Engine, which handles all the hard work of site management for you. If you don’t mind getting your hands dirty, then InMotion Hosting and Bluehost are both viable options as well.

Next up, you might wonder: “How can I add a free chat room for my website?” To foster more real-time communication between users of your site or the readers of your blog, chat rooms can come in handy.

Fortunately, several free chat room services allow you to create your own room. They either provide a simple link to that room, or let you add that chat room to your site. Ready to start? Here are some of the best online chat rooms that you can easily add to your website.

1. Chatzy

Chatzy Chatroom Website

Chatzy lets its users create public and private chat rooms. It provides a link to that room, which you can easily link to on a webpage or in an email. The site offers several ways to customize the chat experience to suit your needs. If you register on the site, you can view your Chatzy room list, making your chats easy to keep track of.

You can easily create a chat by selecting Start Quick Chat. After you input your name and subject, you can enter the room. Clicking Invite/Share on the left menu bar will provide you with a share link.

To embed a private chat room on your website, head to Hosted Rooms on the left menu bar. This page gives you instructions on how to customize your chat room, as well as how to embed the provided code into your site.

2. Tlk.io

Tlk.io Chatroom Website

Tlk.io lets you simply start an online chat room, making it one of the best chat room sites like Chatzy. As soon as you enter the website, Tlk.io asks you to input a channel name, as well as your nickname. Clicking Join brings you to your very own chat room. Copy and paste the chat room’s URL in the address bar to place in emails or on your social media page.

To embed Tlk.io into your website, scroll down on the homepage until you see a button that says Get Embed Code. This option allows you to name your channel, choose a chat room height, and even pick a theme. Copy the generated code on the right side of the screen, and add it to your website to make a chat room in an instant. Tlk.io’s convenience can even make it a great team communication alternative to Slack.

3. Dead Simple Chat

Dead Simple Chat Chatroom Website

To get started on Dead Simple Chat, you have to register for an account. After that, the site will direct you to your dashboard where it shows you the shareable link to your chat room, and also gives you the code to embed it on your website.

If you want to customize your chat room, click Chat Rooms on the left menu bar. Under the chat room of your choice, click Chatroom settings. You can then change the sidebar and background color of your chat room, as well as change its name. When you’re done, click Update Chat Room, and then hit Embed Chat Room to copy and paste the code into your webpage.

Dead Simple Chat also offers several paid plans. With the Pro Plan, you can have up to 2,000 different users, an unlimited amount of chat rooms, and storage for up to 180 days.

All of these perks prove that you don’t need the features of Facebook Messenger in order to communicate effectively.

4. Minnit

Minnit Chatroom Website

Like Dead Simple Chat, Minnit also requires you to sign up in order to create a chat room. Once you create your account, navigate to the Quick Links dropdown menu, and click Create your own chatroom in less than a minute. Input your chat room name, description, and then decide if you want to make your chat private or public.

Minnit will then create your chat and will ask you which plan you want. The free plan offers unlimited messages, up to 40 users, and lets you censor certain words. If you decide to upgrade to one of the paid plans, you’ll get more customization options.

When you’re ready to embed your chat room into your site, head to the page of your chat room, and then select Embed Your Chat. If you have already set up a WordPress blog, you can use the Minnit plugin to add a chat room. You can also use the Wix plugin to add Minnit to your website, or you can simply copy and paste its code onto your own domain.

5. RumbleTalk

RumbleTalk Chatroom Website

If you’ve tried embedding a chat room into your website in the past, you might remember ParaChat. Since ParaChat has closed, RumbleTalk serves as its alternative. You must register for an account before you create your chat room with RumbleTalk.

To customize your chat room, head to Design in the top menu bar. You can then insert a background image, edit text color, change your font, and even add a skin.

If you want to monetize your chat, RumbleTalk has settings for that as well. Head to Monetize on the top menu bar, and input your PayPal information. Rumbletalk also offers paid plans for an increased amount of chat seats and rooms.

When you’re ready to embed your chat room, click Embed on the top of the page. Select Get Code to copy and paste the code right on your website.

6. Pure Chat

Pure Chat Chatroom Website

If you don’t know how to add a chat room to your website, Pure Chat will walk you through the steps. Create an account, and you can then access all of its helpful features. Its free live chat gives you plenty of customization options, allows you to transfer files, and even lets you have unlimited chat rooms. For more than three users, you’ll have to upgrade to one of Pure Chat’s paid plans.

After you register, Pure Chat will give you a code that lets you embed Pure Chat into your website. When you’re ready to chat, you can have conversations from your site, and from Pure Chat’s mobile app.

Web Chat Communication Made Simple

Embedding a chat room on your website doesn’t have to involve any complicated coding. In fact, it only requires you to install a widget, or simply copy and paste a code that the chat room creator generates for you. Choose one of these options from this online chat website list, and you’ll have a reliable way to communicate with your readers, customers, or your team.

Want to extend your conversations to your smartphone and your computer? Check out these messaging apps that you can use on your phone or computer.

Read the full article: 6 Ways to Add a Chat Room to Your Website

via MakeUseOf.com
6 Ways to Add a Chat Room to Your Website

Why One Mom Decided to Get Her Concealed Pistol License

I decided to obtain my concealed pistol license (CPL) about six years ago. While I really never intended to carry a gun, my husband was taking the class, so I figured, why not take it, too? I could always learn more about guns, and I liked the idea of knowing I could carry one if I choose to. I wanted the training to teach me what it meant to carry and the fundamentals of how to be a responsible gun owner, and I liked the idea of personal protection, but I never thought to take it to the next level.

Much more than a handgun goes into completing a good Concealed Carry Rig.

RELATED STORY

Everything to Consider When Setting Up a Concealed Carry Rig

My husband always carries a gun, so I didn’t feel the need to carry, myself. I saw the struggle my husband went through with finding the proper holsters, pants and shirts to carry concealed, and I just couldn’t imagine the struggle that would entail for a woman. Women are built totally differently than men are. I like my yoga pants, tight jeans and tank tops. But then I had a child, and the whole game changed. I decided it was time to start carrying a gun when I went out, especially when my husband wasn’t around.

Carry Complications

To his dismay, I started out carrying in my purse, but I soon found that off-body carry wasn’t the best option for me for several reasons. First, toddlers always seem to want to dig around in purses—maybe it’s because of all the goodies us moms keep for our children in there. Second, if someone was going to attempt to rob me, what’s the first thing he’d probably go after? That’s right, my purse. The same purse that has my gun resting inside that’s supposed to be available for me to use to protect myself from someone who might attack me. Now the bad guy not only has my purse but also my gun, and that would be a very bad day for me indeed.

I then tried carrying inside the waistband of my pants. That didn’t work either, as I still prefer tighter clothing, so carrying was extremely uncomfortable for me. I would have to purchase a whole new wardrobe. But as much as I love buying clothes, I hated the idea of buying bigger clothes. I looked into bra holsters and outside-the-waistband holsters, tried some of my husband’s holsters and even resorted to not carrying a gun at all. It took being followed around a local grocery store by two mid-30s men to get smart about safety.

Danger Comes

I knew the two guys were following me when they continued to go out of their way to watch my every move. And I noticed eye contact and gestures out of the corner of my eye. I could feel my anxiety and adrenaline skyrocket, and I was sick to my stomach, so I kind of panicked. Then I went through the checkout line, paid for my groceries and sprinted out into the parking lot. I locked my doors and sped out of there just as the men approached my car. I felt terrified.

While I should have called the police and found a store employee to help me, but panic overshadowed my rational thinking because I knew I didn’t have a way to effectively protect myself. No gun, no knife, no pepper spray, nothing. I felt helpless. At that moment, I knew I never wanted to feel that way again, so I gave in and decided to start buying some larger clothes in order to carry concealed inside my waistband. With proper clothing and the right holster, this proved to be the best option for me. Slowly, concealed carry became a normal part of my everyday life.

Concealed Pistol License Holder: Always On Alert

As I get older, I really don’t trust anyone. My friends think I’m kind of crazy and somewhat paranoid because I’m constantly screening and watching people when we go out. I’m also the only individual in my group of friends who has a CPL and one of the only ones who’s into guns and shooting. I’m always aware of my surroundings when I’m by myself or when I’m with my son, who’s almost five years old now. Scanning, people watching, observing cars, noting how long people are standing around and their body language, observing who’s around me when I get out of my vehicle and even paying attention to where I park at the store—all of this makes me a much safer person but also generates a bit of ridicule from friends and even family.

My son knows that both my husband and I carry guns. He saw and held my gun; he knows it’s not a toy. He’s been around guns his entire life, so he knows exactly why my husband and I carry, and he understands it’s a secret that no one else should ever know. Before he can even hold a gun in our home, he must tell us the four rules of gun safety. We raised him to respect guns and knows that they’re for protection and to keep us safe.

We promised him his first gun for his 5th birthday, and he’s beyond excited to be just like mommy and daddy. The fact that my son has been exposed to and knows so much about guns at his age brings its own challenges in today’s world. I have family and friends who act like we’re bad parents because we carry guns. People judge us daily and sometimes even ridicule us if they see a photo of Colton with a gun.

Encouraging Concealed Carry for Women

RELATED STORY

Why Concealed Carry for Women Is Both Necessary and Important

Why I Do It

I feel in control and have more confidence when I carry a gun. I know I have the ability to effectively protect myself and my family if a situation arises. Most close friends understand what my husband does for a living. He has his Federal Firearms License (FFL), teaches concealed pistol license classes and is a professional photographer in the firearms industry, so they just assume that at least one of us is carrying when we go out. It’s a hot topic, and it does make me a bit nervous to meet new parents during play dates or while out with new people. What if they ask what our professions are? Or what if they aren’t gun nuts like us? What if we’re judged for what we do or how we’re raising our son?

I always approach the subject openly; I want others to understand why I carry and why it’s a benefit to them, even if they don’t understand. And I cannot allow or rely on anyone else but myself to protect me and my family. The first time we met one of Colton’s friends’ parents, we were extremely nervous. What if they asked about our careers? Should I order a beer, or do they not drink? As we introduced ourselves, we noticed that the other dad was wearing an NRA cap. Yep, instant friends. I breathed a sigh of relief knowing that we all could talk about guns and my husband’s job. Hell, their son had already started shooting at their home range!

Living the Concealed Carrier Life

But I certainly don’t go out of my way to talk about my concealed pistol license and carrying if I don’t have to. With all of the recent child abductions, I’m even more observant of what’s going on around me, especially when I have Colton with me. I’m on especially high alert when we go out into a public play area. I literally size up anyone who looks suspicious or even remotely gives me bad vibes. I will protect my son with my life, even if that means I’m reaching for the gun on my hip.

This article is from the August-September 2019 issue of Personal Defense World magazine. Grab your copy at OutdoorGroupStore.com. For digital editions, visit Amazon.

The post Why One Mom Decided to Get Her Concealed Pistol License appeared first on Personal Defense World.

via Personal Defense World
Why One Mom Decided to Get Her Concealed Pistol License

Eloquent Subquery Enhancements in Laravel 6.0

Eloquent Subquery Enhancements in Laravel 6.0

If you’ve been following my work for any length of time, you know that I am a big fan of pushing more work in our Laravel applications to the database layer. By doing more work in the database we can often reduce the number of database queries we make, reduce the amount of memory our applications use, and reduce the amount of time required by Eloquent to process our models. This can result in some pretty significant performance wins.

One excellent way to push more work to the database is by using subqueries. Subqueries allow you to run nested queries within another database query. This can be a powerful way to retrieve ancillary model data, without making any additional database queries, when it’s not possible to do via a relationship. You can also use subqueries in order by statements, where statements, and other database clauses.

During my Laracon US 2019 talk, I made reference to a couple of query builder macros I’ve been using that make it easier to use subqueries in Laravel. I’ve since submitted three pull requests to Laravel to add these to the core framework.

Here’s an overview of each:

“Select” subqueries

Pull request #29567 adds support for subqueries to both the select() and addSelect() query builder methods.

For example, let’s imagine that we have a table of flight destinations and a table of flights to destinations. The flights table contains an arrived_at column which indicates when the flight arrived at the destination.

Using the new subquery select functionality in Laravel 6.0, we can select all of the destinations and the name of the flight that most recently arrived at that destination using a single query:

return Destination::addSelect(['last_flight' => Flight::select('name') ->whereColumn('destination_id', 'destinations.id') ->orderBy('arrived_at', 'desc') ->limit(1) ])->get(); 

Notice how we’re using Eloquent to generate the subquery here. This makes for a nice, expressive syntax. That said, you can also do this using the query builder:

return Destination::addSelect(['last_flight' => function ($query) { $query->select('name') ->from('flights') ->whereColumn('destination_id', 'destinations.id') ->orderBy('arrived_at', 'desc') ->limit(1); }])->get(); 

“Order by” subqueries

In addition, pull request #29563 makes it possible to use subqueries in the query builder’s orderBy() method. Continuing our example above, we can use this to sort the destinations based on when the last flight arrived at that destination.

return Destination::orderByDesc( Flight::select('arrived_at') ->whereColumn('destination_id', 'destinations.id') ->orderBy('arrived_at', 'desc') ->limit(1) )->get(); 

As with selects, you can also use the query builder directly to create the subquery. For example, maybe you want to order users based on their last login date:

return User::orderBy(function ($query) { $query->select('created_at') ->from('logins') ->whereColumn('user_id', 'users.id') ->latest() ->limit(1); })->get(); 

“From” subqueries

Finally, pull request #29602 makes it possible to use subqueries within the query builder’s from() method. These are sometimes called derived tables.

For example, maybe you want to calculate the average total donations made by users in your application. However, in SQL it’s not possible to nest aggregate functions:

AVG(SUM(amount)) 

Instead, we can use a from subquery to calculate this:

return DB::table(function ($query) { $query->selectRaw('sum(amount) as total') ->from('donations') ->groupBy('user_id'); }, 'donations')->avg('total'); 

You probably won’t need to use this every day, but when you do need it, it’s indispensable.

One breaking change to be aware of if you’re using Eloquent outside of Laravel is a signature change to the table() method on the Illuminate/Database/Capsule/Manager object. It’s been changed from table($table, $connection = null) to table($table, $as = null, $connection = null).

Learn more

If you’re interested in learning more about subqueries and other advanced database techniques, be sure to follow my blog, and also watch my Laracon US 2019 talk.

At Laracon I also announced a new video course I’m working on called Eloquent Performance Patterns. My goal with this course is to teach Laravel developers how to drastically improve the performance of their Laravel applications by pushing more work to the database layer, all while still using the Eloquent ORM. Be sure to join the mailing list for that if you’re interested!


Filed in: News


Enjoy this? Get Laravel News delivered straight to your inbox every Sunday.

No Spam, ever. We’ll never share your email address and you can opt out at any time.

via Laravel News
Eloquent Subquery Enhancements in Laravel 6.0