Answers for "laravel migration soft delete"

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
0

laravel migration table softdeletes

$ php artisan make:migration add_soft_deletes_to_user_table --table="users"}
Posted by: Guest on September-15-2020
0

delete rows by migration laravel

Comment::where('post_id',$id)->delete();

// in down migration

    public function down()
    {
        Schema::table('package_types', function (Blueprint $table) {
            \App\Models\PackageType::query()->where('id','gt',1)->delete();
        });
    }
Posted by: Guest on August-14-2021
0

delete a migration laravel

// delete a migration safely from laravel 
delete migration from database/migrations/ directory
and also delete entry from migrations table
Posted by: Guest on October-29-2020
0

laravel migration table softdeletes

use Illuminate\Database\Eloquent\SoftDeletes;class User extends Model {use SoftDeletes;    protected $dates = ['deleted_at'];}
Posted by: Guest on September-15-2020
0

laravel migration softdelete

>>> $test->forceDelete();
=> true
Posted by: Guest on August-26-2021

Browse Popular Code Answers by Language