How it Works

How it Works

https://ift.tt/2ZJ1jZO

To get started, let’s review the basics of Livewire and build the obligatory counter example. Next, we’ll take a brief look at the request/response lifecycle of a Livewire component.
View the source code for this episode on GitHub.

programming

via Laracasts https://ift.tt/1eZ1zac

September 16, 2020 at 10:08AM

Basic Data Analysis with MySQL Shell Python mode

Basic Data Analysis with MySQL Shell Python mode

https://ift.tt/2ZFyT2L

I recently watched a fantastic Python Pandas library tutorial series on YouTube. Without a doubt, Pandas is great for all sorts of data stuff. On the same token, MySQL Shell in Python mode is quite powerful in the sense that Python and the MySQL Shell (version >= 8.0) are somewhat united in the same environment. Although Pandas is in a league all its own when it comes to data analysis, between the power of MySQL and Python, we can also perform some basic analysis easily in MySQL Shell Python mode. In this blog post, I will cover some basic data analysis using Python mode in the MySQL Shell. Continue reading to see examples…

OS, Software, and DB used:

  • OpenSuse Leap 15.1
  • MySQL 8.0.21

Self-Promotion:

If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like!


Data Set Used

You can download the Stack Overflow Developer Survey Results data set used in this post for your own exploration if you would like.

Basic Data Analysis with MySQL Shell Python Mode: Connecting, table row and column count, column names

For starters, we use the available global db object and get a connection to an existing table in the database/schema by passing in a name to the get_table() method:

1
 MySQL  localhost:33060+ ssl  learning  Py > data = db.get_table(‘so_data’)

I store the ‘so_data’ table in a shell.Object variable named ‘data’. We can call the count() method against this object and get a count of the total rows in the table:

1
2
 MySQL  localhost:33060+ ssl  learning  Py > data.count()
88883

Related: Read the post, Dynamic MySQL CREATE TABLE statement with pandas and pyodbc, I wrote and see how I dynamically created the ‘so_data’ table and populated it with accompanying data.

Calling the select() method on the ‘data’ object, I can essentially retrieve all rows and columns from the table. However, at this time, I am only interested in the actual column names of the table. I’ll store this result in a ‘rows’ object variable:

1
 MySQL  localhost:33060+ ssl  learning  Py > rows = data.select().execute()

With the ‘rows’ variable, I call the get_column_names() method on it and am returned a Python list of all the table’s column names:

1
2
3
4
5
6
7
8
9
10
11
12
13
 MySQL  localhost:33060+ ssl  learning  Py > cols = rows.get_column_names()
 MySQL  localhost:33060+ ssl  learning  Py > cols
[
    "Respondent", "MainBranch", "Hobbyist", "OpenSourcer", "OpenSource", "Employment",
    "Country", "Student", "EdLevel", "UndergradMajor", "EduOther", "OrgSize", "DevType", "YearsCode", "Age1stCode", "YearsCodePro", "CareerSat", "JobSat", "MgrIdiot", "MgrMoney", "MgrWant", "JobSeek", "LastHireDate", "LastInt",
    "FizzBuzz", "JobFactors", "ResumeUpdate", "CurrencySymbol", "CurrencyDesc", "CompTotal", "CompFreq", "ConvertedComp",
    "WorkWeekHrs", "WorkPlan", "WorkChallenge", "WorkRemote", "WorkLoc", "ImpSyn", "CodeRev", "CodeRevHrs", "UnitTests",
    "PurchaseHow", "PurchaseWhat", "LanguageWorkedWith", "LanguageDesireNextYear", "DatabaseWorkedWith","DatabaseDesireNextYear",
    "PlatformWorkedWith", "PlatformDesireNextYear", "WebFrameWorkedWith", "WebFrameDesireNextYear", "MiscTechWorkedWith",
    "MiscTechDesireNextYear", "DevEnviron", "OpSys", "Containers", "BlockchainOrg", "BlockchainIs", "BetterLife", "ITperson",
    "OffOn", "SocialMedia", "Extraversion", "ScreenName", "SOVisit1st", "SOVisitFreq", "SOVisitTo", "SOFindAnswer",
    "SOTimeSaved", "SOHowMuchTime", "SOAccount", "SOPartFreq", "SOJobs", "EntTeams", "SOComm", "WelcomeChange", "SONewContent", "Age", "Gender", "Trans", "Sexuality", "Ethnicity", "Dependents", "SurveyLength", "SurveyEase"
]

As you can see, there are quite a lot of columns in this table. Instead of counting them myself, I use the Python len() method and get a count of the ‘cols’ list object:

1
2
 MySQL  localhost:33060+ ssl  learning  Py > len(cols)
85

Summary: We can use combinations of MySQL Shell methods: get_table(), count(), select(), get_column_names() and the Python len() method and determine pertinent table meta-data information.

