teleren/devto huggingface dataset:
Laravel 8 Eloquent whereHas Condition
Tags: laravel, php, laravel8, wherehas
Published: 2022-08-26 03:27:50

In this article, we will see laravel 8 eloquent whereHas() condition. You will learn about wherehas() condition in laravel 8. I will give you simple example of how to use wherehas() condition with laravel 8 eloquent relationship. You can also use the laravel 6, laravel 7, laravel 8, and laravel 9 version.

For wherehas condition in laravel 8 we need two table like users and country and in users tabel add country_id.

So, let's see,  laravel 8 wherehas query or laravel 8 wherehas relationship.

>Example 1 : Laravel whereHas()

Laravel eloquent whereHas() method works basically the same as has() but it just allows you to specify additional filters for the related model to check. 

```
public function index()
{
    $name = 'india';
    $users = User::with('country')
                    ->whereHas('country', function ($query) use($name){
                        $query->where('name', 'like', '%'.$name.'%');
                    })
                    ->get()
                    ->toArray();
}
```
 
---

**_[Read Also: How To Store Data In Database Using Node.js](https://techsolutionstuff.com/post/how-to-store-data-in-database-using-node-js)_**

---
 
> Example 2 : Laravel has()

Laravel eloquent has() method is used to filter the selecting model based on the selected relationship. It works similarly to where method for relations.

```
use App\Models\User;

$users = User::has('country')->get();
```

You may also specify an operator and count value to further customize the query: 

```
$posts = Post::has('comments', '>=', 3)->get();
```
 
> Example : 3

```
app/Models/User.php

<?php
  
namespace App\Models;
  
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
  
class User extends Authenticatable
{
    
    protected $fillable = [
        'name',
        'email',
        'password',
    ]; 
  
    public function country()
    {
        return $this->belongsTo(Country::class);
    }
}
```

app/Models/Country.php

```
<?php
  
namespace App\Models;
  
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
  
class Country extends Model
{
    use HasFactory;
}
```
 
app/Http/Controllers/UserController.php

```
<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use App\Models\User;
  
class UserController extends Controller
{
    public function index()
    {
        $name = 'india';
        $users = User::with('country')
                        ->whereHas('country', function ($query) use($name){
                            $query->where('name', 'like', '%'.$name.'%');
                        })
                        ->get()
                        ->toArray();  
    }
}
```
 
---

You might also like:

**_[Read Also: Laravel whereIn and whereNotIn Query Example](https://techsolutionstuff.com/post/laravel-wherein-and-wherenotin-query-example)_**
State of Denial, a Journey
Tags: react, flatiron, beginners, programming
Published: 2022-08-26 03:19:11



As a Flatiron School student, I just spent a few weeks
studying React as part of Phase 2 of the Software Engineering
program. React builds on JavaScript and is all-around a pretty powerful tool. There are still some quirky syntax requirements, but after being thrown into the deep end while learning JavaScript, it wasn’t too bad. We learned about props and components and that went well enough, but when the conversation turned to state and events, I had a pretty hard time parsing the idea of state in my head.

Dictionaries define state basically as what condition 
something is in. This does work out and is pretty easy to 
understand in some cases. If you have a situation where you’re working with a toggle or something similar, a Boolean value works fine. Then, state actually refers to a condition, true or false. There are situations where you have strings and arrays assigned to a piece of state and I had a very hard time understanding how those things had a “condition”. I resigned myself to working without really understanding state and that led to a decision to move forward without really getting what was in front of me already.

Moving forward at that point was kind of a bad idea. I got
into a situation where I was coding without understanding why I was doing things. I was simply pattern matching and rewriting code without an appreciation of how it worked. This led to a lot of frustration that could have been avoided had I just stuck it out and wrapped my head around what is actually going on with state. My first step was losing this need to have state as used in React match my idea of what book-definition state was.

Assigning a variable to state just allows React to hold on 
to the values of these variables and change them, usually with event handling and will re-render the component when the state is changed. This is why it’s important not to implicitly re-value a variable assigned to state. Doing so will not allow React to keep up with the state and it won’t re-render the page. I was getting lost in the weeds trying to figuring out how adding a new object to an array was fundamentally changing the “state” of the variable. It wasn’t - I was just being kind of  inflexible and not using the term “state” in a way that I hadn’t come across before. Once I understood what state was and what it was doing, I was able 
to get over the fact that it was labeled a word I found misleading at first. 

As I did a lot of reading and panicky searches of “what is 
react state”, I came across the origin of the term. It is 
referring to Finite-State Machines. State machines are not literal machines, but are abstractions with have a number of states which are changed in response to inputs. I wish I had gone down the rabbit hole a lot earlier, as understanding that concept helped me understand state in React. Also, one thing this process has taught me is to walk before you run!
5 Websites That Will Hook You Towards CSS 🚀
Published: 2022-08-26 03:15:00

1. **Complete Guide to CSS Grid**
`https://css-tricks.com/snippets/css/complete-guide-grid`

2. **CSS Selectors Cheat Sheet**
`https://www.sitepoint.com/css-selectors`

3. **Complete Guide to Flexbox**
`https://css-tricks.com/snippets/css/a-guide-to-flexbox`

4. **The Lengths of CSS**
`https://css-tricks.com/the-lengths-of-css`

5. CSS Transitions and Transforms
`https://thoughtbot.com/blog/transitions-and-transforms`
Tip Land the SaaS platform for the tip of the day
Tags: redishackathon, redis, remix, re2stack
Published: 2022-08-26 02:57:46

---
title: Tip Land the SaaS platform for the tip of the day
published: true
description: My submission to the Redis Hackathon on DEV!
tags: redishackathon, redis, remix, re2stack
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vszwudswegfdrvg2ejdb.png
---

### Overview of My Submission

Tip Land is a platform as a service for product creators and that can easily integrate the functionality of the tip of the day.

Many products today include daily tips for their best use in their interface, such as code editors, management systems among many others, Tip Land provides you with a platform with which you can create those tips for your products, through a API Key assigned to your account you can access the endpoint.

Made with **Re2 Stack** 📀 🟥 (_Remix + Redis = Re2 Stack_)

When two blazing-fast technologies come together to bring out the best of each other, something amazing happens:

> In Remix the global state is the database and the database is the cache in Redis Stack.


### Submission Category: 

Wacky Wildcards

### Video Explainer of My Project
{% embed https://youtu.be/yhhfZTNStGw %}


### Language Used
JS/TS/Node.js


### Link to Code

{% embed https://github.com/andreslopezrm/tip-land %}


### Additional Resources / Info

#### Links to open source projects that are using in the workflow

- [Redis](https://redis.io/)
- [Redis Cloud](https://redis.com/try-free/)
- [Redis OM for Node](https://github.com/redis/redis-om-node)
- [Remix](https://remix.run/)
- [Vercel](https://vercel.com/)
- [Clerk](https://clerk.dev/)
- [Tailwind](https://tailwindcss.com/)

**Live Deploy**

- [Tip Land](https://tip-land.vercel.app/)

**Stack**
![Stack](https://tip-land.vercel.app/images/stack.png)



**Database**
![Database](https://tip-land.vercel.app/images/database.png)

#### Screenshots

Social Login
![Social Login](https://tip-land.vercel.app/images/login.png)

Dashboard
![Dashboard](https://tip-land.vercel.app/images/dashboard.png)

Tips
![Tips](https://tip-land.vercel.app/images/tiplist.png)

API Key
![Api Key](https://tip-land.vercel.app/images/apikey.png)

Stats
![Stats](https://tip-land.vercel.app/images/stats.png)



- - - 


* _Check out [Redis OM](https://redis.io/docs/stack/get-started/clients/#high-level-client-libraries), client libraries for working with Redis as a multi-model database._
* _Use [RedisInsight](https://redis.info/redisinsight) to visualize your data in Redis._
* _Sign up for a [free Redis database](https://redis.info/try-free-dev-to)._
Introducing Re2 Stack
Tags: remix, redis, re2stack, node
Published: 2022-08-26 02:53:34

---
title: Introducing Re2 Stack
published: true
description: 
tags: remix, redis, re2stack, node
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43ld8eax02a0nbwo1rpg.png
# Use a ratio of 100:42 for best results.
---


I present to you this new stack that consists of two highly fast technologies that make the development experience really fast.

# Re2 Stack 📀 🟥

The name comes from both technologies starting with the word **Re**, **Re**mix and **Re**dis, so these two (2) technologies make up the stack.


When talking about **Redis** today it is thought that it simply provides a caching mechanism and could hardly be used in other parts that would make up an architecture, however Redis has evolved so much that it can cover many more scenarios, even being the main database without need for no other.

**Remix** on the other hand is a full stack web framework that allows you to focus on the user interface that provides user experience and rapid development.

When two blazing-fast technologies come together to bring out the best of each other, something amazing happens:

> In Remix the global state is the database and the database is the cache in Redis Stack.

The idea of Re2 Stack is to be progressive and two scenarios are proposed here

## Re2 Stack Full Stack Version

In a fullstack scenario, Redis JSON will be used as the main/cache database and Remix will be used to access that data as seen in the following diagram:

![full](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ofaz6xgm4synptbir6jf.png)

Redis Stack through Redis JSON allows you to be a document-oriented database with exceptional speed, through **Redis OM** you can define your schemas, queries, have indexes, any capability that a modern NoSQL database would have, along with To that at the exceptional speed that comes out of the Remix box you have an amazing combination.

An example of this stack is found in the following repository:

{%embed https://github.com/andreslopezrm/re2stack %}


## Re2 Stack Enterprise Version

Business applications normally have an architecture with many components, jobs in queues, asynchronous processes, events, and therefore tend to have technologies from different providers. In a scenario like this, for example:

![stack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zqwso4gsevbbm78i91xt.png)


Now all these components can be simplified and united in a single technology: **Redis**

![join](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31di0obrcskhat4sjktb.png)

With Redis we have all those features in a single stack without having to bundle different technologies separately.

For more information check:

- [Remix](https://remix.run/)
- [RedisEnterprise](https://redis.com/)
- [Redis Stack](https://redis.io/docs/stack/)
- [Redis Cloud](https://redis.com/redis-enterprise-cloud/overview/)
sNationalDaysToday.com - Unite people to celebrate everyday
Tags: sharing
Published: 2022-08-26 02:34:22

NationalDaysToday-com aims to unite people to celebrate and recognize our culture, food, people, pioneers, invincible innovations, nature, and more.

Here you will find some tips for the observance that can be seen in all published topics and learn more about the history, reason, date, day, and other interesting facts of all National Days.

[https://www.nationaldaystoday.com](https://www.nationaldaystoday.com)
War :"Emacs or "Vi" Text Editor
Tags: vi, emacs, bash, webtermina
Published: 2022-08-26 02:32:00

In today’s world, you would not miss anyone using their web browser to search for something on a daily, whether it is internet explorer, Firefox or even chrome .For this case therefore, it brought the rise of using text editors .Emacs and Vi since time memorial have been the go to text editors for software developers .Some prefer using “Vi” others prefer using “Emacs”.

So let us look at the difference between using VI and Emacs as a text editor.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm7paehsmaxels2ibruq.png)
Cant See AdSense Ads
Published: 2022-08-26 02:09:09

There Is No policy issues but ads are not displayed 
please help me to fix this problem 
Ill add the Ad code correctly and wait 9 Day but not Difference
Ads Are not display
Please Check My web site -http://mediauniversitylk.com

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4y9xcc49lruk0s2zgwvd.png)
Criar um ambiente virtual de Python para seus projetos com o VSCODE
Tags: python, ambientevirtual, venv, vscode
Published: 2022-08-26 01:55:00

Em [1](https://dev.to/jfelipeslg/criar-um-ambiente-virtual-de-python-para-seus-projetos-420j), eu mostro o objetivo de criar um ambiente vritual e como criá-los pelo CMD. Neste artigo, irei mostrar como criar ambientes virtuais pelo VSCODE (spoiler: eu, particularmente, acho mais simples!)

Antes de tudo, é necessário considerar que eu utilizo o W10 e o terminal que utilizarei será o bash.

1) Basta abrir a pasta desejada no VSCODE (Arquivo → Abrir pasta)

2) Execute o terminal do bash e digite os seguintes comandos

```
$ python -m venv NOME_AMBIENTE_VIRTUAL
$ source ".\NOME_AMBIENTE_VIRTUAL\Scripts\activate" 
$ python -m pip install --upgrade pip
```

Já acabou! Já é possível usar o ambiente virtual para seus projetos. ;)
Initializing the project
Tags: elixir, algorithms, webdev, tutorial
Published: 2022-08-26 01:39:00

---
series: Rock, Paper, and Scissors with Elixir
---

## About the Project

Now that we know how the game works, let's create the project and some initial settings.

### Creating the project

To create the project, we can run the command:

```Elixir
mix new rock_paper_scissor_elixir --module Game
```

We can specify the main module name of our project by passing `--module NameOfTheModule`. And own main module will call `Game`.

- **Adding the test coverage tool**
As a good practice, we'll create our project with the maximum test coverage. And now we'll add the library test coverage tool: `coveralls`.

```Elixir
# /mix.exs
#...
  defp deps do
    [
      {:excoveralls, "~> 0.10", only: :test}
    ]
  end
#...
```

- **Adding the static code analysis tool**
Now we'll add the lib Credo, a static code analysis tool for the Elixir language focused on helping us maintain the code's quality and consistency.

```Elixir
# /mix.exs
#...
  defp deps do
    [
      {:excoveralls, "~> 0.10", only: :test},
      {:credo, "~> 1.6", only: [:dev, :test], runtime: false}
    ]
  end
#...
```

And then, we need to install the dependencies running this command:

```Elixir
mix deps.get
```

In the next post, we'll build the tests.

#### Contacts
Email: contato@diegonovais.com.br
Linkedin: https://www.linkedin.com/in/diegonovais/
Twitter: https://twitter.com/diegonovaistech
You don't need VSCode to debug your Node.js app [Google Chrome V8 inspect and debugger breakpoint]
Published: 2022-08-26 01:36:07

## **Hi, Devs!**

When we look at Node.js documentation there's a interesting option do debug our code and is [inspector](https://nodejs.org/en/docs/guides/debugging-getting-started/) context

---

Let'a create a piece of code and let's use a `debugger` word that means a _breakpoint_ for our debug process.

```js
//index.js

console.log('hello')
setTimeout(() => {
    debugger
    console.log('After debugger breakpoint')
}, 8000)
debugger
console.log('Finished')
```

For debugger's uses we need to configure one port into an extension of chrome web browser, copy on your web address:

```js
chrome://inspect/
```

Click on configure and add the `localhost:9229` address:

![Node.js Chrome V8 Inspector Debugger](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3vv294u4dnlpzayhvpz.png)
 
We are going to use the command below to start the debugger:

```js
node --inspect index.js
```

After run the previous command --inspect, in the next step we need to click on `inspect` button, below the remote target.

![Debugger V8 Javascript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qmrzssdh78kkd0ura4pj.png)

And will be open the DevTools: 

![DevTools Debugger Javascript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mv4en2b2dj83zevp7p92.png)

And you could use the `next` button on the right of the image above where is writing _Debugger paused_

You could add some expression on Watch to verify some value and into Scope verify the returns.
 
**Contacts**
Email: luizcalaca@gmail.com
Instagram: https://www.instagram.com/luizcalaca
Linkedin: https://www.linkedin.com/in/luizcalaca/
Twitter: https://twitter.com/luizcalaca
Rock Paper and Scissors with Elixir
Tags: elixir, algorithms, webdev, tutorial
Published: 2022-08-26 01:36:00

---
series: Rock, Paper, and Scissors with Elixir
---

Hey, dev!

Let's code the game Rock, Paper, and Scissors in Elixir?

## About the game

The game Rock, Paper, Scissors (aka "Ro-Sham-Bo"; janken; "Bato, Bato, Pick"; and "Scissors, Paper, Stone") is a simple hand game with many names and variations.

In the game, usually, we have two opponents. And the players use their hands to choose and represent one of three items: a rock, paper, or scissors.

## Who wins?

The player who chooses the most powerful object is the winner of the game.

As the picture below:
- Rock breaks the scissor;
- Scissor cut the paper;
- Paper covers the Rock;

![Who wins?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ered8vlgnyz31hb4luij.png)

One crucial detail is that the players can also draw the game when they choose the same item.

In the next article we'll initialize the project.

See ya!

#### Contacts
Email: contato@diegonovais.com.br
Linkedin: https://www.linkedin.com/in/diegonovais/
Twitter: https://twitter.com/diegonovaistech
Definition of Computer Science
Tags: computerscience, programming, philosophy, mathematics
Published: 2022-08-26 01:29:00

"Computer Science" is a very vague term. But a word with at least some definition removes the aura of mystery. This article is my attempt to define what Computer science is.

I define computer science as a field of knowledge that incorporates:
- Programming craftsmanship. Code writing and knowing your tools to facilitate the programming activity and deployment of the result.
- A few sections of mathematics which help to stay rigorous:
- Proof by induction and by contradiction. It helps to convince yourself and others of the correctness of your thought process;
- Discrete math: graph theory. It provides multiple beautiful graph-like and tree-like high-utility structures and algorithms on top of them;
- Number theory. Prime numbers as building blocks specifically. It helps with the understanding of the basics of information security.
- Algorithms and data structures. Asymptotic analysis of their time and space complexity. It answers why one algorithm is faster or better and why one data structure works better for a given task than the other.
- Theory of computation. It answers, on a fundamental level, what is computable—for example, a halting problem.
- Computer architecture. It is helpful to know some basics of the architecture of the computer: Random-Access Memory vs. hard drives, memory registers, CPU cache, etc.

These are the generic parts one will find helpful during their Computer Scientific or Computer Engineering career. I think these are useful for any skilled programmer. However, the discussion about the deepness of each part can last forever.
Breakdown of Declarative vs. Imperative programming
Tags: react, imperativeprogramming, javascript, webdev
Published: 2022-08-26 01:28:00

JavaScript is an outstanding programming language that allows you to write code in different paradigms or combine them into a 'multi-paradigmatic' approach.

But what does that even mean? 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ra5svhj1ox5zu6t3wa3m.png)

A programming paradigm is an approach or a style of writing code. Most of the modern programming languages fall into two general paradigms: **imperative** and **declarative**.



_So what is the difference?_ 



**Declarative** programming is when you say **what** you want, and **imperative** language is when you say **how** to get what you want.



I like to think about it as the _process of ordering a meal_. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/inh76pjpmztxeru7fm0i.png)

**Imperative** goes to a Subway restaurant and wants to order a sandwich. For that he chooses: size, type of bread, meat, veggies, cheese, extra ingredients, and a sauce, he also tells to heat up his bread. The waiter delivers **exactly what** he asked for.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6dqv1g5mddagx2vbe611.jpeg)


On the other hand, **Declarative** goes to McDonald's and tells that he wants a double cheeseburger. Grabs the burger.



**_What is imperative programming?_**
 
Imperative programming is the oldest and most basic programming approach. Within the imperative paradigm, code describes a step-by-step process for a program’s execution.

_Examples of imperative programming languages include:_

- Java
- C
- Pascal
- Python
- Ruby
- Fortran
- PHP

**_What is declarative programming?_**
In contrast with imperative programming, declarative programming describes what you want the program to achieve rather than how it should run.

In other words, within the declarative paradigm, you define the results you want a program to accomplish without describing its control flow.

_Examples of declarative programming languages include:_

- SQL
- Miranda
- Prolog
- Lisp
- Many markup languages (e.g., HTML)

**Let's look at some code:**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddr5ic6coq1mtss3ertw.png)

Declarative programming describes what you’re trying to accomplish without defining how to do it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6yu10o1x3kfw8xneq95.png)

For the first example which is an Imperative programming approach, it usually has more lines code, that’s the very obvious difference. 
Another is, it explicitly follows a step-by-step instruction to get the even numbers from the array. 
While in the declarative programming approach, it leverages an existing function, which is filter.

---

The differences are subtle, but hopefully you have a better background to understand them from now.

With experience, you are able to learn which situations call for which programming paradigms!
I'm Making a Game
Tags: gamedev, unity3d, csharp, programming
Published: 2022-08-26 01:10:00

Hi guys, how's going?
Today's video is to show a small game that I'm currently developing, my main goal is to at least once per day develop the game and finish it, previously I've developed other projects but I didn't finish them, so, this time, I will finish this game and launch it at itch.io.

[Download the game](https://cristovoxdgm.itch.io/keep-beating)

![Game title](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y432pmwdsf5y9k1osolf.png)
{% youtube hpwfUFhyjKk %}