Permalink
Browse files

Episode 87

  • Loading branch information...
JeffreyWay committed Oct 16, 2017
1 parent ea241a7 commit 6836b96eb07fd34eb4e7f9d4ce33cdc53a3a29b8
@@ -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]);
}
}
View
@@ -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.
*/
@@ -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.
*
@@ -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();
Oops, something went wrong.

0 comments on commit 6836b96

Please sign in to comment.