Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I am following laracasts of laravel , in storing an article via a forum.
- my routes file
- <?php
- use Illuminate\Support\Facades\Route;
- use App\User;
- use App\Article;
- use App\Post;
- /*
- |--------------------------------------------------------------------------
- | Web Routes
- |--------------------------------------------------------------------------
- |
- | Here is where you can register web routes for your application. These
- | routes are loaded by the RouteServiceProvider within a group which
- | contains the "web" middleware group. Now create something great!
- |
- */
- Auth::routes();
- Route::get('/home', 'HomeController@index')->name('home');
- Route::get('/', function () {
- return view('welcome');
- })->name('root');
- Route::get('/about', function () {
- $about = Post::where('slug', 'about')->first();
- return view('about', ['about' => $about]);
- })->name('about');
- Route::get('articles', 'ArticlesController@index')->name('articles');
- Route::post('articles', 'ArticlesController@store')->name('articles.store');
- Route::get('articles/create', 'ArticlesController@create')->name('articles.create');
- Route::get('articles/{article}', 'ArticlesController@show');
- my controller file
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use App\Article;
- class ArticlesController extends Controller
- {
- public function index()
- {
- $articles = Article::latest()->get();
- return view('articles.index', ['articles' => $articles]);
- }
- public function create()
- {
- return view('articles.create');
- }
- public function store()
- {
- dump(request()->all());
- }
- public function show($id)
- {
- $article = Article::findOrFail($id);
- return view('articles.show', ['article' => $article]);
- }
- }
- my create.blade.php
- @extends('layout')
- @section('content')
- <div id="wrapper">
- <div id="page" class="container">
- <h1 class="mb-5">New Article</h1>
- <form action="{{route('articles.store')}}" method="post">
- @csrf
- <div class="form-group">
- <h4 for="title">Title</h4>
- <input type="text" class="form-control" id="title">
- </div>
- <div class="form-group">
- <h4 for="excerpt">Excerpt</h4>
- <textarea class="form-control" id="excerpt" rows="2"></textarea>
- </div>
- <div class="form-group">
- <h4 for="body">Body</h4>
- <textarea class="form-control" id="body" rows="6"></textarea>
- </div>
- <button type="submit" class="btn btn-primary">Create Article</button>
- </form>
- </div>
- </div>
- @endsection
- when i submit the forum , i get only the token number
- array:1 [▼
- "_token" => "RZtvcAJKq0gbiWge17RMp2n5UmipSlTn3Jyj2Q91"
- ]
- i didnt get the forum content , so why is this ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement