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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在數(shù)據(jù)庫中添加 json 類型不起作用

在數(shù)據(jù)庫中添加 json 類型不起作用

PHP
皈依舞 2023-05-26 17:30:22
我想在我用 Laravel 制作的項目中顯示醫(yī)生的可用性,使用 json 類型顯示早上和下午的可用性,如下所示:Monday_morning:["8:30" ; “12:30”] 所以一開始它是工作的,但之后它只給我看這個:Monday_morning:“12:30”最后一次添加所以這是我的控制器: 'lun_mat1' => 'nullable',            'mar_mat1' => 'nullable',            'mar_ap1' => 'nullable',            'mer_mat1' => 'nullable',            'mer_ap1' => 'nullable',            'jeu_mat1' => 'nullable',            'jeu_ap1' => 'nullable',            'ven_mat1' => 'nullable',            'ven_ap1' => 'nullable',            'sam_mat1' => 'nullable',        $medecin= new doc() ;        $medecin->Lun_mat_de=$request->input('lun_mat1');        $medecin->Lun_apres_a=$request->input('lun_ap1');        $medecin->Mar_mat_de=$request->input('mar_mat1');        $medecin->Mar_apres_a=$request->input('mar_ap1');        $medecin->Mer_mat_de=$request->input('mer_mat1');        $medecin->Mer_apres_a=$request->input('mer_ap1');        $medecin->Jeu_mat_de=$request->input('jeu_mat1');        $medecin->Jeu_apres_a=$request->input('jeu_ap1');        $medecin->Vend_mat_de=$request->input('ven_mat1');        $medecin->Vend_apres_a=$request->input('ven_ap1');        $medecin->Sam_mat_de=$request->input('sam_mat1');        $medecin->save();return redirect()->back()->withSuccess('medecin ajouter' ) ; 這是模型: protected  $table = 'doctors' ;    protected $primaryKey = 'ID';    protected $fillable = [        'ID' ,        'Photo' ,        'demande',];        protected $casts = [        'Lun_mat_de' =>'array',        'Lun_apres_a' =>'array',        'Mar_mat_de' =>'array',        'Mar_apres_a' => 'array',         'Mer_mat_de' =>'array',        'Mer_apres_a' =>'array',        'Jeu_mat_de' => 'array',        'Jeu_apres_a' => 'array',        'Vend_mat_de' => 'array' ,         'Vend_apres_a' => 'array',        'Sam_mat_de' => 'array',        ];
查看完整描述

1 回答

?
肥皂起泡泡

TA貢獻1829條經(jīng)驗 獲得超6個贊

我認為你面臨的問題是在這里:


<div class="col-4">

   <label> Monday morning </label>

   <div class="row">

      <div class="col">

          <input type="time"  name="lun_mat1" /> /* input name is supposed to be like this lun_mat1[] */

      </div>

      <div class="col">

          <input type="time"  name="lun_mat1" /> /* input name is supposed to be like this lun_mat1[] */

      </div>

    </div>

</div>

這是錯誤的,因為你想將 lun_mat1 作為數(shù)組獲取,但是你上面的兩個輸入名稱是相同的,它應該更改為這個以便在發(fā)布到控制器時檢索數(shù)組值:


<div class="col-4">

   <label> Monday morning </label>

   <div class="row">

      <div class="col">

          <input type="time"  name="lun_mat1[]" /> 

      </div>

      <div class="col">

          <input type="time"  name="lun_mat1[]" />

      </div>

    </div>

</div>

有了這個,您可以將此規(guī)則應用于所有輸入,如果您想在發(fā)布到控制器時檢索數(shù)組數(shù)據(jù),請[]在輸入名稱后添加


查看完整回答
反對 回復 2023-05-26
  • 1 回答
  • 0 關(guān)注
  • 183 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

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