laravel-blade 相关问题

Blade是Laravel提供的简单而强大的模板引擎。与其他流行的PHP模板引擎不同,Blade不会限制您在视图中使用纯PHP代码。

Laravel 资源路由在路由列表中不包含任何参数

获取|头博客................................................. ......................................... blog.index › Blog\BlogController@指数 发布博客........................................

回答 1 投票 0

将心形图标添加到 Bootstrap 5 Carousel 时出现问题

Bootstrap 5 轮播中的心形/收藏夹图标不起作用。如何向其添加适当的功能,使其在单击时显示为填充(红色),在单击时显示为空(白色)...

回答 1 投票 0

Laravel 控制器未接收到从表单发送的数据

当尝试将数据从搜索栏表单发送到路由控制器时,无法使用 $request->input("name") 访问数据。我怎样才能解决这个问题? 控制器 类搜索控件...

回答 1 投票 0

为什么简码@php()会干扰@php和@endphp

我正在寻找为什么在刀片文件(Laravel)中使用混合 @php() 和 @php ... @endphp 的代码失败的原因,并且在文件中一致使用这些代码的情况下工作正常。我刚刚才知道...

回答 1 投票 0

无法正确删除文件,错误404未找到

为什么我的表单没有按应有的方式删除文件,laravel 显示错误消息 404 not found。我创建了一个删除按钮并发出了一个大写的表单。 为什么我的表单没有按应有的方式删除文件,laravel 显示错误消息 404 not found。我创建了一个删除按钮并发出了一个大写的表单。 <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete{{ $data->id }}"><i class="fa fa-trash"></i></button> 查看表单删除 @foreach ($pengaduan as $data) <div id="delete{{ $data->id }}" class="modal fade"> <div class="modal-dialog modal-confirm"> <div class="modal-content"> <div class="modal-header flex-column"> <div class="icon-box"> <i class="material-icons">&#xE5CD;</i> </div> <h4 class="modal-title w-100">Pengaduan UP3 {{ $data->up3 }} ?</h4> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> </div> <div class="modal-body"> <p>Yakin Ingin Menghapus Data Ini.</p> </div> <div class="modal-footer justify-content-center"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <a href="/pengaduan/delete/{{ $data->id }}"> <button type="button" class="btn btn-danger">Delete</button> </a> </div> </div> </div> </div> @endforeach 我的控制器 public function delete($id) { $pengaduan = PengaduanModel::findOrFail($id); if ($pengaduan->foto_aduan) { Storage::delete('public/foto_aduan/' . $pengaduan->foto_aduan); } $pengaduan->delete(); return redirect()->route('pengaduan')->with('pesan', 'Data Berhasil Dihapus !!!'); } 和路线 Route::get('/pengaduan/delete/{id}', [App\Http\Controllers\PengaduanController::class, 'delete']); 以前我都是用这个方法来处理删除功能,但是现在不知道为什么会出现404 not find。 我已经尝试过了 php artisan 路线:清晰且 php artisan 路线:缓存 但是没有效果 你可以像这样使用你的路线 <a href="/pengaduan/delete/{{ $data->id }}" class="btn btn-danger">Delete</a> 如果这不起作用,请使用ajax进行删除

回答 1 投票 0

Laravel Blade HTML 实体

来自 Laravel 10 的文档: 默认情况下,Blade(和 Laravel e 函数)将对 HTML 实体进行双重编码。如果您想禁用双重编码,请调用 Blade::withoutDoubleEnc...

回答 1 投票 0

我在 Laravel 中使用 .blade.php 视图时遇到问题

