我有一個表後與模型簡單的應用程序:Laravel 5.2軟刪除不起作用
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use SoftDeletes;
class Post extends Model
{
protected $table = 'post';
protected $dates = ['deleted_at'];
protected $softDelete = true;
}
我想使例如軟刪除,我使用途徑只是舉例route.php:
<?php
use App\Post;
use Illuminate\Database\Eloquent\SoftDeletes;
Route::get('/delete', function(){
$post = new Post();
Post::find(12)->delete();
});
我有一欄 「created_at」 與移民創建:
Schema::table('post', function (Blueprint $table) {
$table->softDeletes();
});
,但不是增加時間到此列,當我運行該網站時,它將刪除具有選定ID的行。我錯在哪裏?
嘗試移動'使用SoftDeletes;'裏面的類。我認爲文件建議 –