Basic Data Analysis with MySQL Shell Python Mode: Select specific columns, distinct/unique column values, and constraining rows

We learned in the previous section that table ‘so_data’ has over 80k rows of data, along with 85 total columns. That alone is nothing to scoff at. Instead of loading up our screens with many many rows and columns, I’ll utilize several of the available MySQL Shell methods, choosing certain columns and constraining the number of returned rows (if any).

The select() method can accept a list of columns names, separated by commas. In this next query, I specify just the ‘SocialMedia’ column and limit the total number of rows to 10, using the limit() method:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  MySQL  localhost:33060+ ssl  learning  Py > data.select(‘SocialMedia’).limit(10).execute()
+————-+
| SocialMedia |
+————-+
| Twitter     |
| Instagram   |
| Reddit      |
| Reddit      |
| Facebook    |
| YouTube     |
| YouTube     |
| YouTube     |
| Twitter     |
| YouTube     |
+————-+
10 rows in set (0.0010 sec)

Pro Tip: The limit() method parameter is the number of rows you want to be returned from theselect() method.

While the above query does provide good information, suppose we need to know of all the unique values in the ‘SocialMedia’ column. We can easily include the DISTINCT keyword in the call to select() with the desired column name:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 MySQL  localhost:33060+ ssl  learning  Py > data.select(‘DISTINCT (SocialMedia)’).execute()
+————————–+
| SocialMedia              |
+————————–+
| Twitter                  |
| Instagram                |
| Reddit                   |
| Facebook                 |
| YouTube                  |
| NA                       |
| VK ВКонта́кте             |
| WhatsApp                 |
| I dont use social media|
| WeChat                   |
| LinkedIn                 |
| Snapchat                 |
| Weibo                    |
| Hello                    |
| Youku Tudou              |
+————————–+
15 rows in set (0.2199 sec)

Based on the returned query results, we can see there are 15 unique values for the ‘SocialMedia’ column.

Summary: The select() method is capable of choosing either all table columns or individual columns depending on your needs and the column names supplied as parameters. If you need specific columns in your query results, provide those columns separated by commas as parameters to select(). select() also allows MySQL keywords to be included with columns should you need any of them as in the example query using DISTINCT.

On the other hand, constrain the number of output rows returned from any query using the limit() method by specifying the number of desired rows using limit()‘s number parameter.

Basic Data Analysis with MySQL Shell Python Mode: Counting, group by, and other aggregate functions

In the previous section, we executed a query using select() and DISTINCT, retrieving the unique values in the ‘SocialMedia’ column. We have these results from that query:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 MySQL  localhost:33060+ ssl  learning  Py > data.select(‘DISTINCT (SocialMedia)’).execute()
+————————–+
| SocialMedia              |
+————————–+
| Twitter                  |
| Instagram                |
| Reddit                   |
| Facebook                 |
| YouTube                  |
| NA                       |
| VK ВКонта́кте             |
| WhatsApp                 |
| I dont use social media|
| WeChat                   |
| LinkedIn                 |
| Snapchat                 |
| Weibo                    |
| Hello                    |
| Youku Tudou              |
+————————–+
15 rows in set (0.2199 sec)

What is the total number of non-NULL rows for each unique ‘SocialMedia’ column value in the ‘so_data’ table? Can we find out with MySQL Shell Python mode? Absolutely.

We can use the COUNT() aggregate function on the ‘SocialMedia’ column right in the select() method. However, we need a GROUP BY clause in the query as well. MySQL Shell has us covered with a same-named method, group_by().

In this query, I’ll retrieve a count of the actual values in the ‘SocialMedia’ column (ignoring NULL‘s in that count) and group those counts by the ‘SocialMedia’ column:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 MySQL  localhost:33060+ ssl  learning  Py > data.select(‘SocialMedia’, ‘COUNT(SocialMedia) AS num_medias’).group_by(‘SocialMedia’).execute()
+————————–+————+
| SocialMedia              | num_medias |
+————————–+————+
| Twitter                  |      11398 |
| Instagram                |       6261 |
| Reddit                   |      14374 |
| Facebook                 |      13178 |
| YouTube                  |      13830 |
| NA                       |       4446 |
| VK ВКонта́кте             |        603 |
| WhatsApp                 |      13347 |
| I dont use social media|       5554 |
| WeChat                   |        667 |
| LinkedIn                 |       4501 |
| Snapchat                 |        628 |
| Weibo                    |         56 |
| Hello                    |         19 |
| Youku Tudou              |         21 |
+————————–+————+
15 rows in set (0.2566 sec)

Summary: We can easily query using aggregate functions in the select() method and group on appropriate columns with the group_by() method.

Basic Data Analysis with MySQL Shell Python Mode: Filter rows with where and bind query criteria values

The WHERE clause is responsible for filtering out which rows are returned from a query by way of some predicate test. Without a WHERE clause, all rows are returned from a SELECT query. Maybe you want that. Maybe not. If not, use WHERE to filter rows according to your needs.

