Home>

https://www.tutorialfor.com/go.php?id=143349
It's exactly the same as this question, but I couldn't solve it by doing the same thing in my environment.
environment
On cloud9
PHP 7.1.33
Laravel Framework 5.5.50
Composer version 1.10.15

Error message

The page has expired due to inactivity.
Please refresh and try again

This appears, and no new creation, editing, or deletion of data is executed. The URL is the same as before pressing the link or button.

Corresponding source code
TasksController.php

<? php
namespace App \ Http \ Controllers;
use Illuminate \ Http \ Request;
use App \ Task;
class TasksController extends Controller
{
   /**
     * Display a listing of the resource.
     *
     * @return \ Illuminate \ Http \ Response
     * /
    public function index ()
    {
        $tasks = Task :: all ();
        return view ('tasks.index', ['tasks' =>$tasks,]);
    }
   /**
     * Show the form for creating a new resource.
     *
     * @return \ Illuminate \ Http \ Response
     * /
    public function create ()
    {
        $task = new Task;
        return view ('tasks.create', ['task' =>$task,]);
    }
   /**
     * Store a newly created resource in storage.
     *
     * @param \ Illuminate \ Http \ Request $request
     * @return \ Illuminate \ Http \ Response
     * /
    public function store (Request $request)
    {
        $task = new Task;
        $task->content = $request->content;
        $task->save ();return redirect ('/');
    }
   /**
     * Display the specified resource.
     *
     * @param int $id
     * @return \ Illuminate \ Http \ Response
     * /
    public function show ($id)
    {
        $task = Task :: find ($id);
        return view ('tasks.show', ['task' =>$task,]);
    }
   /**
     * Show the form for editing the specified resource.
     *
     * @param int $id
     * @return \ Illuminate \ Http \ Response
     * /
    public function edit ($id)
    {
        $task = Task :: find ($id);
        return view ('tasks.edit', ['task' =>$task,]);
    }
   /**
     * Update the specified resource in storage.
     *
     * @param \ Illuminate \ Http \ Request $request
     * @param int $id
     * @return \ Illuminate \ Http \ Response
     * /
    public function update (Request $request, $id)
    {
        $task = Task :: find ($id);
        $task->content = $request->content;
        $task->save ();
        return redirect ('/');
    }
   /**
     * Remove the specified resource from storage.
     *
     * @param int $id
     * @return \ Illuminate \ Http \ Response
     * /
    public function destroy ($id)
    {
        $task = Task :: find ($id);
        $task->delete ();
        return redirect ('/');
    }}

create.blade.php

@extends ('layouts.app')
@section ('content')
     New message page     {!! Form :: model ($message, ['route' =>'messages.store']) !!}
        {!! Form :: label ('content','message:') !!}
        {!! Form :: text ('content') !!}
        {!! Form :: submit ('submit') !!}
    {!! Form :: close () !!}
@endsection


The generated HTML csrf token seems to be automatically generated.

What I tried

{{csrf_field ()}}
{!! csrf_field () !!}
@csrf
I tried to put.

composer dump-autoload
composer update
I tried reloading the browser on cloud9.

Result: No improvement.

The automatically generated (+ α) routing is as shown in the image.

What's more worrisome: I feel something is wrong with the url. Is link_to_route wrong?

web.php

<? php
Route :: get ('/','TasksController @ index');
Route :: resource ('tasks','TasksController');

index.blade.php

@extends ('layouts.app')
@section ('content')<!-Write the content for each page here->   Task list     @if (count ($tasks)>0)
      <ul>          @foreach ($tasks as $task)
              <li>{!! link_to_route ('tasks.show', $task->id, ['id' =>$task->id]) !!}: {{$task->content}}</li>          @endforeach
      </ul>  @endif
    {!! link_to_route ('tasks.create','post a new task') !!}
@endsection

When I followed the link above, I thought that the destination was/tasks/create, but in reality it is/tasks /

I thought that the following would also be/tasks/1/edit, but in reality it is/tasks/1

Please teach me how to deal with it. I'm stuck at the beginning of laravel.