diff --git a/app/Http/Controllers/RecipeController.php b/app/Http/Controllers/RecipeController.php index d54d980..c36175b 100644 --- a/app/Http/Controllers/RecipeController.php +++ b/app/Http/Controllers/RecipeController.php @@ -167,7 +167,7 @@ class RecipeController extends Controller 'remove_image' => ['nullable', 'boolean'], 'servings' => ['required', 'numeric'], 'time_prep' => ['nullable', 'numeric'], - 'time_active' => ['nullable', 'numeric'], + 'time_cook' => ['nullable', 'numeric'], 'weight' => ['nullable', 'numeric'], 'source' => ['nullable', 'string'], 'ingredients.amount' => ['required', 'array', new ArrayNotEmpty], @@ -201,7 +201,7 @@ class RecipeController extends Controller 'servings' => (int) $input['servings'], 'weight' => $input['weight'], 'time_prep' => (int) $input['time_prep'], - 'time_active' => (int) $input['time_active'], + 'time_cook' => (int) $input['time_cook'], 'source' => $input['source'], ]); diff --git a/app/JsonApi/Schemas/RecipeSchema.php b/app/JsonApi/Schemas/RecipeSchema.php index 8f508d2..1360165 100644 --- a/app/JsonApi/Schemas/RecipeSchema.php +++ b/app/JsonApi/Schemas/RecipeSchema.php @@ -30,7 +30,7 @@ class RecipeSchema extends SchemaProvider 'name' => $resource->name, 'description' => $resource->description, 'time_prep' => $resource->time_prep, - 'time_active' => $resource->time_active, + 'time_cook' => $resource->time_cook, 'time_total' => $resource->time_total, 'source' => $resource->source, 'servings' => $resource->servings, diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php index 9ddb865..5303a91 100644 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -60,7 +60,7 @@ use Spatie\Tags\HasTags; * @method static \Illuminate\Database\Eloquent\Builder|Recipe withAnyTagsOfAnyType($tags) * @mixin \Eloquent * @property int|null $time_prep - * @property int|null $time_active + * @property int|null $time_cook * @property-read int $time_total * @method static \Illuminate\Database\Eloquent\Builder|Recipe whereTimeActive($value) * @method static \Illuminate\Database\Eloquent\Builder|Recipe whereTimePrep($value) @@ -90,7 +90,7 @@ final class Recipe extends Model implements HasMedia 'description', 'description_delta', 'time_prep', - 'time_active', + 'time_cook', 'source', 'servings', 'weight', @@ -102,7 +102,7 @@ final class Recipe extends Model implements HasMedia protected $casts = [ 'servings' => 'int', 'time_prep' => 'int', - 'time_active' => 'int', + 'time_cook' => 'int', 'weight' => 'float', ]; @@ -145,7 +145,7 @@ final class Recipe extends Model implements HasMedia * Get total recipe time. */ public function getTimeTotalAttribute(): int { - return $this->time_prep + $this->time_active; + return $this->time_prep + $this->time_cook; } /** diff --git a/database/migrations/2020_12_21_215932_create_recipes_table.php b/database/migrations/2020_12_21_215932_create_recipes_table.php index 0599db6..7e7884f 100644 --- a/database/migrations/2020_12_21_215932_create_recipes_table.php +++ b/database/migrations/2020_12_21_215932_create_recipes_table.php @@ -20,7 +20,7 @@ class CreateRecipesTable extends Migration $table->longText('description')->nullable(); $table->longText('description_delta')->nullable(); $table->integer('time_prep')->nullable(); - $table->integer('time_active')->nullable(); + $table->integer('time_cook')->nullable(); $table->string('source')->nullable(); $table->unsignedInteger('servings'); $table->unsignedFloat('weight')->nullable(); diff --git a/database/migrations/2021_03_13_134359_replace_active_time_with_cook_time_in_recipes.php b/database/migrations/2021_03_13_134359_replace_active_time_with_cook_time_in_recipes.php new file mode 100644 index 0000000..d52ddc2 --- /dev/null +++ b/database/migrations/2021_03_13_134359_replace_active_time_with_cook_time_in_recipes.php @@ -0,0 +1,36 @@ +integer('time_cook')->nullable()->after('time_prep'); + }); + DB::update("UPDATE `recipes` SET `time_cook` = `time_active`;"); + Schema::table('recipes', function (Blueprint $table) { + $table->dropColumn(['time_active']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('recipes', function (Blueprint $table) { + $table->dropColumn(['time_cook']); + }); + } +} diff --git a/resources/views/recipes/edit.blade.php b/resources/views/recipes/edit.blade.php index c5cba72..08a6dea 100644 --- a/resources/views/recipes/edit.blade.php +++ b/resources/views/recipes/edit.blade.php @@ -51,19 +51,19 @@ step="1" min="0" class="block mt-1 w-full" - :value="old('name', $recipe->time_prep)"/> + :value="old('time_prep', $recipe->time_prep)"/> - +
{{ $recipe->time_prep }} minutes
{{ $recipe->time_active }} minutes
+{{ $recipe->time_cook }} minutes