Skip to content

Commit

Permalink
Add soft deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
magnobiet committed Apr 27, 2018
1 parent 25df501 commit de78e87
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Models/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class City extends Model
{

use SoftDeletes;

/**
* The attributes that are mass assignable.
*
Expand Down Expand Up @@ -35,6 +37,15 @@ class City extends Model
'state_id' => 'integer',
];

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'deleted_at'
];

/**
* Get the state that owns the city.
*/
Expand Down
12 changes: 12 additions & 0 deletions app/Models/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class State extends Model
{

use SoftDeletes;

/**
* The attributes that are mass assignable.
*
Expand All @@ -27,6 +29,16 @@ class State extends Model
'updated_at',
];


/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'deleted_at'
];

/**
* Get all of the cities for the state.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function up()
$table->string('name', 64)->unique();
$table->string('abbr', 2)->unique();
$table->timestamps();
$table->softDeletes();

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function up()
$table->foreign('state_id')->references('id')->on('states');
$table->string('name', 64);
$table->timestamps();
$table->softDeletes();

});

Expand Down

0 comments on commit de78e87

Please sign in to comment.