YouTube Icon

Code Playground.

How to use Insert Statement in Laravel 5

CFG

How to use Insert Statement in Laravel 5

Using the DB façade, we may insert the record with an insert sentence. As its first argument, this method takes the raw SQL query and bindings as its second argument.

Let's build a statement insert in laravel 5

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use DB;

class PostController extends Controller
{
    public function InsertData()
    {
        DB::insert('insert into post (title, slug) values (?, ?)', ["Laravel", 'laravel']);
    }
}




CFG