The WHERE clause is not limited to only the SELECT statement, as it is highly important in the DML commands UPDATE and DELETE. Without a WHERE clause targeting a specific row or rows, all rows are affected – in the case of DML (UPDATE and DELETE) – or returned from a SELECT query. MySQL Shell has a where() method we can use to filter the rows in a select() query just the same as in regular MySQL (or any SQL dialect).

It is generally a good practice not to include potential user input values into our query expressions. Most programming languages have some sort of binding mechanism in place that imposes a sort of parameterized query and/or a prepared statement. Using parameterized queries and prepared statements, we can greatly reduce the risk of SQL Injection attacks.

MySQL Shell has a bind() method we can use instead of directly concatenating values into the query strings of the where() predicate test(s). bind() accepts named parameters (which is what I will use in the examples below) or the universal ‘?’ style of parameter binding.

Readers may be interested in the ‘DatabaseWorkedWith’ column of the ‘so_data’ table so let’s filter that column by rows where the ‘SocialMedia’ column is ‘Hello’ using where() and bind():

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 MySQL  localhost:33060+ ssl  learning  Py > qry_cols = ‘DatabaseWorkedWith’
 MySQL  localhost:33060+ ssl  learning  Py > data.select(qry_cols).where(‘SocialMedia = :soc_media’).bind(‘soc_media’, ‘Hello’).execute()
+—————————————————————————————————————————————–+
| DatabaseWorkedWith                                                                                                                      |
+—————————————————————————————————————————————–+
| Microsoft SQL Server;MySQL;SQLite                                                                                                       |
| Cassandra                                                                                                                               |
| MySQL;Redis                                                                                                                             |
| Microsoft SQL Server;MySQL                                                                                                              |
| NA                                                                                                                                      |
| NA                                                                                                                                      |
| Cassandra;Elasticsearch;Microsoft SQL Server;Oracle;SQLite                                                                              |
| PostgreSQL                                                                                                                              |
| Cassandra                                                                                                                               |
| NA                                                                                                                                      |
| NA                                                                                                                                      |
| DynamoDB                                                                                                                                |
| Cassandra                                                                                                                               |
| MongoDB;MySQL;Oracle;Other(s):                                                                                                          |
| SQLite                                                                                                                                  |
| NA                                                                                                                                      |
| NA                                                                                                                                      |
| NA                                                                                                                                      |
| Cassandra;Couchbase;DynamoDB;Elasticsearch;Firebase;MariaDB;MongoDB;Microsoft SQL Server;MySQL;Oracle;PostgreSQL;Redis;SQLite;Other(s): |
+—————————————————————————————————————————————–+
19 rows in set (0.3925 sec)

In this query, I use bind() and include a matching named placeholder (minus the colon : prefix) and corresponding value for what is specified in the where() method predicate. For example, in the where() method I used the ‘:soc_media’ named parameter and represented it in bind() with ‘soc_media’ and the actual accompanying value, ‘Hello’. Pretty straightforward.


Oftentimes, you need to filter a SELECT query by more than one column or expression using multiple predicates. The MySQL Shell where() method easily accepts multiple predicate conditions just as a regular MySQL WHERE clause would using the AND and OR logical operators.

But, with multiple where() predicates, that also means multiple parameterized values right? Yes, it does.

However, multiple calls to bind() can be chained one after another, for each of the needed bound values. See the following query for a better understanding:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 MySQL  localhost:33060+ ssl  learning  Py > data.select(qry_cols).where(‘SocialMedia = :soc_media AND DatabaseWorkedWith <> :na’).bind(‘soc_media’, ‘Hello’).bind(‘na’, ‘NA’).execute()
+—————————————————————————————————————————————–+
| DatabaseWorkedWith                                                                                                                      |
+—————————————————————————————————————————————–+
| Microsoft SQL Server;MySQL;SQLite                                                                                                       |
| Cassandra                                                                                                                               |
| MySQL;Redis                                                                                                                             |
| Microsoft SQL Server;MySQL                                                                                                              |
| Cassandra;Elasticsearch;Microsoft SQL Server;Oracle;SQLite                                                                              |
| PostgreSQL                                                                                                                              |
| Cassandra                                                                                                                               |
| DynamoDB                                                                                                                                |
| Cassandra                                                                                                                               |
| MongoDB;MySQL;Oracle;Other(s):                                                                                                          |
| SQLite                                                                                                                                  |
| Cassandra;Couchbase;DynamoDB;Elasticsearch;Firebase;MariaDB;MongoDB;Microsoft SQL Server;MySQL;Oracle;PostgreSQL;Redis;SQLite;Other(s): |
+—————————————————————————————————————————————–+
12 rows in set (0.3308 sec)

