How to insert raw data in mysql database in laravel

0 votes

I am new in laravel development. I use the mysql database, and want to insert the raw data in the database. I add the column with $table->binary(). And how can I insert the data to the column.

Schema::table('users', function($table)
{
    $table->binary('raw');
});
Dec 6, 2020 in Laravel by kartik
• 37,490 points
82 views

1 answer to this question.

0 votes

Try this:

Suppose you have the following tables (called 'users')

id|user|fname|lname|email|etc..
-------------------------
1|niroj|niroj|nirojdey@example.com|blah....

DB::table('users')->insert(
    array('user' => 'niroj',
          'fname' => 'niroj',
          'lname' => 'dey',
          'email' => 'niroj dey@example.com')
);

The insert() accepts multiple array (which in turns can be mapped to individual columns in your table).

answered Dec 6, 2020 by Niroj
• 82,560 points

Related Questions In Laravel

0 votes
1 answer

What is database migration and how to create database migration in Laravel?

Hii, Migrations are like version control for your database, ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,560 points
660 views
0 votes
1 answer

How to get data from Laravel backend and display in Vue/Nuxt frontend

Hello, You have to use the package dotenv. Then ...READ MORE

answered Apr 8, 2020 in Laravel by Niroj
• 82,560 points
1,305 views
0 votes
1 answer

How to pass data to mail View in laravel Mail send?

Hello @kartik, Send data like this. $data = [ ...READ MORE

answered Jul 30, 2020 in Laravel by Niroj
• 82,560 points
1,507 views
0 votes
1 answer

How to populating a database in a Laravel migration file?

Hello @kartik, Don't put the DB::insert() inside of ...READ MORE

answered Aug 4, 2020 in Laravel by Niroj
• 82,560 points
444 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,560 points
5,585 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,560 points
647 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,560 points
495 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,560 points
6,178 views
0 votes
1 answer

How to pass data through URL and access through controller in Laravel?

Hello, You can  first refer how to  Create controller through ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,560 points
4,987 views
0 votes
1 answer

Explain validations in laravel and How to validate my application incoming data?

Hey @kartik, In Programming validations are a handy ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,560 points
188 views