我无法通过代码复制来复制ajax调用.
例如:
$I->sendAjaxPostRequest('login/verify', array('name' => 'name', 'password' => 'password'));
$I->seeResponseIsJson();
Run Code Online (Sandbox Code Playgroud)
不会引起任何错误.但另一方面,如果我做以下事情:
$I->sendAjaxPostRequest('login/verify', array('name' => 'name', 'password' => 'password'));
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['login_failed' => 1]);
//or
$I->grabDataFromJsonResponse('data.login_failed');
Run Code Online (Sandbox Code Playgroud)
它给了我这个错误:
ErrorException:传递给Codeception的参数2\Module\REST :: arrayHasArray()必须是数组类型,给定null,在C:\ xampp\htdocs\blog\laravel\vendor\codeception\codeception\src\Codeception\Module中调用\ REST.php在485行并定义
我从上面的错误中理解的是,seeResponseContainsJson或grabDataFromJsonResponse在内部会将响应作为第二个参数传递给arrayHasArray.但看起来无论响应总是空的.
另外,如果我执行以下操作:
$I->sendAjaxPostRequest('login/verify', array('name' => 'name', 'password' => 'password'));
var_dump($I->grabResponse());
Run Code Online (Sandbox Code Playgroud)
我收到这个var_dump():
object(Codeception\Maybe)#753 (3) {
["position":protected]=>
int(0)
["val":protected]=>
NULL
["assocArray":protected]=>
NULL
}
Run Code Online (Sandbox Code Playgroud)
使用Codeception,其他所有工作都按预期工作,我正在使用PhpBrowser.
我在Laravel 4中的模型中的一个函数中放了一个断点.
我看到$this有两个属性和原始.
两者似乎都包含相同的数据,即表示表中字段的键/值对.
有什么不同?
我需要在我的模型中的一个函数,它将所有字段作为关联数组返回,我使用哪一个?

我的laravel4应用程序中有一个小型图像生成器。生成图像大约需要700毫秒,因此我开始在服务器上缓存生成的结果,并将其返回给浏览器,这样可以节省一些时间。
由于图像一旦生成就永远不会改变,所以我想告诉浏览器在本地缓存图像,并使用以下代码完成了此操作:
$path = $cacheFolderPath . $cacheFileName;
if (File::exists( $path )){
$response = Response::make(File::get($path));
$response->header('Content-Type', 'image/png');
$response->header('Content-Disposition', 'inline; filename="'.$cacheFileName.'"');
$response->header('Content-Transfer-Encoding', 'binary');
$response->header('Cache-Control', 'public, max-age=10800, pre-check=10800');
$response->header('Pragma', 'public');
$response->header('Expires', date(DATE_RFC822,strtotime(" 2 day")) );
$response->header('Last-Modified', date(DATE_RFC822, File::lastModified($path)) );
$response->header('Content-Length', filesize($path));
return $response;
}
Run Code Online (Sandbox Code Playgroud)
这会将带有状态代码的图像发送200 OK到带有以下标头的浏览器:
Cache-Control:max-age=10800, pre-check=10800, public
Connection:Keep-Alive
Content-Disposition:inline; filename="pie_0_normal.png"
Content-Length:2129
Content-Transfer-Encoding:binary
Content-Type:image/png
Date:Wed, 07 Aug 2013 10:29:20 GMT
Expires:Fri, 09 Aug 13 10:29:20 +0000
Keep-Alive:timeout=5, max=93
Last-Modified:Wed, 07 Aug 13 10:14:42 +0000
Pragma:public
Server:Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7
Set-Cookie:laravel_session=767487mhf6j2btv3k01vu56174; …Run Code Online (Sandbox Code Playgroud) 假设我有三个表用户,users_groups和groups.如何通过users_groups表获取用户的组?
class User extends Eloquent {
protected $table = 'users';
}
class Groups extends Eloquent {
protected $table = 'groups';
}
class Usergroups extends Eloquent {
protected $table = 'users_groups';
}
Run Code Online (Sandbox Code Playgroud) 我刚开始在laravel 4中实现restful控制器.我不明白在使用这种路由方式时如何将参数传递给控制器中的函数.
控制器:
class McController extends BaseController
{
private $userColumns = array("stuff here");
public function getIndex()
{
$apps = Apps::getAllApps()->get();
$apps=$apps->toArray();
return View::make('mc')->nest('table', 'mc_child.table',array('apps'=>$apps, 'columns'=>$this->userColumns));
}
public function getTable($table)
{
$data = $table::getAll()->get();
$data=$data->toArray();
return View::make('mc')->nest('table', 'mc_child.table',array('apps'=>$apps, 'columns'=>$this->userColumns));
}
}
Run Code Online (Sandbox Code Playgroud)
路线:
Route::controller('mc', 'McController');
Run Code Online (Sandbox Code Playgroud)
我能够访问这两个URL,因此我的路由工作正常.使用此路由和控制器方法时,如何将参数传递给此控制器?
我无法在PhpStorm中设置自动完成功能来处理Laravel 4 blade.php文件.我到处搜索,但我找不到其他用户的问题.我已经在https://github.com/barryvdh/laravel-ide-helper上正确安装了此存储库,但我仍然得到刀片页面的空白格式.
谢谢
我是laravel 4的新手,我正在尝试按照Apigee定义的最佳实践创建一个rest API.
apigee定义的最佳实践之一是对json属性键使用camel case,这种方式在Javascript中使用API时,相应的对象将遵循属性代码约定(camel case).
我希望能够在蛇案例之后定义数据表列,但是当通过我的api检索有说服力的对象时,相应的JSON必须遵循骆驼案例.
我读到了一个静态变量$ snakeAttributes,它可以在模型类中设置,它的文档说"指示属性是否是蛇形数组".我试图覆盖这个变量并将其设置为false(MyResource类)但是在执行下面的代码时,json仍然以蛇形式出现:
码:
$resource = MyResource::find($id);
return Response::json($resource);
Run Code Online (Sandbox Code Playgroud)
JSON:
{
first_name: 'Michael',
created_at: "2013-10-24 15:30:01",
updated_at: "2013-10-24 15:30:01"
}
Run Code Online (Sandbox Code Playgroud)
有人知道如何解决这个问题吗?
由于我的表单没有标签,我希望能够使用与Angular和Angular-UI-Utils-Mask不同的占位符:
<div ng-controller="myController">
<input type="text"
ng-model="date"
ui-mask="99/99/9999"
placeholder="Birth Date"/>
</div>
Run Code Online (Sandbox Code Playgroud)
使用jquery-inputmask它就像一个魅力,但我有太多的问题,使它与Angular一起工作,所以我现在尝试去Angular方式,但Angular显示我的输入为:
Bi/th/Date
Run Code Online (Sandbox Code Playgroud)
这是一个显示它的小提琴:http://jsfiddle.net/XS4R6/
我也看到有些人在谈论'u-mask-placeholder',但它什么也没做.
有没有办法实现这个目标?
编辑
为了澄清,我认为只使用它是正常的,placeholders因为你也使用titles(提示)所以人们总是知道他们应该在这些输入中键入什么:

