之前在我的控制器文件中没有UserController.php,然后我手动创建了它,然后在那之后我做了这个“php artisan make:controller UsersController”,然后它已经然后当我开始在我的index.blade.php上键入html时,它说错误。有人能帮助我吗?
这是用户控制器. php
<?php
namespace App\Http\Controllers;
use App\Models\cr;
use Illuminate\Http\Request;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
*/
public function index()
{
return view('users.index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(cr $cr)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(cr $cr)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, cr $cr)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(cr $cr)
{
//
}
}
这是我的博客
<a href="#" data-bs-toggle="modal" data-bs-target="#staticBackdrop" class="btn btn-outline rounded-pill"><i class="fa-sharp fa-solid fa-list"></i></a>
<a href="{{ route('users.index') }}" class="btn btn-outline rounded-pill"><i class="fa-sharp fa-solid fa-list"></i> Users</a>
<a href="#" class="btn btn-outline rounded-pill"><i class="fa-sharp fa-solid fa-list"></i> Menu</a>
<a href="#" class="btn btn-outline rounded-pill"><i class="fa-sharp fa-solid fa-list"></i> Cashier</a>
<a href="#" class="btn btn-outline rounded-pill"><i class="fa-sharp fa-solid fa-list"></i> Reports</a>
<a href="#" class="btn btn-outline rounded-pill"><i class="fa-sharp fa-solid fa-list"></i> Transactions</a>
<a href="#" class="btn btn-outline rounded-pill"><i class="fa-sharp fa-solid fa-list"></i> Reports</a>
<style>
.btn-outline{
border-color: #F2921D;
color: #F2921D;
}
.btn-outline:hover {
background: #F2921D
color: #F2921D
}
</style>
这是我的博客
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::resource('/orders', 'OrderController'); // orders.index
Route::resource('/products', 'ProductController'); // products.index
Route::resource('/users', 'UserController'); // userController
Route::resource('/companies', 'CompanyController'); // companies.index
Route::resource('/transactions', 'TransactionController'); // transactions.index
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
这是我的网站。
@extends('layouts.app')
@section('content')
<h4>Hello Users</h4>
@endsection
我已经尝试使用告诉我添加“protected $namespace = 'App\Http\Controllers';“on RouteServiceProvider.php,and I try on web.php“use App\Http\Controllers\UserController;“但这两个都不能解决问题。有人能帮我解决这个问题吗?因为我现在在这个问题上卡住了。
1条答案
按热度按时间xesrikrc1#
像这样使用: