Permalink
Browse files

Episode 35

  • Loading branch information...
JeffreyWay committed May 9, 2017
1 parent 986e13c commit 87e55a5ecd44ef9ad13500c84180ab9543a8a145
Showing with 21 additions and 7 deletions.
  1. +12 −2 app/Favoritable.php
  2. +4 −2 resources/views/profiles/show.blade.php
  3. +5 −3 resources/views/threads/reply.blade.php
@@ -6,6 +6,16 @@
trait Favoritable
{
/**
* Boot the trait.
*/
protected static function bootFavoritable()
{
static::deleting(function ($model) {
$model->favorites->each->delete();
});
}
/**
* A reply can be favorited.
*
@@ -37,7 +47,7 @@ public function unfavorite()
{
$attributes = ['user_id' => auth()->id()];
$this->favorites()->where($attributes)->delete();
$this->favorites()->where($attributes)->get()->each->delete();
}
/**
@@ -47,7 +57,7 @@ public function unfavorite()
*/
public function isFavorited()
{
return !! $this->favorites->where('user_id', auth()->id())->count();
return ! ! $this->favorites->where('user_id', auth()->id())->count();
}
/**
@@ -10,15 +10,17 @@
</h1>
</div>
@foreach ($activities as $date => $activity)
@forelse ($activities as $date => $activity)
<h3 class="page-header">{{ $date }}</h3>
@foreach ($activity as $record)
@if (view()->exists("profiles.activities.{$record->type}"))
@include ("profiles.activities.{$record->type}", ['activity' => $record])
@endif
@endforeach
@endforeach
@empty
<p>There is no activity for this user yet.</p>
@endforelse
</div>
</div>
</div>
@@ -8,9 +8,11 @@
</a> said {{ $reply->created_at->diffForHumans() }}...
</h5>
<div>
<favorite :reply="{{ $reply }}"></favorite>
</div>
@if (Auth::check())
<div>
<favorite :reply="{{ $reply }}"></favorite>
</div>
@endif
</div>
</div>

0 comments on commit 87e55a5

Please sign in to comment.