如何在不使用查询生成器的情况下在Laravel 4中创建新的Eloquent Collection?
有一种newCollection()方法可以被覆盖,因为它只是在我们查询设置结果时才使用.
我正在考虑构建一个空集合,然后用Eloquent对象填充它.我不使用数组的原因是因为我喜欢Eloquent Collections方法,例如contains.
如果还有其他选择,我很乐意听听.
我已经为我的网站建立了一个多重过滤器搜索,但我似乎无法在我搜索的内部找到多个if语句的文档.
返回大量结果
$data = Scrapper::paginate(15);
Run Code Online (Sandbox Code Playgroud)
返回none ..需要它以这种方式使用IF的语句看下面.
$database = new Scrapper;
$database->get();
Run Code Online (Sandbox Code Playgroud)
我想做什么的例子..
$database = new Scrapper;
if (isset($_GET['cat-id'])) {
$database->where('cat_id', '=', $_GET['cat-id']);
}
if (isset($_GET['band'])) {
$database->where('price', 'BETWEEN', $high, 'AND', $low);
}
if (isset($_GET['search'])) {
$database->where('title', 'LIKE', '%'.$search.'%');
}
$database->get();
Run Code Online (Sandbox Code Playgroud) 所以我一直试图设置我的MAMP和Laravel,但坚持让作曲家工作.
我已经安装了MAMP,我使用命令:
curl -sS https://getcomposer.org/installer | php
我试着跑步
php composer.phar
到目前为止一切正常.
然后,当我试图将作曲家放入我的全局路径时(我假设以下行做了)
mv composer.phar /usr/local/bin/composer
我收到此错误
mv: rename composer.phar to /usr/local/bin/composer: No such file or directory
我试过mv composer.phar /usr/local/bin它也给出了同样的错误.
这是我的echo $PATH:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
关于解决这个问题的任何指示?哦,Mac新秀在这里.
我有这个控制器:
JApp.controller('WebsiteController', function($scope, $resource) {
var UsersService = $resource('/auth/users', {});
$scope.adding = false;
$scope.users = [];
$scope.addUser = function() {
$scope.adding = true;
UsersService.query({}, function(data) {
$scope.users = data;
$scope.selectedUser = data[0];
});
}
$scope.cancelAddUser = function() {
$scope.adding = false;
}
});
Run Code Online (Sandbox Code Playgroud)
我的HTML:
<section class="vbox" ng-controller="WebsiteController">
<section class="panel animated fadeInDown">
<header class="panel-heading">
<h3>{{selectedUser.last_name}} </h3> <!-- Just to test I print it here -->
</header>
<div class="panel-body m-b">
<div class="row text-sm wrapper">
@if (role_admin())
<a href="{{{URL::action('WebsiteController@getAddWebsite')}}}" class="btn btn-sm btn-info"> <i …Run Code Online (Sandbox Code Playgroud)