Understanding the Levenshtein Distance Equation for Beginners

I recently came across a situation where I needed fuzzy string matching functionality for a command line application I built. After googling a way to do this in Ruby, I found a Stack Overflow post…


Using multiple connections with Laravel 5.5

if you are looking for one way of use two databases (or more) with laravel, keep reading, this article will teach you how you can do it, and it is more easy than you expect!

first of all, you can’t use the DB facade, i mean, you can set a connection with it like this:

but using DB facade you need set the connection in every query, and it is very ugly!

let’s see a example:

first set two protected variables called $connection and $table, in your model, in $connection set the name of the connection you want use, then in $table, set the table name.

after that, just create a function and use the own class instance to create your query like in the example above.

don’t forget of set the connections in your .env and database.php file like below:

the first mysql connection is your default connection, then the second you can use as you want.

if you want import the model to make queries directly in your controller methods, just import them and make the query like below:

that’s it! :)

Add a comment

Related posts:

When You Look

A Poem That Perceives Your View. “When You Look” is published by WOLRAD. Read more

How To Increase Connect Rates During Summer

Summer is officially here! It’s the season for late nights, backyard BBQs, pool parties, and of course — vacations. In 2017, Americans spent more than $100 billion on summer travel and vacations… Read more

Meet Goldfinch

Hello everyone! Not so long ago, Goldfinch Flight Academy appeared and I decided to participate in it. I want to tell a little about her, as I think it will be interesting for you and you want to… Read more