mirror of https://github.com/kcal-app/kcal.git
Add source and notes fields to foods
This commit is contained in:
parent
ca55a0d6ec
commit
6baf888d4f
|
|
@ -72,6 +72,8 @@ class FoodController extends Controller
|
|||
'name' => 'required|string',
|
||||
'detail' => 'nullable|string',
|
||||
'brand' => 'nullable|string',
|
||||
'source' => 'nullable|string',
|
||||
'notes' => 'nullable|string',
|
||||
'serving_size' => ['required', new StringIsDecimalOrFraction],
|
||||
'serving_unit' => 'nullable|string',
|
||||
'serving_weight' => 'required|numeric',
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ class FoodSchema extends SchemaProvider
|
|||
'name' => $resource->name,
|
||||
'detail' => $resource->detail,
|
||||
'brand' => $resource->brand,
|
||||
'source' => $resource->source,
|
||||
'notes' => $resource->notes,
|
||||
'calories' => $resource->calories,
|
||||
'carbohydrates' => $resource->carbohydrates,
|
||||
'cholesterol' => $resource->cholesterol,
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ use Spatie\Tags\HasTags;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|Food withAllTagsOfAnyType($tags)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Food withAnyTags($tags, ?string $type = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Food withAnyTagsOfAnyType($tags)
|
||||
* @property string|null $source
|
||||
* @property string|null $notes
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Food whereNotes($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Food whereSource($value)
|
||||
*/
|
||||
final class Food extends Model
|
||||
{
|
||||
|
|
@ -82,6 +86,8 @@ final class Food extends Model
|
|||
'name',
|
||||
'detail',
|
||||
'brand',
|
||||
'source',
|
||||
'notes',
|
||||
'calories',
|
||||
'carbohydrates',
|
||||
'cholesterol',
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ class CreateFoodsTable extends Migration
|
|||
$table->string('slug')->unique();
|
||||
$table->string('detail')->nullable();
|
||||
$table->string('brand')->nullable();
|
||||
$table->string('source')->nullable();
|
||||
$table->string('notes')->nullable();
|
||||
$table->unsignedFloat('serving_size');
|
||||
$table->enum('serving_unit', ['tsp', 'tbsp', 'cup', 'oz'])->nullable();
|
||||
$table->unsignedFloat('serving_weight');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddSourceAndNotesToFoods extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('foods', function (Blueprint $table) {
|
||||
$table->string('source')->nullable()->after('brand');
|
||||
$table->string('notes')->nullable()->after('brand');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('foods', function (Blueprint $table) {
|
||||
$table->dropColumn(['source', 'notes']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -115,6 +115,24 @@
|
|||
<!-- Tags -->
|
||||
<x-tagger :defaultTags="$food->tags->pluck('name')"/>
|
||||
|
||||
<!-- Source -->
|
||||
<div class="flex-auto">
|
||||
<x-inputs.label for="source" value="Source" />
|
||||
|
||||
<x-inputs.input name="source"
|
||||
type="text"
|
||||
class="block mt-1 w-full"
|
||||
:value="old('source', $food->source)" />
|
||||
</div>
|
||||
|
||||
<!-- Notes -->
|
||||
<div>
|
||||
<x-inputs.label for="description" value="Description" />
|
||||
|
||||
<x-inputs.textarea name="notes"
|
||||
class="block mt-1 w-full"
|
||||
:value="old('notes', $food->notes)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
|
|
|
|||
Loading…
Reference in New Issue