Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cursosdesarrolloweb/d875e138b429d15791e29f3059084ead to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/d875e138b429d15791e29f3059084ead to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProjectsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('projects', function (Blueprint $table) {
$table->id();
$table->foreignId("user_id")->constrained();
$table->string("name", 100)->unique();
$table->text("description")->nullable();
$table->string("featured_image", 150)->nullable();
$table->timestamps();
$table->softDeletes(); // <---- añade esta línea a tus migraciones
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('projects');
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Project extends Model
{
use HasFactory;
use SoftDeletes; // <--- aplica el Trait SoftDeletes a tus modelos
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment