第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

傳遞給 Illuminate\Database\Grammar::parameterize()

傳遞給 Illuminate\Database\Grammar::parameterize()

PHP
慕村225694 2023-07-01 13:10:07
很好,我有一個(gè)原始屬性,正在創(chuàng)建一個(gè)屬性,該屬性具有用戶通過復(fù)選框選擇的特征,我想知道如何使用屬性 id 保存在特征表中選擇的復(fù)選框集控制器           $characteristics = new Characteristic;                $characteristics->characteristic = $request->input('characteristic');            $characteristics->save();        遷移特性 public function up()    {        Schema::create('properties', function (Blueprint $table) {            $table->increments('id');            $table->string('name')->nullable;            $table->string('price')->nullable;            $table->text('description')->nullable;            $table->unsignedBigInteger('property_type_id')->nullable();            $table->unsignedBigInteger('offer_type_id')->nullable();            $table->unsignedBigInteger('spaces_id')->nullable();            $table->unsignedBigInteger('departaments_id')->nullable();            $table->unsignedBigInteger('municipalities_id')->nullable();            $table->unsignedBigInteger('details_id')->nullable();            $table->unsignedBigInteger('characteristics_id')->nullable();            $table->string('images')->nullable;            $table->float('lat')->nullable;            $table->float('lng')->nullable;            $table->string('address')->nullable;                        $table->timestamps();                        $table->foreign('property_type_id')->references('id')->on('property_type')->onDelete('cascade');            $table->foreign('offer_type_id')->references('id')->on('offer_type')->onDelete('cascade');            $table->foreign('spaces_id')->references('id')->on('spaces')->onDelete('cascade');            $table->foreign('departaments_id')->references('id')->on('departaments')->onDelete('cascade');            $table->foreign('municipalities_id')->references('id')->on('municipalities')->onDelete('cascade');            $table->foreign('details_id')->references('id')->on('details')->onDelete('cascade');            $table->foreign('characteristics_id')->references('id')->on('characteristics')->onDelete('cascade');        });    }
查看完整描述

2 回答

?
慕絲7291255

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

看起來你的$request->input('characteristic');是一個(gè)數(shù)組而不是字符串。


你需要一個(gè)循環(huán)來解決這個(gè)問題。一種方法可以是:


$data = []


foreach ($request->input('characteristic') as $characteristic) {

   $data[] = [

      'characteristic' => $characteristic,

      'property_id' => '' // something

   ];

}


Characteristic::insert($data);

->saveMany()更好的方法是通過設(shè)置關(guān)系來使用hasMany()。


$characteristics = [];


foreach ($request->input('characteristic') as $characteristic) {

   $characteristics = new Characteristic([

        'characteristic' => $characteristic

   ]);

}


$property->characteristics()->saveMany($characteristics);


查看完整回答
反對(duì) 回復(fù) 2023-07-01
?
千萬里不及你

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超9個(gè)贊

我能夠保存數(shù)據(jù)如下


$piso_id = $properti->id;

        

            foreach ($request->input('characteristic') as $characteristic) {

               

               $charc = new Characteristic;

               

               $charc->property_id = $piso_id;

               $charc->characteristic = $characteristic;

               $charc->save();

            }


查看完整回答
反對(duì) 回復(fù) 2023-07-01
  • 2 回答
  • 0 關(guān)注
  • 159 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)