@@ -3,9 +3,12 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
class Author extends Model
{
+ use SoftDeletes;
+
function books() {
return $this->hasMany(Book::class);
}
class Book extends Model
function author() {
return $this->belongsTo(Author::class);
class Comment extends Model
// Наличие fillable требуется только при использовании mass assignment, т.е. создание записи из ассоциативного массива
protected $fillable = [
"name",
@@ -16,6 +16,7 @@ return new class extends Migration
$table->timestamps();
$table->string("name");
$table->text("description")->nullable();
+ $table->softDeletes();
});
@@ -20,6 +20,7 @@ return new class extends Migration
$table->smallInteger("pagecount")->unsigned()->nullable();
$table->foreignId("author_id")->constrained();
@@ -18,6 +18,7 @@ return new class extends Migration
$table->string("email");
$table->text("content");
$table->morphs("commentable");