お惣菜コーナーを作った

This commit is contained in:
shibafu
2018-01-07 22:19:33 +09:00
parent 6c90cc2383
commit eb1884200b
3 changed files with 103 additions and 31 deletions

View File

@@ -17,4 +17,9 @@ class Ejaculation extends Model
protected $dates = [
'ejaculated_date'
];
public function user()
{
return $this->belongsTo('App\User');
}
}

View File

@@ -35,7 +35,14 @@ class HomeController extends Controller
$categories = Information::CATEGORIES;
if (Auth::check()) {
return view('home')->with(compact('informations', 'categories'));
// お惣菜コーナー用のデータ取得
$publicLinkedEjaculations = Ejaculation::where('is_private', false)
->where('link', '<>', '')
->orderBy('ejaculated_date', 'desc')
->take(5)
->get();
return view('home')->with(compact('informations', 'categories', 'publicLinkedEjaculations'));
} else {
return view('guest')->with(compact('informations', 'categories'));
}