草庐IT

After_Create

全部标签

php - Laravel 的 Model::create() 函数未设置自定义字段值

Laravel新手,抱歉,如果这很明显,但我已经坚持了很长时间!目标:要使用表单中的完整值批量分配Quote::create()数据库插入,加设置当前登录用户的用户ID。问题:user_id列从未写入数据库。每隔一列,但user_id保持为0。我当然尝试过将user_id添加到$fillable数组,但我不希望它是用户可填写的-我希望它由Laravel的Auth::id()函数。知道为什么这不会被存储吗?是因为$quote->create()函数没有考虑之前设置的数据,只是将其参数作为要保存的所有内容吗?如果是这样,我该怎么做?这是我的Controller的store()函数:/***

php - 函数 mcrypt_create_iv() 在 CodeIgniter 框架中被弃用

skey,$text,MCRYPT_MODE_ECB,$iv);returntrim($this->safe_b64encode($crypttext));}publicfunctiondecode($value){if(!$value){returnfalse;}$crypttext=$this->safe_b64decode($value);$iv_size=mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB);$iv=mcrypt_create_iv($iv_size,MCRYPT_RAND);$decrypttext=m

php - 警告 : preg_match(): Compilation failed: unrecognized character after (? 或 (?-

我有一个以前的程序员编写的代码,一个抛出编译错误的正则表达式preg_match:$regex_t="/".$op."(?\\>[^".$op.$cl."]+)*".$cl."/s";preg_match($regex_t,$text,$inner);我收到的警告是:Warning:preg_match():Compilationfailed:unrecognizedcharacterafter(?or(?-atoffset4另外,我想提一下var_dump($regex_t)的值是:string'/\{(?\>[^\{\}]+)*\}/s'(length=21)

PHP : How to create a string of image binary without saving it to a file?

我有一个图像变量,$im=imagecreatetruecolor(400,300);有没有办法在不将其保存到文件的情况下以jpeg格式获取此图像的二进制字符串?谢谢! 最佳答案 是的,这是可能的(即使没有输出缓冲)。它看起来没有记录,但您可以传递流资源而不是文件名。 关于PHP:Howtocreateastringofimagebinarywithoutsavingittoafile?,我们在StackOverflow上找到一个类似的问题: https://

php - 创建 zf 自定义命令,例如 zf create form

当我像这样使用zendCLI创建表单时,会生成一个表单并将其添加到表单文件夹中。zfcreateformMyForm我有一个自定义类,我想以相同的方式为其创建一个自定义命令,并希望查看zfcreateform命令以获取指导。我怀疑它在Zend_Framework/bin中,那里有一个shell、php、bat文件,但我找不到任何与创建表单类相关的代码,也许我错过了?无论如何,有更好的方法来完成同样的事情吗?比如让我自己创建其中一些命令的ZendAPI?如果不是,我唯一的选择是查看如何创建类似zfcreateform的内容。 最佳答案

php - 警告 : File upload error - unable to create a temporary file in Unknown on line 0

每次尝试上传文件时都会出现以下错误。“警告:文件上传错误-无法在第0行的未知中创建临时文件”这是我的HTML表单,ProductNameProductPriceRs:CategoryBedroomLivingroomDiningSub-CategoryDiningtablesshoerackswardrobessofaProductDetailsProductImage 这是我的PHP代码,if(isset($_POST["product_name"])){$product_name=mysql_real_escape_string($_POST["product_name"

php - 类型错误:传递给 Illuminate\Database\Eloquent\Builder::create() 的参数 1 必须是数组类型,给定为 null

我正在尝试在laravelrestapi中发布标题和文章,但出现此错误Typeerror:Argument1passedtoIlluminate\Database\Eloquent\Builder::create()mustbeofthetypearray,nullgiven,calledinC:\xampp\htdocs\LaravelProject\cpapi\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.phponline1440这是我的帖子数据的route/api.php文件Route::post

php - "Cannot set session ID after the session has started."测试表单时

我正在为我的应用程序编写单元测试。我编写了一个函数来登录不同的用户(以测试用户级别)和一个函数来生成有效或无效的表单数据(以测试我的表单处理)。当测试提交表单时,它抛出一个异常:UncaughtPHPExceptionLogicException:"CannotsetsessionIDafterthesessionhasstarted."我正在使用Symfony2.6.4。我找不到有关此错误消息的任何有用信息。该测试在不久前运行良好。classControllerTestextendsWebTestCase{public$client=null;public$route='home/'

php - 迁移 CakePHP 2 到 3 : Before/after-attribute of save button (form helper)

将CakePHP2.x迁移到3.x,在提交按钮中CakePHP2.x具有after和before属性,但这不适用于CakePHP3.x。Form->submit(__('Save'),array('div'=>'form-actions','class'=>'btnbtn-largebtn-primarybtn-save','data-loading-text'=>'PleaseWait...','after'=>''.$this->Html->link(__('Cancel'),array('admin'=>true,'action'=>'index'),array('class'=

php - Laravel 工厂关系......尊重 create() 或 make()

根据Laravel的documentationondefiningrelationshipswithinmodelfactories:YoumayalsoattachrelationshipstomodelsusingClosureattributesinyourfactorydefinitions.Forexample,ifyouwouldliketocreateanewUserinstancewhencreatingaPost,youmaydothefollowing:$factory->define(App\Post::class,function($faker){return[