situation
using PHP 8 Laravel 9
Now I have just deployed in production environment. When I come my URL which is already simbolick, toppage(welcome.blade.php) appeared. I am putting link to contact.create.blade.php. However I come here, the error I show appeares.
In local, I can go to the link, but in production, the error says not defined
maybe to mistake routes. Now I can go to the link in local.
Can you tell me this problem and how to solve it.
error messages
error
Route [contact.create] not defined.
welcome.blade.php
<div>
{{-- ボタン設定 --}}
<a href="{{route('contact.create')}}">
<x-primary-button class="next-button text-center">お問い合わせ</x-primary-button>
</a>
<a href="{{route('register')}}">
<x-primary-button class="next-button text-center">ご登録</x-primary-button>
</a>
</div>
web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PostController;
use App\Http\Controllers\CommentController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\SearchController;
use App\Http\Controllers\NiceController;
use App\Http\Controllers\StripeController;
use App\Http\Controllers\FollowController;
use App\Models\Role;
Route::get('/', function () {
return view('welcome');
})->name('top');
~~~~~~~~~~
// contact
Route::get('contact/create',[ContactController::class,'create'])->name('contact.create');
Route::post('contact/store',[ContactController::class,'store'])->name('contact.store');
ContactController.php
<?php
namespace App\Http\Controllers;
use App\Models\Contact;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use App\Mail\ContactForm;
class ContactController extends Controller
{
public function create()
{
return view('contact.create');
}
public function store(Request $request)
{
$inputs = request()->validate([
'title' => 'required|max:255',
'email' => 'required|email|max:255',
'body' => 'required|max:1000',
]);
Contact::create($inputs);
Mail::to(config('mail.admin'))->send(new ContactForm($inputs));
Mail::to($inputs['email'])->send(new ContactForm($inputs));
return back()->with('message','submitted your email!');
}
}
I don't know anything because I can go to link in local but this error appeares in production.
I tried php artisan optimize:clear
, but nothing changed at all.