Answers for "laravel update function"

PHP
3

laravel soft delete

/** in migrations this changes need to
    add for table we want to add soft delete (LARAVEL)*/

	/** The migrations. START */
	public function up()
	{
		Schema::table('users', function(Blueprint $table)
		{
			$table->softDeletes();
		});
	}
	/** The migrations. END */

	/** after adding softdelete you need to
    point that column in table related model (LARAVEL)*/

	/** The Model. START */
  	use Illuminate\Database\Eloquent\SoftDeletes;
  	class User extends Model {
	  use SoftDeletes;
	  protected $dates = ['deleted_at'];
	}
	/** The Model. END */
Posted by: Guest on November-17-2020
6

laravel create or update

// If there's a flight from Oakland to San Diego, set the price to $99.
// If no matching model exists, create one.
$flight = App\Models\Flight::updateOrCreate(
    ['departure' => 'Oakland', 'destination' => 'San Diego'],
    ['price' => 99, 'discounted' => 1]
);
Posted by: Guest on September-27-2020
4

laravel update

$flight = App\Models\Flight::find(1);

$flight->name = 'New Flight Name';

$flight->save();
Posted by: Guest on September-25-2020
0

update function laravel 7

## View 
Route::get('/subjects', 'SubjectsController@index')->name('subjects');

## Create
Route::get('/subjects/create', 'SubjectsController@create')->name('subjects.create');
Route::post('/subjects/store', 'SubjectsController@store')->name('subjects.store');

## Update
Route::get('/subjects/store/{id}', 'SubjectsController@edit')->name('subjects.edit');
Route::post('/subjects/update/{id}', 'SubjectsController@update')->name('subjects.update');

## Delete
Route::get('/subjects/delete/{id}', 'SubjectsController@destroy')->name('subjects.delete');
Posted by: Guest on July-06-2021
-1

create new record via model in laravel

$userData = array('username' => 'Me', 'email' => '[email protected]');
User::create($userData);
Posted by: Guest on October-19-2020

Browse Popular Code Answers by Language