In the above query, we filtered using where() on columns ‘SocialMedia’ and ‘DatabaseWorkedWith’. For each of the columns, we also include a separate call to bind().

The first bind() method call includes the value ‘Hello’ for the ‘SocialMedia’ column named parameter ‘:soc_media’ and the second bind() method call has the matching parameters for the ‘DatabaseWorkedWith’ with column and the ‘NA’ value for the ‘:na’ placeholder.

Summary: MySQL Shell provides powerful where() and bind() methods for row-filtering needs.


Be sure and check out, X DevAPI User Guide for MySQL Shell in Python Mode, for in-depth information on many of the topics covered in today’s post along with much much more.

Additional MySQL Shell Python mode articles you should read

I have written several blog posts about MySQL Shell Python mode so feel free to check any of those that interest you:


MySQL Shell Python mode is jam-packed with a ton of goodies and features. It opens up new options for working with data in the MySQL ecosystem. If you have not tried MySQL in Python mode, give it a shot. I am quite sure you will really like what you see.

Like what you have read? See anything incorrect? Please comment below and thanks for reading!!!

A Call To Action!

Thank you for taking the time to read this post. I truly hope you discovered something interesting and enlightening. Please share your findings here, with someone else you know who would get the same value out of it as well.

Visit the Portfolio-Projects page to see blog post/technical writing I have completed for clients.

To receive email notifications (Never Spam) from this blog (“Digital Owl’s Prose”) for the latest blog posts as they are published, please subscribe (of your own volition) by clicking the ‘Click To Subscribe!’ button in the sidebar on the homepage! (Feel free at any time to review the Digital Owl’s Prose Privacy Policy Page for any questions you may have about: email updates, opt-in, opt-out, contact forms, etc…)

Be sure and visit the “Best Of” page for a collection of my best blog posts.


Josh Otwell has a passion to study and grow as a SQL Developer and blogger. Other favorite activities find him with his nose buried in a good book, article, or the Linux command line. Among those, he shares a love of tabletop RPG games, reading fantasy novels, and spending time with his wife and two daughters.

Disclaimer: The examples presented in this post are hypothetical ideas of how to achieve similar types of results. They are not the utmost best solution(s). The majority, if not all, of the examples provided, is performed on a personal development/learning workstation-environment and should not be considered production quality or ready. Your particular goals and needs may vary. Use those practices that best benefit your needs and goals. Opinions are my own.

The post Basic Data Analysis with MySQL Shell Python mode appeared first on Digital Owl’s Prose.

technology

via Planet MySQL https://ift.tt/2iO8Ob8

September 16, 2020 at 12:02PM

Laravel 8 step by step CRUD

Laravel 8 step by step CRUD

https://ift.tt/2RBK73T


If you are new in Laravel 8 and looking for a step by step tutorial for Laravel 8 CRUD example app then this post will help you to learn how to make a complete CRUD application using Laravel 8. Before starting we have to check our system requirement is okay to use Laravel 8. The Laravel 8 minimum requirements are listed below so that you can confirm either your system is okay or not to install Laravel 8 project for making a Laravel 8 CRUD application.

Laravel 8 requirements

  • PHP >= 7.3
  • BCMath PHP Extension
  • Ctype PHP Extension
  • Fileinfo PHP Extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

 

Steps for making Laravel 8 CRUD

  • Step 01: Install Laravel 8
  • Step 02: Database Configuration
  • Step 03: Make model & migration
  • Step 04: Make controller
  • Step 05: Define routes
  • Step 06: Make views

 

Step 01: Install Laravel 8

First, install a fresh new Laravel 8 project. To do that, open your command prompt and run the artisan command below. This command will install and create a new Laravel 8 project for you. Before running this command make sure you have a stable internet connection. This command will take some times depends on your internet connection speed.

composer create-project laravel/laravel laravel8-project 8.0

N.B: Replace the laravel8-project with your project name. According to this name, a folder will create in your project directory.

 

Step 02: Database Configuration

Now create a database in MySQL via phpMyAdmin or other MySQL clients which you. Now open .env file from Laravel 8 project and update the database details.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel8
DB_USERNAME=root
DB_PASSWORD=

Here laravel8 is our database name. If your database name different then update it and save. Our project creation finished and the database is ready to use.

 

Step 03: Make model & migration

We will make a contact list Laravel 8 CRUD example application. So that we need a contacts table in our database. Here we do not create the table manually. Here we use Laravel migration. When we’ll run our migration that will make the table for us. Run the command in your terminal.

php artisan make:model Contact -m

This command will make a Contact.php model class file into the app/Models directory of our Laravel 8 project and a migration file will be created into the database migrations directory.

 

Now open the migration file from database/migrations directory of your Laravel 8 project and replace the code with below.

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateContactsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('contacts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('email');
            $table->string('phone');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('contacts');
    }
} 

Our migration file is ready. Now run the migration with this command. This command will create our tables in our database.

