new_gist_file.php
https://laracasts.com/discuss/channels/eloquent/whats-the-difference-between-save-and-create
<?php
// IN YOUR MODEL: add the fillable fields
namespace App;
use Illuminate\Database\Eloquent\Model;
class Task extends Model
{
protected $fillable = [
'task' , 'project_id', 'priority'
] ;
}
// IN YOUR CONTROLLER:
public function store(Request $request)
{
// dd( $request->all() ) ;
$this->validate( $request, [
'task' => 'required',
'project_id' => 'required'
]) ;
$post = Task::create([
'project_id' => $request->project_id,
'task' => $request->task,
'priority' => $request->priority
]);
// ->route is defined in web.php
Session::flash('success', 'Task Created') ;
return redirect()->route('task.show') ;
}