Guest User

Untitled

a guest
Aug 1st, 2020
17
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I am following laracasts of laravel , in storing an article via a forum.
  2.  
  3. my routes file
  4.  
  5.  
  6.  
  7.  
  8. <?php
  9.  
  10. use Illuminate\Support\Facades\Route;
  11. use App\User;
  12. use App\Article;
  13. use App\Post;
  14.  
  15. /*
  16. |--------------------------------------------------------------------------
  17. | Web Routes
  18. |--------------------------------------------------------------------------
  19. |
  20. | Here is where you can register web routes for your application. These
  21. | routes are loaded by the RouteServiceProvider within a group which
  22. | contains the "web" middleware group. Now create something great!
  23. |
  24. */
  25.  
  26.  
  27. Auth::routes();
  28.  
  29. Route::get('/home', 'HomeController@index')->name('home');
  30.  
  31. Route::get('/', function () {
  32. return view('welcome');
  33. })->name('root');
  34.  
  35.  
  36.  
  37. Route::get('/about', function () {
  38. $about = Post::where('slug', 'about')->first();
  39. return view('about', ['about' => $about]);
  40. })->name('about');
  41.  
  42. Route::get('articles', 'ArticlesController@index')->name('articles');
  43. Route::post('articles', 'ArticlesController@store')->name('articles.store');
  44. Route::get('articles/create', 'ArticlesController@create')->name('articles.create');
  45. Route::get('articles/{article}', 'ArticlesController@show');
  46.  
  47.  
  48.  
  49. my controller file
  50.  
  51.  
  52. <?php
  53.  
  54. namespace App\Http\Controllers;
  55.  
  56. use Illuminate\Http\Request;
  57. use App\Article;
  58.  
  59. class ArticlesController extends Controller
  60. {
  61. public function index()
  62. {
  63. $articles = Article::latest()->get();
  64. return view('articles.index', ['articles' => $articles]);
  65. }
  66.  
  67. public function create()
  68. {
  69. return view('articles.create');
  70. }
  71.  
  72. public function store()
  73. {
  74. dump(request()->all());
  75. }
  76.  
  77. public function show($id)
  78. {
  79. $article = Article::findOrFail($id);
  80. return view('articles.show', ['article' => $article]);
  81. }
  82. }
  83.  
  84.  
  85.  
  86. my create.blade.php
  87.  
  88. @extends('layout')
  89.  
  90. @section('content')
  91. <div id="wrapper">
  92. <div id="page" class="container">
  93. <h1 class="mb-5">New Article</h1>
  94.  
  95. <form action="{{route('articles.store')}}" method="post">
  96. @csrf
  97.  
  98. <div class="form-group">
  99. <h4 for="title">Title</h4>
  100. <input type="text" class="form-control" id="title">
  101. </div>
  102.  
  103. <div class="form-group">
  104. <h4 for="excerpt">Excerpt</h4>
  105. <textarea class="form-control" id="excerpt" rows="2"></textarea>
  106. </div>
  107.  
  108.  
  109. <div class="form-group">
  110. <h4 for="body">Body</h4>
  111. <textarea class="form-control" id="body" rows="6"></textarea>
  112. </div>
  113.  
  114. <button type="submit" class="btn btn-primary">Create Article</button>
  115. </form>
  116. </div>
  117. </div>
  118. @endsection
  119.  
  120.  
  121.  
  122. when i submit the forum , i get only the token number
  123.  
  124. array:1 [▼
  125. "_token" => "RZtvcAJKq0gbiWge17RMp2n5UmipSlTn3Jyj2Q91"
  126. ]
  127.  
  128.  
  129. i didnt get the forum content , so why is this ?
RAW Paste Data