Class MyClass{
private $data=array('action'=>'insert');
public function insert(){
echo 'called insert';
}
public function run(){
$this->$this->data['action']();
}
}
Run Code Online (Sandbox Code Playgroud)
这不起作用:
$this->$this->data['action']();
Run Code Online (Sandbox Code Playgroud)
只有可能使用call_user_func();?
我真的找不到从路由名称生成安全URL的方法.
要获得完整的URL,我使用
echo route('my_route_name');
Run Code Online (Sandbox Code Playgroud)
但是,如果我想要一个带https的URL怎么办?
我试着像这样使用json_decode:
json_decode($string, true, 100, JSON_BIGINT_AS_STRING);
Run Code Online (Sandbox Code Playgroud)
但我得到了错误:
Warning: json_decode() expects at most 2 parameters, 4 given in /home/content/27/2326027/html/sys/get.php on line 38
Run Code Online (Sandbox Code Playgroud)
任何回应都是适当的
我正在用嘲弄运行phpunit(没有DB/fixtures),但是我在模拟模型时遇到了麻烦.
$customer = Mockery::mock(CustomerModel::class);
echo $customer->id;
Run Code Online (Sandbox Code Playgroud)
产生错误:
BadMethodCallException: Method Mockery_1_models_Customer::hasAttribute() does not exist on this mock object
然后我尝试了:
$customer->shouldReceive('hasAttribute')->andReturn(true);
Run Code Online (Sandbox Code Playgroud)
但是,我再次参与:
Fatal error: Call to a member function getDb() on a non-object in ..\yiisoft\yii2\db\ActiveRecord.php on line 135
有什么建议?
有没有办法以某种方式覆盖队列侦听器的输出?
Processed: Illuminate\Queue\CallQueuedHandler@call 不是很有用,如果我能以某种方式输出实际的作业名称,以及实际正在处理的一些参数,那就太好了。
挖了代码,WorkCommandclass用这一行来输出job的名字,但是我实际的job class和这里使用的job不一样。
$this->output->writeln('<error>['.Carbon::now()->format('Y-m-d H:i:s').'] Failed:</error> '.$job->getName());
laravel ×2
php ×2
activerecord ×1
https ×1
json ×1
laravel-5.2 ×1
mockery ×1
oop ×1
phpunit ×1
queue ×1
routing ×1
unit-testing ×1
url ×1
yii2 ×1