Skip to content

Commit

Permalink
Episode 87
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Oct 16, 2017
1 parent ea241a7 commit 6836b96
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 195 deletions.
12 changes: 11 additions & 1 deletion app/Http/Controllers/LockedThreadsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ class LockedThreadsController extends Controller
*/
public function store(Thread $thread)
{
$thread->lock();
$thread->update(['locked' => true]);
}

/**
* Unlock the given thread.
*
* @param \App\Thread $thread
*/
public function destroy(Thread $thread)
{
$thread->update(['locked' => false]);
}
}
17 changes: 9 additions & 8 deletions app/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ class Thread extends Model
*/
protected $appends = ['isSubscribedTo'];

/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'locked' => 'boolean'
];

/**
* Boot the model.
*/
Expand Down Expand Up @@ -103,14 +112,6 @@ public function addReply($reply)
return $reply;
}

/**
* Lock the thread.
*/
public function lock()
{
$this->update(['locked' => true]);
}

/**
* Apply all relevant thread filters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('name')->unique();
$table->string('email')->unique();
$table->string('password');
$table->string('avatar_path')->nullable();
Expand Down
Loading

0 comments on commit 6836b96

Please sign in to comment.