Create IdeaController
ADD
app/Http/Controllers/IdeaController.php
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Idea;
+use Illuminate\Http\Request;
+
+class IdeaController extends Controller {
+ public function create() {
+ return view('ideas.create');
+ }
+
+ public function store(Request $request) {
+ $request->validate([
+ 'body' => 'required'
+ ]);
+
+ Idea::create([
+ 'user_id' => auth()->user()->id,
+ 'body' => $request->body
+ ]);
+
+ return redirect()->route('ideas.create');
+ }
+}

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'];
}

MODIFY
resources/assets/sass/components/input.scss
resources/assets/sass/components/input.scss
}
.theme-light {
- input[type=text], input[type=email], input[type=password], select {
+ input[type=text], input[type=email], input[type=password], select, textarea {
background: $colors-light-body;
border: 1px solid $colors-light-border;
}
}
.theme-dark {
- input[type=text], input[type=email], input[type=password], select {
+ input[type=text], input[type=email], input[type=password], select, textarea {
color: #FFF;
background: $colors-dark-body;
border: 1px solid $colors-dark-border;
}
}
-input[type=text], input[type=email], input[type=password], select, .button {
+input[type=text], input[type=email], input[type=password], select, textarea, .button {
font: inherit;
border-radius: $dimensions-box-border-radius;
}
-input[type=text], input[type=email], input[type=password], select {
+input[type=text], input[type=email], input[type=password], select, textarea {
padding: $dimensions-input-padding;
width: 100%;
-webkit-appearance: none;
@@ -47,6 +47,10 @@ select {
background: #FFF;
}
+textarea {
+ resize: vertical;
+}
+
button.button {
border: none;

ADD
resources/views/ideas/create.blade.php
+@extends('layout')
+
+@section('body')
+ <div class="wrapper my-3">
+ <div class="box">
+ <form method="POST" action="/ideas">
+ {{ csrf_field() }}
+ <div class="box__section">
+ <div class="input input--small">
+ <label>Body</label>
+ <textarea name="body"></textarea>
+ @include('partials.validation_error', ['payload' => 'body'])
+ </div>
+ <button class="button">Submit</button>
+ </div>
+ </form>
+ </div>
+ </div>
+@endsection

MODIFY
resources/views/layout.blade.php
resources/views/layout.blade.php
</div>
@endif
@yield('body')
+ @if (auth()->check())
+ <div class="text-center mb-3">
+ <a href="/ideas/create" style="font-size: 14px;">Know how to make this app better?</a>
+ </div>
+ @endif
</div>
<script src="/js/app.js"></script>
@yield('scripts')

MODIFY
routes/web.php
routes/web.php
@@ -68,6 +68,11 @@ Route::group(['middleware' => ['auth']], function () {
Route::post('/settings', 'SettingsController@store');
Route::get('/spaces/{id}', 'SpaceController');
+
+ Route::name('ideas.')->group(function () {
+ Route::get('/ideas/create', 'IdeaController@create')->name('create');
+ Route::post('/ideas', 'IdeaController@store');
+ });
});
Route::get('/logout', 'LogoutController@index')->name('logout');

Create IdeaController