Add types like bug and feature request to ideas
MODIFY
app/Http/Controllers/IdeaController.php
app/Http/Controllers/IdeaController.php
@@ -12,11 +12,13 @@ class IdeaController extends Controller {
public function store(Request $request) {
$request->validate([
+ 'type' => 'required|in:bug,feature_request',
'body' => 'required'
]);
Idea::create([
'user_id' => auth()->user()->id,
+ 'type' => $request->type,
'body' => $request->body
]);

MODIFY
app/Idea.php
app/Idea.php
@@ -5,5 +5,5 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
class Idea extends Model {
- protected $fillable = ['user_id', 'body'];
+ protected $fillable = ['user_id', 'type', 'body'];
}

ADD
database/migrations/2019_01_08_184758_add_type_column_to_ideas_table.php
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddTypeColumnToIdeasTable extends Migration {
+ public function up() {
+ Schema::table('ideas', function (Blueprint $table) {
+ $table->string('type')->after('user_id');
+ });
+ }
+
+ public function down() {
+ Schema::table('ideas', function (Blueprint $table) {
+ $table->dropColumn($table);
+ });
+ }
+}

MODIFY
resources/views/ideas/create.blade.php
resources/views/ideas/create.blade.php
<form method="POST" action="/ideas">
{{ csrf_field() }}
<div class="box__section">
+ <div class="input input--small">
+ <label>Type</label>
+ <select name="type">
+ <option value="bug">Bug or Error</option>
+ <option value="feature_request">Feature Request or Suggestion</option>
+ </select>
+ @include('partials.validation_error', ['payload' => 'type'])
+ </div>
<div class="input input--small">
<label>Body</label>
<textarea name="body"></textarea>

Add types like bug and feature request to ideas