php artisan migrate

 

 

Step 04: Make controller

In our controller, all our business login will be coded to make Laravel 8 CRUD system. To make the controller run the command.

php artisan make:controller ContactController

By this command, a file will be created in app/Http/Controllers name with ContactController.php. Write the code below in the ContactController.php

<?php namespace App\Http\Controllers;

use App\Contact;
use Response;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class ContactController extends Controller
{

    public function index()
    {
        $data = Contact::orderBy('id','desc')->paginate(10)->setPath('contacts');
        return view('admin.contacts.index',compact(['data']));
    }

    public function create()
    {
        return view('admin.contacts.create');
    }

    public function store(Request $request)
    {
        $request->validate([
         'name' => 'required',
         'email' => 'required|email',
         'phone' => 'required'
        ]);

        Contact::create($request->all());
        return redirect()->back()->with('success','Create Successfully');
    }

    public function show($id)
    {
       $data =  Contact::find($id);
       return view('admin.contacts.show',compact(['data']));
    }

    public function edit($id)
    {
       $data = Contact::find($id);
       return view('admin.contacts.edit',compact(['data']));
    }

    public function update(Request $request, $id)
    {
        $request->validate([
         'name' => 'required',
         'email' => 'required|email',
         'phone' => 'required'
        ]);

        Contact::where('id',$id)->update($request->all());
        return redirect()->back()->with('success','Update Successfully');
        
    }

    public function destroy($id)
    {
        Contact::where('id',$id)->delete();
        return redirect()->back()->with('success','Delete Successfully');
    }

}

 

Step 05: Define routes

Open the web.php file from routes folder and write the routes like below.

Route::resource('contacts','ContactController');

Here we are using the Laravel resource route which will make all our required routes that are needed for Laravel 8 CURD example app.

 

Step 06: Make views

Here is the final part, We need some forms and HTML markup to show our records and data insert, update. Let’s make those views. Create a folder inside views folder name with contacts so that all views are related to contact CRUD will be in the same folder and organized.

We need the Laravel H package for making HTML form easily. Install it by the composer.

composer require haruncpi/laravel-h

Create an index.blade.php to show all our records from the database.

@extends('layout') 
@section('content')
<div class="col-md-12">

    <div class="table-responsive">
        <table class="table table-bordered table-condensed table-striped">
            <thead>

                <th>ID</th>
                <th>NAME</th>
                <th>EMAIL</th>
                <th>PHONE</th>
                <th>ACTION</th>
            </thead>

            <tbody>
                @foreach($data as $row)
                <tr>

                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>

                    <td>
                        <a href="" class="btn btn-primary">Edit</a>

                        <form action="" method="post">
                            @csrf @method('DELETE')
                            <button class="btn btn-danger" type="submit">Delete</button>
                        </form>

                    </td>
                </tr>
                @endforeach
            </tbody>

        </table>
    </div>
    <div>
        <?php echo $data->render(); ?>
    </div>
</div>

@endsection

Create a create.blade.php file for insert data.

@extends('layout')

@section('content')
{!! F::open(['action' =>'ContactController@store', 'method' => 'POST'])!!}
    
    <div class="col-md-6">
        
			 <div class="form-group required">
				{!! F::label("NAME") !!}
				{!! F::text("name", null ,["class"=>"form-control","required"=>"required"]) !!}
			</div>

			 <div class="form-group required">
				{!! F::label("EMAIL") !!}
				{!! F::text("email", null ,["class"=>"form-control","required"=>"required"]) !!}
			</div>

			 <div class="form-group required">
				{!! F::label("PHONE") !!}
				{!! F::text("phone", null ,["class"=>"form-control","required"=>"required"]) !!}
			</div>

   
        <div class="well well-sm clearfix">
            <button class="btn btn-success pull-right" title="Save" type="submit">Create</button>
        </div>
    </div>
 
{!! Form::close() !!}
@endsection

Create an edit.blade.php file to edit data.

@extends('layout')

@section('content')
    {!! F::open(['action' =>['ContactController@update',$data->id], 'method' => 'PUT'])!!}
    
        <div class="col-md-6">

            
			 <div class="form-group required">
				{!! F::label("NAME") !!}
				{!! F::text("name", $data->name ,["class"=>"form-control","required"=>"required"]) !!}
			</div>

			 <div class="form-group required">
				{!! F::label("EMAIL") !!}
				{!! F::text("email", $data->email ,["class"=>"form-control","required"=>"required"]) !!}
			</div>

			 <div class="form-group required">
				{!! F::label("PHONE") !!}
				{!! F::text("phone", $data->phone ,["class"=>"form-control","required"=>"required"]) !!}
			</div>



            <div class="well well-sm clearfix">
                <button class="btn btn-success pull-right" title="Save" type="submit">Update</button>
            </div>
        </div>
        
    {!! Form::close() !!}
