我有两个表,每个表用于其 Eloquent 。我想从他们每个人那里获得特定领域的结果(使用where子句)
然后我想组合两个结果数组并按创建日期归档对它们进行排序
我怎样才能在 laravel5 中实现这一目标?我尝试利用关系但无法使其发挥作用
这个例子分别是两个数组
$football = Football::where('playerId','=',$id)->get()->toArray();
$tennis= Tennis::where('playerId','=',$id)->get()->toArray();
Run Code Online (Sandbox Code Playgroud)
提前致谢
我想让我的日期字段记住我的旧输入
我有什么办法可以做到这一点吗?
这是我的代码
<div class="form-group">
<label for="date1">Date From: </label>
<input id="date1" name="date1" type="date" value="<?php echo date('Y-m-d'); ?>" class="form-control">
</div>
<div class="form-group">
<label for="date2">Date To: </label>
<input id="date2" name="date2" type="date" value="<?php echo date('Y-m-d'); ?>" class="form-control">
</div>
Run Code Online (Sandbox Code Playgroud)
请帮忙。谢谢你!
我需要一些帮助来使用 Laravel Forge 为我的数据库播种。我已经对我的应用程序进行了部署并且成功了。正如我最新的部署日志所示,这些表已创建:
来自 github.com:nahin14/cin-app * 分支 master -> FETCH_HEAD 已经是最新的。使用包信息加载 Composer 存储库 从锁定文件安装依赖项 无需安装或更新 生成自动加载文件 生成优化的类加载器 编译公共类 已迁移:2014_10_11_000000_create_roles_table 已迁移:2014_10_12_000000_create_users_table 已迁移:2014_10_12_100000_create_password_resets_表 已迁移:2015_04_16_205049_create_statuses_table 已迁移:2015_04_16_205103_create_claim_types_table 已迁移:2015_04_16_205118_create_insurance_types_table 已迁移:2015_04_16_205127_create_insurers_table迁移:2015_04_16_205215_create_solicitors_table已迁移:2015_04_16_205224_create_client_types_table 已迁移:2015_04_16_205229_create_clients_table 已迁移:2015_04_16_205243_create_vehicle_types_table 已迁移:2015_04_16_205251_create_vehicles_table已迁移:2015_04_16_205312_create_claims_table 已迁移:2015_04_16_205318_create_tasks_table
不过我想知道如何为桌子播种。我有一个包含所有播种信息的databaseseeder.php 文件。那么,我将如何使用databaseseeder.php 文件中的播种信息对表进行播种。
谢谢。
我在数据库表中有一个字段,现在当有人从 Laravel nova 创建一个条目时,它的默认值是 true 我想默认情况下传递 true 而不在创建和更新表单中显示该字段...所以任何人都可以帮助我如何我能解决这个问题吗?
Boolean::make('Is Active', 'is_active')->onlyOnIndex(),
Run Code Online (Sandbox Code Playgroud) 我在做什么:
我正在使用 Backpack 在 laravel 中做一个项目。在我的项目中,有两种观点。即管理员视图和学生视图。Admin 视图是使用 Backpack 创建的,而 student 视图是使用 auth 创建的。管理员使用背包的登录和注册表单和路由,而学生使用 Laravel 的 auth 登录和注册表单。
我想做的事:
所以我想要的是我想使用 Laravel 的登录表单和路由来登录背包仪表板,并完全删除背包的登录和注册表单和路由。
我是 Laravel 的新手,所以也许我的问题可能有点新手。我怎样才能做到这一点?请在这方面指导我。
authentication laravel laravel-5 backpack-for-laravel laravel-backpack
在我的表中,我没有 delete_at 列。
但在 Laravel 模型中,在 where 条件下,deleted_at 返回 null。
下面是我的代码
public function load($id) {
return $this
->select(sprintf('%s.*', $this->getTable()))
->where(sprintf('%s.id', $this->getTable(), $this->getKeyName()), '=', $id)
->first();
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我吗?如何解决这个问题?
我正在尝试使用 laravel 处理基本表单,但遇到了一个问题,即未检测到我的 POST 路由并导致刀片模板中出现路由未定义错误。我的目标是解决此错误并将表单发布到控制器,然后使用 $request 参数访问各种表单字段。
这是错误: Route [become-a-customer] not defined.
我感谢有关如何解决此问题的任何建议。
形式
<form action="{{ route('become-a-customer') }}" method="post" class="col-md-8 offset-md-2">
<div class="form-row">
<div class="form-group col-md-6">
<label for="first_name">First Name</label>
<input name="last_name" type="email" class="form-control" id="first_name" placeholder="First Name">
</div>
...
</div>
<input type="hidden" name="_token " value="{{ Session::token() }}"/>
<button type="submit" class="btn">SUBMIT</button>
</form>
Run Code Online (Sandbox Code Playgroud)
网页.php
Route::post('/become-a-customer', 'BecomeACustomerFormController@postBecomeACustomer');
Run Code Online (Sandbox Code Playgroud)
成为客户控制器。php
class BecomeACustomerFormController extends Controller
{
public function postBecomeACustomer(Request $request)
{
$firstName = $request['first_name'];
$lastName = $request['last_name'];
...
...
return redirect()->back();
}
}
Run Code Online (Sandbox Code Playgroud) 我在Laravel 中使用http://image.intervention.io/来调整图像大小,然后再将它们存储在 AWS S3 存储桶中。这是适用的代码:
$extension = $image->extension();
$realPath = $image->getRealPath();
$resizedImage = Image::make($realPath) // ->resize(255, 255); // resize or not, make() seems to always return an empty Image
$file_path = "posts/$post->id/images/image-$post->id-num-$pictureCount.$extension/";
$path = Storage::disk('s3')->put($file_path, $resizedImage->__toString(), ['visibility' => 'public']);
Run Code Online (Sandbox Code Playgroud)
调试时($path设置了线路上的断点),我可以看到它$realPath包含一个类似的值/private/var/folders/23/jl2dytp168g9g9s5j51w2m780000gn/T/php9047Fh- 去那里我可以看到我正在尝试的图像make()/ resize()。
该$resizedImage对象具有以下字段:
[encoded] =>
[mime] => image/jpeg
[dirname] => /private/var/folders/23/jl2dytp168g9g9s5j51w2m780000gn/T
[basename] => phpTNRdXe
[extension] =>
[filename] => phpTNRdXe
Run Code Online (Sandbox Code Playgroud)
我猜编码的属性应该包含类似 base 64 图像数据的内容?
检查 AWS S3 存储桶中的图像时,它总是作为 …
我已经按照本教程实现了 Laravel-5.8 电子邮件验证:https ://laravel.com/docs/5.8/verification 。我试图保护几条路线免受电子邮件未经验证的用户的影响,如下所示:
Route::group(['middleware' => ['verified']], function () {
Route::get('/dashboard', 'DashboardController@dashboard')->name('dashboard');
Route::get('/backend', 'DashboardController@backend')->name('backend');
});
Run Code Online (Sandbox Code Playgroud)
但是我可以在dashboard不验证我的电子邮件地址的情况下访问。
如何在不验证电子邮件的情况下阻止此访问?
我有一个 Laravel 应用程序,我需要根据 15 分钟的间隔显示上午 9 点到凌晨 3 点之间的所有时间段。时间段不包含日期,只有时间格式,如(AM 和 PM)
laravel-5 ×10
laravel ×7
php ×4
eloquent ×3
image ×1
intervention ×1
laravel-4 ×1
laravel-nova ×1
php-7 ×1
soft-delete ×1