Update Data
Update Data by Eloquent Model

Route
<?php
Route::get('update_student','Update_Data@student_update');

Controller
<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Student;

class Update_Data extends Controller {
public function student_update(){
$student=Student::find(1);
$student->name='Ravi';
$student->email='ravi@gmail.com';
$student->save();
}
}

Laravel Update by Query

DB::table('student')
->where('id', 1)
->update(array('name' => 'Rahul' , 'email' => 'email@gmail.com'));


Previous
Next