显示的输入__.___.___是我正在使用Angular UI Mask的输入.
JQuery Inputmask工作得非常好,因为它显示了'name'占位符,只要我鼠标悬停或单击输入它就会显示掩码.
我是Laravel框架的新手.我正在使用4.2我的问题是我在manageemployee页面中有一个分页功能,我已经为manageemployee页面创建了一个路由.
Route::get('/usercp/manageemployee',array('uses' =>'ManageEmployeeController@getManageCompanyEmployee','as' =>'getManageCompanyEmployee'));
Run Code Online (Sandbox Code Playgroud)
在这个页面我有分页,如果用户在第三页,他想删除一条记录.
现在页面看起来像/ usercp/manageemployee?page = 3删除该页面中的特定记录后,我需要将用户重定向到同一页面.
我的重定向代码如下
return Redirect::route('getManageCompanyEmployee')->with('success','Record deleted successfully');
Run Code Online (Sandbox Code Playgroud)
但是使用上面的代码,用户来到第一页,如/ usercp/manageemployee.但重定向用户需要在第3页/ usercp/manageemployee?page = 3之后.
如何实现这一目标?
I`m use
public function getImages($array_symbols_id){
$array_images = DB::table('photo')
->whereIn('photo_symbol_id', $array_symbols_id)
->where('photo_moderation_id','2')
->orderByRaw('RAND()')
->get(['photo_id', 'photo_src', 'photo_symbol_id']);
Run Code Online (Sandbox Code Playgroud)
then try
$array = array();
foreach ($array_symbols_id as $id) {
$array[] = $array_images->where('photo_symbol_id', $id)->first()->photo_src;
}
Run Code Online (Sandbox Code Playgroud)
but i have exception Call to a member function where() on array.
Why DB::table returns an array but not a collection?
laravel v5.0.35
laravel ×9
laravel-4 ×7
php ×3
angular-ui ×1
angularjs ×1
blade ×1
codeception ×1
eloquent ×1
http-caching ×1
http-headers ×1
laravel-5 ×1
masking ×1
phpstorm ×1
query-string ×1
routing ×1