mirror of https://github.com/kcal-app/kcal.git
96 lines
2.3 KiB
PHP
96 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\JournalEntry;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class JournalEntryController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index(Request $request): View
|
|
{
|
|
$date = $request->date ?? Carbon::now()->toDateString();
|
|
return view('journal.index')
|
|
->with('entries', JournalEntry::where([
|
|
'user_id' => Auth::user()->id,
|
|
'date' => $date,
|
|
])->get())
|
|
->with('date', Carbon::createFromFormat('Y-m-d', $date))
|
|
->with('nutrients', ['calories', 'fat', 'cholesterol', 'carbohydrates', 'sodium', 'protein']);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\Models\JournalEntry $journalEntry
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show(JournalEntry $journalEntry)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\Models\JournalEntry $journalEntry
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit(JournalEntry $journalEntry)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \App\Models\JournalEntry $journalEntry
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(Request $request, JournalEntry $journalEntry)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Models\JournalEntry $journalEntry
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(JournalEntry $journalEntry)
|
|
{
|
|
//
|
|
}
|
|
}
|