首页 >

laravel5一对多的create问题

后端开发|php教程laravel5一对多的create问题
php,laravel,laravel5
后端开发-php教程
弹幕服务器搭建源码,vscode单标签,ubuntu开发定制版,mac tomcat升级,sqlite 导入脚本,discuz 手机版 插件,ui前端框架 精美漂亮,爬虫 多ip,数组 字符串 php,友情链接对seo,java门户型网站源码,网页后台模板下载,jq 手机登录模板,电商网站页面源码下载,拓网手机触屏版网站管理系统,程序侠如何自动采集lzw
array:7 [▼  "_token" => "Y9szFJQYRcmHpyBB1McOE9tbUoZmshmJHzfV1hMG"  "title" => "1"  "image" => "2"  "itemimages" => array:2 [▼    0 => array:1 [▼      "image" => "/editor/php/../attached/image/20151203/20151203071049_60053.jpg"    ]    1 => array:1 [▼      "image" => "/editor/php/../attached/image/20151203/20151203071049_32261.jpg"    ]  ]  "category_id" => "4"  "content" => "3"  "text" => "3"]

一个表单传递过来一个商品的信息,并且这个商品

php微商店源码,跨硬盘引导ubuntu,屯门免费爬虫馆,php rand,react如何seolzw
        $data=$request->all();        $data['text']=mb_substr($data['content'],0,64);        $save=Item::create($data);

商品创建成功,然后需要往图片库里加图片$data[‘itemimages’],

建站工作室源码,安装vscode怎么改为中文,ubuntu搭建代理,tomcat文件未部署,sqlite查询 实例,中国最好的网页设计公司,ca服务器https,dx论坛认证插件,前端框架dest,oss防爬虫,php思想,上海专业seo服务公司,springboot上传回滚,免费做网站. 优帮云,网页广告模板,展览模板,dede登陆成功进不了后台,手机页面导航代码,手机房源管理系统,手机网站程序下载lzw
$save->itemimages()->save($data['itemimages']);//报错$save->itemimages()->saveMany($data['itemimages']);//报错$save->itemimages()->create($data['itemimages']);//item_id有值,image为空

后来尝试格式换一下

"itemimages" => array:1 [▼      "image" => "/editor/php/../attached/image/20151203/20151203071049_60053.jpg"  ]$save->itemimages()->create($data['itemimages']);//成功

那么多张图片怎么办

Item已经定义

public function itemimages(){    return $this->hasMany("App\Itemimage");}

回复内容:

array:7 [▼  "_token" => "Y9szFJQYRcmHpyBB1McOE9tbUoZmshmJHzfV1hMG"  "title" => "1"  "image" => "2"  "itemimages" => array:2 [▼    0 => array:1 [▼      "image" => "/editor/php/../attached/image/20151203/20151203071049_60053.jpg"    ]    1 => array:1 [▼      "image" => "/editor/php/../attached/image/20151203/20151203071049_32261.jpg"    ]  ]  "category_id" => "4"  "content" => "3"  "text" => "3"]

一个表单传递过来一个商品的信息,并且这个商品

        $data=$request->all();        $data['text']=mb_substr($data['content'],0,64);        $save=Item::create($data);

商品创建成功,然后需要往图片库里加图片$data[‘itemimages’],

$save->itemimages()->save($data['itemimages']);//报错$save->itemimages()->saveMany($data['itemimages']);//报错$save->itemimages()->create($data['itemimages']);//item_id有值,image为空

后来尝试格式换一下

"itemimages" => array:1 [▼      "image" => "/editor/php/../attached/image/20151203/20151203071049_60053.jpg"  ]$save->itemimages()->create($data['itemimages']);//成功

那么多张图片怎么办

Item已经定义

public function itemimages(){    return $this->hasMany("App\Itemimage");}

$itemimages=[];foreach($data['itemimages'] as $v){    $itemimages[]=new App\Itemimage(['image' => $v['image']),}$save->itemimages()->saveMany($itemimages);

laravel5一对多的create问题
  • Lumen开启StartSession中间件后,报错:Response需要为Object,但是得到的是String
  • Lumen开启StartSession中间件后,报错:Response需要为Object,但是得到的是String | Lumen开启StartSession中间件后,报错:Response需要为Object,但是得到的是String ...

    laravel5一对多的create问题
  • laravel 隐式路由 简洁书写
  • laravel 隐式路由 简洁书写 | laravel 隐式路由 简洁书写 ...

    laravel5一对多的create问题
  • Laravel 5框架学习之数据库迁移(Migrations),laravelmigrations
  • Laravel 5框架学习之数据库迁移(Migrations),laravelmigrations | Laravel 5框架学习之数据库迁移(Migrations),laravelmigrations ...