@endsection

 

Now our Laravel 8 CRUD app is ready to use. To test the Laravel 8 CRUD app operation first, run the server by php artisan serve command and then open your browser and browse http://localhost:8000/contacts

Hope this step by step tutorial on Laravel 8 CRUD app will help you to make your won CRUD system using Laravel 8. If you find this tutorial helpful then please share this with others.

programming

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

September 15, 2020 at 08:15PM

How to fix ‘Target class does not exist’ in Laravel 8

How to fix ‘Target class does not exist’ in Laravel 8

https://ift.tt/2E5om9N


How do I fix this?

The problem here is that Laravel has no idea where to look for your controller, so all we have to do is let it know! There are 3 ways you can accomplish this:

  • Add the namespace back manually so you can use it as you did in Laravel 7.x and before
  • Use the full namespace in your route files when using the string-syntax
  • Use the action syntax (recommended)

Adding the namespace manually

This is fairly simple. Go into your RoutesServiceProvider.php file and you’ll see the following:

All you need to do is add the following three lines to this file and Laravel will go back to using the default namespace as in Laravel 7.x:

What did we just do? We declared the $namespace variable with the default Namespace for our controllers and told laravel to use that for our web and api routes.

If you try to run your app again, everything should be working.

Using the full namespace

This one involves changing all your route declarations, but the idea is simple: prepend your controller names with their namespace. See the following example for our PostsController inside the app/Http/Controllers folder.

If you try again, everything should be running smoothly.

Using the Action Syntax

This is the alternative I personally recommend as I find it more typo-proof and in my experience provides better IDE support as we are explicitly telling the code which class to use. Instead of using our usual string syntax, we can use the action syntax where we specify the class and method to use in an array:

Notice here we are not passing the PostsController within quotes but rather PostsController::class, which internally will return ‘App\Http\Controllers\PostsController’. The second value in the array is the method to call within that controller, meaning: “In PostsController.php call the ‘all’ method.

Again, if you try to run your app again, everything should be up and running.

Closing Remarks

By now, your app should be up and running again. If not, please feel free to ask for help. Everyone in the community is eager to give a hand.

Whether you added the namespace manually, specified the full namespace in your routes, or went with the action syntax, what you just did is tell Laravel in which namespace your controllers actually are, so now it actually knows where to look.

If you liked what you read or want to learn more cool stuff related to Laravel, you can follow me on Twitter, where I post about coding, entrepreneurship, and living a better life.

programming

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

September 15, 2020 at 08:15PM

Sadequl Hussain: 7 Best Practice Tips for PostgreSQL Bulk Data Loading

Sadequl Hussain: 7 Best Practice Tips for PostgreSQL Bulk Data Loading

https://postgr.es/p/4U4

Sometimes, PostgreSQL databases need to import large quantities of data in a single or a minimal number of steps. This process can be sometimes unacceptably slow. In this article, we will cover some best practice tips for bulk importing data into PostgreSQL databases.

Postgresql

via Planet PostgreSQL https://ift.tt/2g0pqKY

September 15, 2020 at 11:21AM

The Mandalorian’s Season 2 Trailer Is Here, and It Brought Baby Yoda

The Mandalorian’s Season 2 Trailer Is Here, and It Brought Baby Yoda

https://ift.tt/3c1qN9L


Trailer FrenzyA special place to find the newest trailers for movies and TV shows you’re craving.

This is the way to more episodes of The Mandalorian. And more Baby Yoda adorableness, of course.

Out of nowhere, Lucasfilm dropped our very first look at The Mandalorian’s sophomore season in action, picking up where season one left off: Din Djarin (Pedro Pascal), our titular bounty hunting hero, and his newly-inducted clanmate “The Child” jetting off on a quest to not just find the little green force-user’s people, but to keep themselves safe from the sinister grip of Imperial Remnant officer Moff Gideon (Giancarlo Esposito).

While the trailer doesn’t give too much away—just like season one’s cryptic footage sneakily hiding tiny Baby Yoda’s massive presence in the show—there have been plenty of rumors hinting to expect tons of familiar faces and major explorations of the Star Wars canon as we know it this season. From teases for the return of Clone Wars favorites like Ahsoka Tano and Mandalorian Death Watch agent Bo-Katan Kryze, there’s also the helmeted elephant in the room: Temuera Morrison’s alleged return as legendary Bounty Hunter Boba Fett.

How will all that factor in? Will Moff Gideon get his grubby hands on the baby? Will Din, indeed, find the way? We won’t have much longer to find out: The Mandalorian will return to Disney+ on October 30th.

G/O Media may get a commission


For more, make sure you’re following us on our Instagram @io9dotcom.

geeky,Tech

via Gizmodo https://gizmodo.com

September 15, 2020 at 10:21AM

Team finds vitamin D deficiency and COVID-19 infection link

