Make recipe description and units fields optional

This commit is contained in:
Christopher C. Wells 2021-01-15 04:53:02 -08:00
parent 5513c2b37c
commit 03f9d5395a
4 changed files with 37 additions and 4 deletions

View File

@ -60,11 +60,11 @@ class RecipeController extends Controller
{
$input = $request->validate([
'name' => 'required|string',
'description' => 'required|string',
'description' => 'nullable|string',
'servings' => 'required|numeric',
'foods_amount' => ['required', 'array', new ArrayNotEmpty],
'foods_amount.*' => 'required_with:foods.*|nullable|numeric|min:0',
'foods_unit' => ['required', 'array', new ArrayNotEmpty],
'foods_unit' => ['required', 'array'],
'foods_unit.*' => 'nullable|string',
'foods' => ['required', 'array', new ArrayNotEmpty],
'foods.*' => 'required_with:foods_amount.*|nullable|exists:App\Models\Food,id',

View File

@ -17,7 +17,7 @@ class CreateRecipesTable extends Migration
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->longText('description');
$table->longText('description')->nullable();
$table->unsignedInteger('servings');
$table->timestamps();
});

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class MakeRecipeDescriptionOptional extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('recipes', function (Blueprint $table) {
$table->string('description')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('recipes', function (Blueprint $table) {
$table->string('description')->change();
});
}
}

View File

@ -49,7 +49,8 @@
class="block mt-1 w-full"
type="number"
name="servings"
:value="old('servings')" />
:value="old('servings')"
required />
</div>
</div>