我在Laraval的Blade视图中有这段代码:
@foreach ($questions as $question)
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
@if(isset($question->task))
<a href="{{URL::action('showTask', $question->task_id)}}"><h4> <span class='glyphicon glyphicon-file'></span> {{$question->Task->name}}</h4></a>
@endif
<blockquote >
<a class="nostyle" href="{{URL::action('showQuestion',$question->id)}}" ><p
@if($question->status==1)
class="text-success"
@endif
>{{$question->text}}</p></a>
<footer>Gevraagd door <strong>{{$question->Author->getFullName('mij') }}</strong> op <strong>{{DateConverter::dateToString($question->created_at)}}</strong></footer>
@if($question->status==1)
<span class="label label-success">Beantwoord</span>
@endif
</blockquote>
</div>
@endforeach
Run Code Online (Sandbox Code Playgroud)
显示所有问题.我希望它们以3行的漂亮行显示.但是,有些文本($ question-> text)比其他文本更长,因此它们并不总是完美地开始新行,而是附加到最短的前一个网格,如屏幕截图所示.

我想要的更像是一张桌子,三列,然后是一个同一高度的新行,有三个新项目.
所以我正在寻找一种方法
或者在每三列之后自动添加和关闭行div.
最好的方法是什么?
自托管(非伪造)Laravel是否有cron系统?或者这已被工人队列所取代?
也就是说,在许多PHP框架中,都有一个要运行的cron文件 - 经常命名cron.php.通常会指示您通过unix cron作业将此脚本配置为每15分钟(或某个类似的时间)运行.
1,15,30,45 * * * * /path/to/php /path/to/cron.php
Run Code Online (Sandbox Code Playgroud)
Laravel有类似的系统吗?谷歌搜索我已经看到有人提到Forge有一个解决方案,并且旧版本的Laraval可能有一个系统,但我还没有找到一个明确的答案W/R/T Laravel 4.
在我的 Laravel 项目中,我有一个 BusController.php 文件,我需要在其中运行 for() 循环。但是,循环不起作用。我也试过一个刀片来循环,但有同样的问题。
总线控制器.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Bus;
use App\Bus_type;
use App\Company;
use App\Http\Requests;
class BusController extends Controller
{
public function index()
{
$buses = Bus::all();
$bus_types = Bus_type::all();
$companies = Company::all();
return view('admin.adding_bus', compact('buses', 'bus_types', 'companies'));
}
public function store(Request $request)
{
$bus = new Bus;
$bus->company_name = $request->company_name;
$bus->bus_type = $request->bus_type;
$bus->bus_number = $request->bus_number;
$bus->no_of_rows = $request->no_of_rows;
$bus->no_of_columns = $request->no_of_columns;
$seats = "";
for ($i = 1; $i <= …Run Code Online (Sandbox Code Playgroud) 我想创建一个where子句,它是一个和,带有或者列表.这是我的代码:
$searchLoop = array(
'u.Name',
'u.Email',
'n.Name',
'u.PhoneMobile'
);
$text = 'Manager';
$count = 0;
foreach ($searchLoop as $loop) {
$query->where(function ($where) use ($loop, $count, $text) {
if ($count === 0) {
$where->where($loop, 'like', '%' . $text . '%');
} else {
$where->orWhere($loop, 'like', '%' . $text . '%');
}
});
$count++;
}
Run Code Online (Sandbox Code Playgroud)
基于我对laraval文档和其他搜索的阅读,我希望这样翻译:
and (
`u`.`Name` like '%Manager%'
or `u`.`Email` like '%Manager%'
or `n`.`Name` like '%Manager%'
or `u`.`PhoneMobile` like '%Manager%'
)
Run Code Online (Sandbox Code Playgroud)
相反,它转换为:
and (`u`.`Name` like '%Manager%')
and (`u`.`Email` like …Run Code Online (Sandbox Code Playgroud) 我有一个名为errors以下字段的表:id, website_id, message & level.我正在尝试获得错误最多的前5个网站.
询问
SELECT website_id, COUNT(id) AS 'errors'
FROM errors GROUP BY website_id ORDER BY COUNT(*) DESC
我不知道如何使用Laravel Query Builder和Eloquent来做到这一点.谁能帮我吗?
数据库截图
我正在使用 JOIN 语句从我的数据库查询。当我使用 dd() 函数打印结果时,我得到了正确数量的结果,但是,由于某种原因,属性数组不是可见数组。
<?php
$usersResults = User::where('place', '=', $place)
->join("destinations", 'users.id', "=", "destinations.user_id")
->select("users.*", "destinations.created_at")
->groupBy("users.id")->get();
dd($usersResults);
Run Code Online (Sandbox Code Playgroud) 简要:
birthdate我的users表中有用户列.用户birthdate具有默认日期格式:Y-m-d.另外,我有自定义mutator来获取用户在User模型中的年龄.
变异器代码:
public function getAgeAttribute($value) {
if($this->birthday !== null) {
$bday = new \DateTime("{$this->birthday}");
$today = new \Datetime(date('Y-m-d'));
$diff = $today->diff($bday);
return $diff->y;
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
题:
如何使用模型按年龄获取用户User?
我在我的路由->api 中创建了 Route,但是当我这样做时php artisan route:list,它会显示除此路由之外的所有路由:
Route::apiResources([
'vh-invoice' => 'API\VhInvoiceController'
]);
Run Code Online (Sandbox Code Playgroud)
即使我删除了一些路线,它也会显示相同的路线:列表,就像我一样,删除了下面的这些路线,但在路线:列表中,它也向我显示了已删除的路线,如下图所示。
Route::get('findVTI', 'API\TicketInvoiceController@searchVTI');
Route::get('selectVTI', 'API\TicketInvoiceController@selectVTI');
Run Code Online (Sandbox Code Playgroud)
前端部分
参数的发送方式如下:
Laravel 请求
class CarCreateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
//TODO: Define authorization logic, possibly a middleware
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'car.name' => 'present|required'
];
}
}
Run Code Online (Sandbox Code Playgroud)
真正的问题
请求类始终验证为 false。我检查了验证数组部分,但看起来这可以发送如下参数:
car[name]=Spidey Mobile
Run Code Online (Sandbox Code Playgroud)
但是,我需要使用 JSON.stringify() 发送字符串化的数据。
有解决方法吗?看起来点符号不起作用,因为这是一个 JSON …
有没有办法隐藏命令的输出composer install?
我为 Laravel 应用程序运行一个部署脚本,当它打印数百行时,输出很混乱:
\n\n据我所知,似乎没有\xe2\x80\x99t 隐藏输出的标志。有什么建议吗?
\n