Team finds vitamin D deficiency and COVID-19 infection link

https://ift.tt/3klxGFM

A vitamin D gelcap sits on a yellow/orange background

There’s an association between vitamin D deficiency and the likelihood of becoming infected with COVID-19, according to a new retrospective study of people tested for COVID-19.

“Vitamin D is important to the function of the immune system and vitamin D supplements have previously been shown to lower the risk of viral respiratory tract infections,” says David Meltzer, professor of medicine and chief of hospital medicine at University of Chicago Medicine and lead author of the study in JAMA Network Open. “Our statistical analysis suggests this may be true for the COVID-19 infection.”

The research team looked at 489 patients whose vitamin D level had been measured within a year before being tested for COVID-19. Patients who had untreated vitamin D deficiency (defined as less than 20 nanograms per milliliter of blood) were almost twice as likely to test positive for COVID-19 compared to patients who had sufficient levels of the vitamin.

Researchers stress it’s important to note that the study only found the two conditions frequently seen together; it does not prove causation. Meltzer and colleagues plan further clinical trials.

Experts believe half of Americans have a vitamin D deficiency, with much higher rates seen in African Americans, Hispanics, and people living in areas like Chicago where it is difficult to get enough sun exposure in winter.

Research has also shown, however, that some kinds of vitamin D tests don’t detect the form of vitamin D present in a majority of African Americans—which means those tests might falsely diagnose vitamin D deficiencies. The current study accepted either kind of test as criteria.

COVID-19 is also more prevalent among African Americans, older adults, nursing home residents, and health care workers—populations who all have increased risk of vitamin D deficiency.

“Understanding whether treating vitamin D deficiency changes COVID-19 risk could be of great importance locally, nationally, and globally,” Meltzer says. “Vitamin D is inexpensive, generally very safe to take, and can be widely scaled.”

Meltzer and his team emphasize the importance of experimental studies to determine whether vitamin D supplementation can reduce the risk, and potentially severity, of COVID-19. They also highlight the need for studies of what strategies for vitamin D supplementation may be most appropriate in specific populations.

The University of Chicago/Rush University Institute for Translational Medicine Clinical and Translational Science Award and the African American Cardiovascular Pharmacogenetic Consortium funded the work.

Source: Gretchen Rubin for University of Chicago

The post Team finds vitamin D deficiency and COVID-19 infection link appeared first on Futurity.

via Futurity.org https://ift.tt/2p1obR5

September 15, 2020 at 01:35PM

Buying A Gun In A Private Sale? Is There a Way to Check If It’s Stolen?

Buying A Gun In A Private Sale? Is There a Way to Check If It’s Stolen?

https://ift.tt/3mmOMoM


By David Katz

You’re looking for a gun for everyday carry, a shotgun for hunting season, or perhaps you just want a nice used gun to add to your collection. You also want to find a really good deal and the gun market is tight right now. A private sale might be just the way to go.

Federal law doesn’t prohibit private sales between individuals who reside in the same state, and the vast majority of states do not require that a private sale be facilitated by a federally licensed gun dealer (“FFL”). However, the more you think about it, what would happen to you if you bought a gun that turned out to be lost or stolen? Even worse, what would happen if you purchased a firearm that had been used in a crime?

Unfortunately, these things can happen. Further, there is no practical way for you to ensure a gun you purchase from a stranger is not lost or stolen.

FBI Lost and Stolen Gun Database

When a firearm is lost or stolen, the owner should immediately report it to the police. In fact, if a gun is lost or stolen from an FFL, the law requires the FFL to report the missing firearm to the ATF. These reported firearms are entered into a database maintained by the FBI’s National Crime Information Center.

Unfortunately for purchasers in private sales, only law enforcement agencies are allowed to request a search of the lost and stolen gun database.

Private Databases

While there have been attempts at creating private searchable internet databases where individuals self-report their lost or stolen guns, these usually contain only a fraction of the number of actual stolen guns, and the information is not verifiable.

Some states are exploring or attempting to build a state database of lost or stolen firearms that is searchable by the public, online. For example, the Florida Crime Information Center maintains a website where an individual can search for many stolen or lost items, including cars, boats, personal property, and of course, firearms.

However, even this website warns:

“FDLE cannot represent that this information is current, active, or complete. You should verify that a stolen property report is active with your local law enforcement agency or with the reporting agency.”

Police Checks of Firearms

Having the local police check the federal database continues to be the most accurate way of ascertaining whether or not a used firearm is lost or stolen, but many police departments do not offer this service. And be forewarned: if the gun does come back as lost or stolen, the person who brought it to the police will not get it back. The true owner always has the right to have his or her stolen gun returned.

If you choose to purchase a firearm in a private sale, you should protect yourself. A bill of sale is the best way to accomplish this. If it turns out the firearm was stolen or previously used in a crime, you will need to demonstrate to the police when you came into possession of the firearm and from whom you made the purchase. You don’t want to be answering uncomfortable police questions without documentation to back you up.

