teleren/devto huggingface dataset:
How to use Soft Delete in Laravel 8
Tags: beginners, laravel, womenintech, codenewbie
Published: 2021-09-14 17:40:54

In this blog post we are going to see what is Soft Delete and why we need it in our laravel application.

__What is Soft Delete and Why we use it?__
Soft delete will not totally remove data from database instead it will prevent data from selecting or mark record for deletion.
For example if we accidentally deleted data from database we cannot retrieve or restore it easily and will cause issue if it has been used within our project. To prevent it laravel provide support for `Illuminate\Database\Eloquent\SoftDeletes` trait which enables the functionality of soft delete. It means we can add Soft delete in our Eloquent model.
  
__Let us see how to use it__.

First we need to decide for which model we need to set it and add `use SoftDeletes` in that model with this `Illuminate\Database\Eloquent\SoftDeletes` trait, this trait will automatically cast deleted_at attribute DateTime/Carbon instance for us.

__For example__ we have the functionality where we delete user instead hard delete now we will use soft delete in User's model. 

Use the below code to add it in your application
```php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class User extends Model
{
    use SoftDeletes;
}
```

When we use it, it will set `deleted_at` attribute, as well as we can also add `deleted_at` field/column to our database, for that laravel schema builder has provided a helper method as given below.

```php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Schema::table('flights', function (Blueprint $table) {
    $table->softDeletes();
});

Schema::table('flights', function (Blueprint $table) {
    $table->dropSoftDeletes();
});
```
When we delete data it will add current date n time in `deleted_at` field. When we fetch list of users from, the soft deleted users will automatically be excluded from all query results.

If we want to see the soft deleted data we can fetch it with help of `trashed()` method provided by Soft delete.

```php
   $user->trashed()
```

1. It also provide `restore()` method to restore soft delete data.

```php
   $user->restore();
```
2. This method is also used in query to restore multiple/mass data. 

```php
 User::withTrashed()
        ->restore();
```
3. If we want to fetch the record with soft deleted data we can use it `withTrashed()`

```php
User::withTrashed()->get();
```

4. When we want to permanently delete data we can force delete it by using 
```php 
$user->forceDelete();
```
5. If we want to fetch only soft deleted data from Users we can retrive it with help of `onlyTrashed()` method.

```php
User::onlyTrashed()->get();
```

We have seen multiple methods provided by soft delete. It means we can fetch, restore data with help of them.

Thank you for reading. :unicorn: :unicorn: :lion:
Part # 4: Class and Objects in Java | Java Tutorial for beginners 2021 | Java OOPs basics
Tags: java, beginners, class
Published: 2021-09-14 17:40:02

I have explained Class & related concepts of it detail that beginners can easily understand. 

Here is Timeline : 

00:00 Introduction to Video 

00:20 What is Class? 

00:42 Create First Class 

04:07 What is Object & Create it 

07:27 Setter 

11:14 Static Members 

12:35 Getter 

13:36 Calculator Assignment 

{% youtube cdFGLzHLoTM %}
JavaScript Reusable Constants that are used in most apps.
Tags: languages, countries, javascript, npm
Published: 2021-09-14 17:40:00

## Constants.js

