Created
August 1, 2021 08:41
-
-
Save cursosdesarrolloweb/d875e138b429d15791e29f3059084ead to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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