On the flip side, if you are the one who happens to be the victim of gun theft, be sure to report it after speaking with an attorney. Because while it may take several years, you never know when a police department may be calling you to return your gun.

 

David Katz is an independent program attorney for US LawShield. 

guns

via The Truth About Guns https://ift.tt/1TozHfp

September 14, 2020 at 03:15PM

Essential Climbing Knots You Should Know and How to Tie Them

Essential Climbing Knots You Should Know and How to Tie Them

https://ift.tt/3hpGUPr

Tying knots is an essential skill for climbing. Whether you’re tying in as a climber, building an anchor, or rappelling, using the right knot will make your climbing experience safer and easier.

Here, we’ll go over how to tie six common knots, hitches, and bends for climbing. Keep in mind, there are plenty of other useful knots.

And while this article can provide a helpful reminder, it’s by no means a substitute for learning from an experienced guide in person. However, this can be a launching point for you to practice some integral and common climbing knots at home.

This article includes:

  • Figure-eight follow-through
  • Overhand on a bight
  • Double fisherman’s bend
  • Clove hitch
  • Girth hitch
  • Prussik hitch

Knot-Tying Terms

Before we get into it, these are a few rope terms you’ll want to know for the rest of the article:

  • Knot — a knot is tied into a single rope or piece of webbing.
  • Bend — a bend joins two ropes together.
  • Hitch — a hitch connects the rope to another object like a carabiner, your harness, or another rope.
  • Bight — a section of rope between the two ends. This is usually folded over to make a loop.
  • Working end — the side of the rope that you’re using for the knot.
  • Standing end — the side of the rope that you’re not using for the knot.

Figure-Eight Follow-Through

This knot, also known as the trace-eight or rewoven figure-eight is one of the first knots every rock climber will learn. It ties you into your harness as a climber.

To make this knot, hold the end of your rope in one hand and measure out from your fist to your opposite shoulder. Make a bight at that point so you have a loop with your working end on top. Wrap your working end around the base of your loop once, then poke the end through your loop from front to back.

Pull this tight and you should have your first figure-eight knot.

For the follow-through, if you’re tying into your harness, thread your working end through both tie-in points on your harness and pull the figure-eight close to you. Then, thread your working end back through the original figure-eight, tracing the original knot.

Once it’s all traced through, you should have five sets of parallel lines in your knot neatly next to each other. Pull all strands tight and make sure you have at least six inches of tail on your working end.

Overhand Knot on a Bight

This knot is great for anchor building, creating a central loop, or as a stopper.

Take a bight on the rope and pinch it into a loop — this loop now essentially becomes your working end.

Loop the bight over your standing strands then bring it under the rope and through the loop you just created. Dress your knot by making sure all strands run parallel and pull each strand tight.

Double Fisherman’s Bend

Use this knot when you need to join two ropes together or make a cord into a loop. The double fisherman’s is basically two double knots next to each other.

To do this knot, line both rope ends next to each other. Hold one rope in your fist with your thumb on top. Wrap the working end of the other rope around your thumb and the first rope twice so it forms an X.

Take your thumb out and thread your working end through your X from the bottom up and pull tight. You should have one rope wrapped twice around the other strand with an X on one side and two parallel lines on the other.

Repeat this process with the working end of the other rope so you have one X and two parallel lines from each rope. Pull the two standing ends tight to bring both knots together.

Clove Hitch

This hitch is great for building anchors with your rope or securing your rope to a carabiner. The clove hitch is strong enough that it won’t move around when it’s weighted, but you can adjust each side to move the hitch around when unweighted.

To make this hitch, make two loops twisting in the same direction. Put your second loop behind the first, then clip your carabiner through both loops. Pull both strands tight and the rope should cinch down on the carabiner.

Girth Hitch

The girth hitch is ideal for attaching your personal anchor (or any sling) directly to your harness. The hitch is not adjustable like the clove hitch, but you can form it around any object as long as you have a loop.

Wrap your loop around the object, then feed the other end through your first loop so the rope or sling creates two strands around the object. Pull your working end tight.

Prusik Hitch

This is the most common friction hitch and is ideal for a rappel backup or ascending the rope. The friction hitch will grip the rope on either end when pulled tight, but can also easily move over a rope when loose.

To make your prusik hitch, you’re essentially making multiple girth hitches.

Put your loop behind the rope then thread the other end of your sling or cord through that loop. Loosely wrap the cord around the rope at least three times, threading through your original loop each time.

Pull the hitch tight around the rope then test it by making sure it successfully grips the rope.

The post Essential Climbing Knots You Should Know and How to Tie Them appeared first on GearJunkie.

Outdoors

via GearJunkie https://gearjunkie.com

September 14, 2020 at 10:15AM