这是我的路线 路线::get('/product/create',[ProductoController::class,'createProduct'])->name('product.create')->middleware('auth'); 路线::post('/product/create',[ProductoController::...

回答 1 投票 0

我有多个房型,每个房型有多行定价

我有多种房间类型,每种房间类型都有多行定价,但当我执行计算时,它会计算每种房间类型表格,但如果我为该房间类型添加新的 pax 平板行,那么它

回答 1 投票 0

患者卡未永久显示

我正在尝试创建一张患者卡,该卡会自动添加到“就座等待”区域,一开始它向我显示该卡,然后不到一秒钟它就消失了 我怎样才能

回答 2 投票 0

文本透明实用程序类不适用于 TailwindCSS

我正在尝试使用本指南将渐变应用于某些文本。一切都在进行中,直到尝试使文本透明以允许渐变通过。这就是我最终得到的结果: ...

回答 1 投票 0

Laravel 11 AJAX 请求只显示响应数据,不执行成功函数

Laravel 11 AJAX 请求仅显示响应数据,而不执行 AJAX 中的成功函数。我已经添加了下面的所有代码。 索引.blade.php: Laravel 11 AJAX 请求仅显示响应数据,而不执行 AJAX 中的成功函数。我已添加以下所有代码。 Index.blade.php: <table id="employeesTable" class="table table-hover datatable"> <thead> <tr> <th>ID</th> <th>Image</th> <th>Full Name</th> <th>Email</th> <th>Details</th> <th>Status</th> <th>Action</th> </tr> </thead> <tbody> </tbody> </table> 脚本: <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> <script> $(document).ready(function() { fetchEmployees(); function fetchEmployees() { $.ajax({ url: '/system/employee', type: 'GET', dataType: "json", success: function(res) { console.log(res.employees); } }); } }); </script> 在控制器中: public function index() { $query = Employee::query(); $employees = $query->orderBy('created_at', 'desc') ->get(); return response()->json(["employees" => $employees]); } 显示此内容的回复 --> 回复SS 我还没找到解决办法! 运行 config:cache Artisan 命令来缓存配置文件: php artisan config:cache 这将在 Laravel 应用程序的 bootstrap/cache 目录中生成一个缓存的配置文件 (config.php)。确保 Web 服务器可写入该目录。

回答 1 投票 0

如何在blade中包含一个带有句点(.)作为文件名一部分的blade文件

我有以下路径的部分视图。 /views/acp/review/check.details.blade.php 我如何使用刀片包含这样的文件,因为如果我这样做 @include('views.acp.review.check.details') 我明白了...

回答 2 投票 0

laravel - 访问覆盖的包刀片文件中的原始刀片文件

我正在创建一个动态 Laravel 包,可以在其中扩展刀片文件。我的想法是提供一个基本模板并使用相同的名称多次扩展它。让我们简化一下我的说法 文件:- 打包...

回答 1 投票 0

更改变量名称时显示未定义变量

在我的控制器页面中,我试图将所有数据从模式返回到视图。我将所有数据保存在一个变量中并传递到视图页面。当我将变量名称保留为 $post 时,我得到

回答 3 投票 0

注册账号成功后如何路由登录?

**我一直在尝试登录并注册我们制作的网站。我正在使用 vs code 和 laravel Blade 模板。 这是我的登录代码:** **我一直在尝试登录并注册我们制作的网站。我正在使用 vs code 和 laravel Blade 模板。 这是我的登录代码:** <?php session_start(); $validationRules = [ 'email' => ['required', 'email'], 'password' => ['required', 'regex:/^[A-Za-z0-9\s-_]+$/'] ]; $errors = []; if ($_SERVER['REQUEST_METHOD'] === 'POST') { foreach ($validationRules as $field => $rules) { foreach ($rules as $rule) { switch ($rule) { case 'required': if (empty($_POST[$field])) { $errors[$field] = ucfirst($field) . ' is required.'; } break; case 'email': if (!filter_var($_POST[$field], FILTER_VALIDATE_EMAIL)) { $errors[$field] = 'Invalid email format.'; } break; case 'regex': if (!preg_match('/^[A-Za-z0-9\s-_]+$/', $_POST[$field])) { $errors[$field] = ucfirst($field) . ' contains invalid characters.'; } break; } } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="StyleLogin.css"> <title>Style Sync Login Page</title> </head> <body> <div class="card"> <div class="card-header"> <img src="{{ asset('logo.png') }}" alt="Style Sync Logo"> <div class="title-container"> <h1>Account Login</h1> </div> <div class="card-body"> <?php if (!empty($errors)): ?> <div class="alert alert-danger"> <ul> <?php foreach ($errors as $error): ?> <li><?= $error ?></li> <?php endforeach; ?> </ul> </div> <?php endif; ?> <form action="login" method="POST"> @csrf <div class="form-group"> <label for="email">Email</label> <input type="email" id="email" name="email" required> </div> <div class="form-group"> <label for="password">Password</label> <input type="password" id="password" name="password" required> </div> <button type="submit">Login</button> </form> <p>Don't have an account?<a href="{{ route('registration') }}">Register an Account</a></p> </div> </div> </body> </html> 然后这就是我在登录控制器上的内容: <?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; class LoginController extends Controller { public function showLoginForm() { return view('auth.login'); } public function login(Request $request) { $validator = Validator::make($request->all(), [ 'email' => 'required|email', 'password' => 'required', ]); if ($validator->fails()) { return redirect()->route('login')->withErrors($validator)->withInput(); } if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) { return redirect()->route('dashboard'); } else { return redirect()->route('login')->with('error', 'Invalid email or password'); } } } 这是注册码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Style Sync Registration Page</title> <link rel="stylesheet" href="StyleRegistration.css"> </head> <body> <div class="card"> <div class="card-header"> <img src="{{ asset('logo.png') }}" alt="Style Sync Logo"> <h1>Account Registration</h1> </div> <div class="card-body"> <form method="POST" action="{{ route('registration') }}"> @csrf <div> <label for="name">Name</label> <input id="name" type="text" name="name" value="{{ old('name') }}" required> @error('name') <div class="error">{{ $message }}</div> @enderror </div> <div> <label for="email">Email</label> <input id="email" type="email" name="email" value="{{ old('email') }}" required> @error('email') <div class="error">{{ $message }}</div> @enderror </div> <div> <label for="password">Password</label> <input id="password" type="password" name="password" required> @error('password') <div class="error">{{ $message }}</div> @enderror </div> <div> <label for="password_confirmation">Confirm Password</label> <input id="password_confirmation" type="password" name="password_confirmation" required> </div> <button type="submit">Register</button> </form> <p>Already have an account? <a href="{{ route('login') }}">Login here!</a></p> </div> </div> </body> </html> 那么这就是注册控制器 <?php namespace App\Http\Controllers\Auth; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Validator; use App\Models\User; class RegistrationController extends Controller { public function showRegistrationForm() { return view('auth.registration'); } public function register(Request $request) { $validator = Validator::make($request->all(), [ 'name' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:8|confirmed', ]); if ($validator->fails()) { return redirect()->route('registration')->withErrors($validator)->withInput(); } User::create([ 'name' => $request->name, 'email' => $request->email, 'password' => bcrypt($request->password), ]); return redirect()->route('login')->with('success', 'Registration successful! Please login.'); } } 这是web.php路由 <?php use Illuminate\Support\Facades\Route; use App\Http\Controllers\Auth\LoginController; use App\Http\Controllers\Auth\RegistrationController; use App\Http\Controllers\DashboardController; Route::get('/', function () { return view('welcome'); }); Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login'); Route::post('/login', [LoginController::class, 'login']); Route::get('/registration', [RegistrationController::class, 'showRegistrationForm'])->name('registration'); Route::post('/registration', [RegistrationController::class, 'registration']); Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard'); 我尝试了不同的路由,但仍然不起作用 这是弹出的错误: 调用未定义方法 App\Http\Controllers\Auth\RegistrationController::registration() 错误“Call to undefined method App\Http\Controllers\Auth\RegistrationController::registration()”表示Laravel无法在RegistrationController中找到名为registration()的方法。 查看你的RegistrationController,负责处理注册过程的方法名为register(),而不是registration()。因此,当您尝试在路由文件中调用 Registration() 时,Laravel 会抛出错误,因为该方法不存在。 要解决此问题,您需要更新路由文件 (web.php) 以在注册路由中使用正确的方法名称 (register()): Route::post('/registration', [RegistrationController::class, 'register']);