- [Installation](#installation)
- [Usage](#usage)
- [Available Constants](#available-constants)

## Installation

```
npm i constants-js
```

## Usage

```js
// ES6
import { languages } from "constants-js";

console.log(languages);
```

## Available Constants

| Name                  | Variable Name | Type   | Example Output                                                                     |
| --------------------- | ------------- | ------ | ---------------------------------------------------------------------------------- |
| Continents            | continents    | Array  | [{ africa: { label: "Africa", code: "AF" },... ]                                   |
| Countries             | countries     | Array  | [{ name: "Afghanistan", dial_code: "+93", code: "AF" }, ...]                       |
| Duration              | duration      | Array  | [ { label: "day", value: 8.64e7 },... ]                                            |
| Islamic Months        | islamicMonths | Array  | [ { label_en: "al-Muharram", label_ar: "ٱلْمُحَرَّم", value: 0 },...]                  |
| Languages             | languages     | Array  | [{ code: "ab", name: "Abkhazian" }, ...]                                           |
| Lower Case Characters | lowerCases    | Array  | ["a", "b", "c",...]                                                                |
| Months                | months        | Array  | [{ label: "January", value: 0 }, ... ]                                             |
| Numbers               | numbers       | Array  | ["0", "1", "2",...]                                                                |
| special Characters    | specialChars  | Array  | ['!', '"', '#',...]                                                                |
| Upper Case Characters | upperCases    | Array  | ["a", "b", "c",...]                                                                |
| Week Days             | weekDays      | Array  | [{ label: "Sunday", value: 0 }, ... ]                                              |
| Status                | status        | Object | { continue: 100, switching_protocols: 101, processing: 102 }                       |
Model Training Patterns - Useful Overfitting
Tags: machinelearning, datascience, python
Published: 2021-09-14 17:36:56

Creating a machine learning model involves training loops. With each training iteration, we try to improve the model. Generally, we use  **Gradient Descent (GD)** to determine the model parameters. However, for larger datasets, **Stochastic Gradient Descent (SGD)** is preferred. It is the same as gradient descent, however, it operates on mini-batches of the data set. 

> Extensions of SGD - **Adam** and **Adagrad** are the de-facto optimizers used in ML frameworks.

A typical Keras training loop looks as follows:

```python
model = Keras.model(...)
model.compile(optimizer=keras.optimizers.Adam(),
              loss=keras.losses.categorical_crossentropy(),
              metrics=['accuracy'])

history = model.fit(x_train, y_train,
                    batch_size=64,
                    epochs=3,
                    validation_data=(x_val, y_val))
results = model.evaluate(x_test, y_test, batch_size=128)
model.save()
```

In this post, we are going to discuss **Useful overfitting**.

Sometimes, it might happen we have the entire domain space of observations at our disposal. In such cases, intentionally overfitting over the entire training dataset without regularization, dropout or a validation or testing set seems to be a good idea as we would want our model to compute the precise solution instead of approximating the solution.

> Overfitting is not a concern if all possibly inputs are trained for.

## Use cases for useful overfitting

1. All possible inputs are available
2. Distilling knowledge of NN: Training a smaller model with data generated from a very larger model
3. Overfitting a batch

### Overfitting a batch

Overfitting on a small batch can be considered to be a good sanity check. If a model is not able to, then something might be wrong with the model or it's training process.

So, ideally, we should look for a model which should overfit over the training set. Once we find such a model, we can apply regularization to improve the validation accuracy and focus less on training accuracy.
How to Get Email from HTML Form Using PHP | HTML Form to Direct Mail
Tags: programming, php, html, webdev
Published: 2021-09-14 17:21:37

Hi, In this video I will show you how to get email from HTML form using PHP and send HTML form to direct mail. A Simple PHP contact form to send email with source code.
How to send an email from a static HTML page using PHP mailer function?
How to send HTML form to direct mail?
How to get an email from HTML form?
How will you send an email using PHP?
How do I send an email from the client side?
Can I send an email from localhost PHP?
How do you check PHP mail () is working?
How to send email to the client in PHP?
PHP mail HTML format not working how to fix?
How does PHP mail function works, YouTube Tutorials?
How do I send emails using a PHP mailer? 
How to send HTML form data to email using PHP?

{% youtube RcN265mm_mw %}

**Send mail PHP**
PHP mail is the built-in PHP mail function that is used to send emails from PHP scripts. It's a cost-effective way of notifying users of important events. Let users contact you via email by providing a contact us form on the website that emails the provided content.


If you found this video helpful please like the video and SUBSCRIBE to this youtube channel to watch more videos like that. What do you think about today's video topic? please share your thoughts and queries in the comments below! 

---------------------------------------------------------
- For Source Code visit this link:
         https://www.hmablogs.com/send-html-form-data-to-email-using-php/

- For Portfolio visit this website:
         https://www.hmablogs.com/

- Please have a look at my blog website to read more!
         https://hmawebdesign.com

- Place an order for any Web Development work!
         https://www.fiverr.com/haaddison1?up_rollout=true
---------------------------------------------------------------
Comparing Web Component Frameworks
Published: 2021-09-14 17:15:23

###Similarities
Angular, React, VueJS, and StencilJS are all frameworks that provide a sort of template for developing web applications successfully.  They make it easy to add features to a web app that have been well developed, used, and tested by others.  The frameworks prevent developers from having to reinvent everything. All of these frameworks had a number of dependencies and they all have HTML files.  Angular and StencilJS use Typescript.  React uses JSX (an extension of JavaScript) and VueJS uses both TypeScript and JavaScript.

###Easiest Developer Experience
The easiest to get going I think would be VueJS.  It was quick to install and seems user friendly.  VueJS is also more flexible and does not seem to have as much of a learning curve as some other frameworks.

###What I would chose
If I had to start building an app tomorrow I would choose React.  Although it took a long time to install, it is a lot of JavaScript which I am familiar with.   Hopefully this would make it pretty easy to start developing with.  It also seems to be one of the most popular frameworks meaning there is a large community of people who like it and would be many resources to refer to.  React is very flexible so a number of different libraries such as, state management and http, can be used with it.  My only concern would be with this flexibility it may be hard to choose between all the tools/options.
Provide a links in your post to your organization as well as the repo that you got your boilerplate from
Here is a link to our team’s boilerplate: https://github.com/table-in-the-corner/boilerplates
Here is a link to the React boilerplate example I used https://github.com/react-boilerplate/react-boilerplate
Manage your Laravel migrations with 1 click!
Tags: laravel, php
Published: 2021-09-14 17:02:48

Have you ever want to migrate a single migration in Laravel?
You need to write a huge line of words in your command line to just migrate a migration.

Or have you ever tried to refresh or reset a migration?
In some cases the migration commands literally aren't understandable and you may wonder what is the `fresh` or `refresh` and should I use `refresh` or `reset` or other commands and what is the difference between them?

Imagine that you have over 10 migrations and you just want to refresh just one of them, to do this you need to execute this command:
```bash
php artisan migrate:refresh --path=database/migrations/2021_09_14_153949_create_products_table.php
```

Hmmm, to me and lots of you it's not enjoyable and also it does take time to write in command line and if we type the wrong name we may lose our data in database.

So what should we do?

Here Migrator comes!

[Migrator](https://github.com/rezaamini-ir/migrator) is a GUI migration manager for Laravel.

With Migrator you can manage your migration as easy as possible in a beautiful user interface.

Migrator features:
- Create new migration
- Migrate all migrations
- Fresh migrations
- Drop a single migration
- Migrate a single migration
- Delete and drop a migration 
- See the status of migrations
- Refresh a migration (Drop then up)
- Show the migration data in a better way!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trwm2moxlrqtr70drb3p.png)

So we have talked about the features, let's install Migrator in a minute.

Installing Migrator is super duper easy, you just need to run a single composer command:

```bash
composer require rezaamini-ir/migrator
```

Congrats! Migrator was installed successfully, now you will be to access the `/migrator` path in your project and if you want to change the authentication method or Migrator route you can publish config file with this command:
```bash
php artisan vendor:publish --tag=migrator-config
```
Then a new file will be created in your `config` directory called: `migrator.php` and you can change the middleware which authenticates the user and also the route of the package is editable.

To read more about the Migrator package you can check out the documentation:
https://github.com/rezaamini-ir/migrator

Don't forget to contribute to the project and Star it ⭐️ :)).
How to Change Text Color in Visual Studio Code in 2021 | VSCode Syntax Highlighting
Tags: vscode, webdev, codenewbie, devops
Published: 2021-09-14 16:42:32

Hi, in this tutorial you will be learn following!
How to change code color in VSCode in 2021?
How to change comment color in vs code?
How to change theme color in vs code in 2021?
How to change the theme in visual studio code?
How to change text color in visual studio code in 2021?
How do I change the color of text in Visual Studio?
how to modify vscode syntax highlighting?
How do you change the color of text in Visual Basic?
How do you change the font color in Vscode in terminal?
How to change VSCode theme color highlighting?
How to modify color settings in visual studio code?
How do you change the vscode highlight color?

**Video Tutorial**
{% youtube suaqd0te9Pw %}

Steps to change the color of the text in Visual studio Code:
1. Start by opening any source code file. 
2. Open the Command Palette (Ctrl+Shift+P) and run the "Developer: Inspect Editor Tokens and Scopes".
3. In this case, we notice it says "No theme selector." That means the tokenColors attribute of the theme is not setting this color, rather it is the ordinary colors attribute of the theme, specifically the editor. foreground color. This can be overridden as in Sean's answer by setting workbench.colorCustomizations in settings.json. 
4. After invoking that command, move the cursor to an identifier. 
5. Copy and paste this code in the settings.json section in your VSCode
6. follow the steps in the video tutorial.

If you found this Tutorial helpful please like the video and SUBSCRIBE to this YouTube channel to watch more videos like that. What do you think about today's video topic? please share your thoughts and queries in the comments below! 

---------------------------------------------------------
- Source Code Link:
         https://www.hmablogs.com/change-color-of-text-and-syntax.../
- Please have a look at my website for more details!
         https://hmawebdesign.com
- Place an order for any Web Development work!
         https://www.fiverr.com/haaddison1?up_rollout=true
---------------------------------------------------------------
Comparison of Boilerplates
Published: 2021-09-14 16:36:18

Similarities between VueJS, Angular, React, and StencilJS:

VueJS, Angular, React, and StencilJS all are javascript based that use it to create their components. Httml and CSS are also commonly found with these four.  The four different boilerplates also come with src and app directories which contain key components in the apps functionality. 
All of these 

Easiest Developer Experience:
VueJS to me has the easiest developer experience because of the components it has. It worked smoothly and was the easiest to understand since I do not have experience with any of these boilerplates. 

Preference:
I prefer the VUE boilerplate because it was the easiest to understand and work with. The app started up quickly and the structure of it was familiar to me due to its similarities and common language. I'd work with this for a project because it was easy to create the set up and work within it and a lot of resources to work with. 

To view the boilerplate I created, follow https://github.com/njd5435/boilerplates.git
To view my groups page, follow https://github.com/table-in-the-corner/boilerplates.git
Build a command line program with commander.js
Tags: javascript
Published: 2021-09-14 16:19:13

# Features 
* It accepts `.txt` files and converts them into `.html` files. 
* User can specify output folder where converted `.html` files will be placed 
* If a **folder** is specified for input, it will look for all `.txt` files in the folder and **subfolder(s)**
* An `index.html` containing links to other `.html` files is generated 

# Usage: 
|  Option |  Description |
|---|---|
|  -V, --version | output the version number  |
| -o, --output <path> | specify a path to output .html files |
| -i, --input <path> | (required) transform .txt files into .html files |
| -h, --help | display help for command |

#Example: 
###### textfiles
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l3b2p9kgkb5uu4k58mvd.png)

###### Silver Blaze.txt 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upyjsay0ck45wr8k7our.png)

After executing  `node index.js -i ./textfiles -o ./output`, `.txt' files will be converted to `.html` files

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02wwdg0epzwiqzf3d3u7.png)

###### index.html 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6vdg9c3ybh4levybwaok.png)

###### The Naval Treaty.html 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gzblincdnjez3f8f6c2.png)

# Notes: 
The program doesn't catch all errors, if you encounter any error please let me know at tnguyen187@myseneca.ca or tuenguyen12329@gmail.com
Simple but Minimal Portfolio template
Published: 2021-09-14 15:51:45


## Simple but minimal Portfolio Website using React and GSAP
  
 Hi everyone, my name is Devang Saklani. I'm a Front-end Developer from India and I've recently built a *Simple portfolio website*  using React and GSAP.
Everyone can use this website and modify it in which ever way they want (no attributions necessary).

Check it out live: https://devang47.github.io/simple-portfolio/
check out the Particle-js version here: https://devang47.github.io/simple-portfolio-with-particlejs/
(Feedbacks will be appreciated) 
Github repo: [here](https://github.com/Devang47/simple-portfolio) 

Lighthouse score:
![Lighthouse score](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8g2wd6hb4dl5wo61my87.png)

I've also added few default themes but You can also make and add your own theme by making a simple CSS Class like:

```CSS
.unique_theme {
	--bg: #0c0f0a;
	--primary: #f8f8f8;
	--secondary: #d1d1d1;
	--highlight: #41ead4;
	--card: #ffffff08;
	--icon-bg: #9e6e6e1a;
	--icon-bg-hover: #ffffff1c;
}
```

and then add this Class to ` <body>` tag in `index.html`.

  

## Available default themes:

- Dark theme

![Dark theme](https://drive.google.com/uc?id=19KnTSs3TE5Md9dgR_qy5-quKHl2EU1Bq)

- White theme

![White theme](https://drive.google.com/uc?id=1FxtgVYUmxu5kSuqQ9M-RPwr4rRBhNXgq)

- Blue theme

![Blue theme](https://drive.google.com/uc?id=1XxR9CQdua3AK9FlCgF80VqIieIZ7rQuU)

- Green theme

![Green theme](https://drive.google.com/uc?id=1i_4D5OsP6Ls_9PDuiZqR9SR8ESI0s4Zu)

## How to change themes

To change themes go to ` index.html ` file and change the class of body tag to the theme name like:

```html
<body  class="green">
```

or

```html
<body  class="dark">
```



### **Update**
Particle JS is also now integrated in a clone of this project 🤩 and it is looking really good: 
Check it out live here: [here](https://devang47.github.io/simple-portfolio-with-particlejs/)
Github repo: [here](https://devang47.github.io/simple-portfolio-with-particlejs/)
![Partile js integrated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uizx33vysq87h70qwoks.png)



If you have any feedback please add a Comment below and Contribute in this project.
How to add an element to an array
Tags: php, array, beginners
Published: 2021-09-14 15:35:24

My first Post as a junior dev (in progress...) to explain how to add an element to an array.

Premier Post en tant que Junior dev(en cours...) pour expliquer comment ajouter un element à un tableau

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oiy7l90ml7dt21xmqmbr.png)
Reduce method to sum values of array of objects
Tags: react, javascript, html, css
Published: 2021-09-14 15:30:27

Hello guys today i am going to show you how to use reduce method to sum up the values of array of objects.

Reduce method - 
The reduce() method executes a user-supplied “reducer” callback function on each element of the array, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.

Perhaps the easiest-to-understand case for reduce() is to return the sum of all the elements in an array.

Here is an example of reduce method
```javascript
import React from 'react'

function App() {

    const data  = [
        {
            Name : "shubham",
            Marks:100
        },
        {
            Name : "bharat",
            Marks:90
        },
        {
            Name : "abhishek",
            Marks:80
        },
        {
            Name : "himanshu",
            Marks:90
        },
        {
            Name : "alfiya",
            Marks:68
        },
        {
            Name : "akshay",
            Marks:79
        }
    ];

    var total = data.reduce((accum,item) => accum + item.Marks, 0)

    return (
        <div>
            {data.map((item) => (
                <div className="m-5" style={{display:"grid",gridTemplateColumns:"repeat(2,1fr)",justifyContent:"center"}}>
                    <p>{item.Name}</p>
                    <p>{item.Marks}</p>
                </div>
            ))}
            <div className="m-5" style={{display:"grid",gridTemplateColumns:"repeat(2,1fr)",justifyContent:"center"}}>
                <p></p>
                <p className="my-5">{total}</p>
            </div>
           
            
        </div>
    )
}

export default App
```

Working - 

1. First we define an array of objects named "data".
2. Then We stored the reduce method in a variable named "total".
3. Then inside reduce method , we have two parameters named "accum" which stands for accumulator and "item" which is the value we need to sum up.
4. accum is started with 0 and then add the Marks of each object item one by one and sum up all the values and return the final result , which is sum of all the values which is passed to the reduce function.
5. Then finally we have mapped the data using map() method and below it we have put the total in a <p> tag which shows the total value on the webpage.


![Screenshot (32)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6wlbesv09r1p4a2hwvyn.png)

NOTE- this is just a demo of reduce() method so, there is not much styling in the webpage!!
 

I hope you understand the concept and if there is any mistake or suggestion then please mention it in the comment section.

THANK YOU FOR READING THIS POST.