回答 1 投票 0

在对 Laravel 查询结果集进行排序时指定一些要优先考虑的“粘性”值

我目前有一个显示所有国家/地区的国家/地区下拉菜单。通常我的用户会在“美国”、“英国”或“加拿大”之间进行选择。我不想要我的...

回答 3 投票 0

如何移动下拉菜单顶部的 3 个热门国家/地区

我目前有一个显示所有国家/地区的国家/地区下拉菜单。通常我的用户会在“美国”、“英国”或“加拿大”之间进行选择。我不想要我的...

回答 3 投票 0

为什么 Alpine x-data 对其自身的属性变化没有反应?

有一个输入组件。代码如下。 @道具([ '禁用' => false, '隐藏' => 假, '类型' => '文本', '状态' => 空, '边框类' => '' ]) @php 开关($状态){ 案例 'a...

回答 1 投票 0

Laravel 图像上传文件路径但未显示在视图中

我目前正在 Laravel 10 中开发一个电子商务项目。在类别部分的管理仪表板中,我设置了两列,一列用于类别图像,另一列用于类别横幅

回答 1 投票 0

Laravel 多段路由导致找不到资源

如果我的路线上有多个路段,它会弄乱我的资产路径 当我访问 url('/blogadmin') 时,我的资源位于 href="admin/css/simplebar.css" 上 但是当我访问 url('/blogs/...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.