dsg24156 2017-03-14 12:41
浏览 77
已采纳

LARAVEL - 按钮更改DB中的布尔值

when i click the success button i have to change 'confirmação' value to 1.

Is that possible? I have to create a form to do this?

 Schema::create('visitas', function (Blueprint $table) {
            $table->increments('id');
            $table->date('data');
            $table->time('hora');
            $table->boolean('confirmacao')->default(0);
            $table->integer('imovel_id');
            $table->integer('client_id');
            $table->timestamps();

Example

  • 写回答

3条回答 默认 最新

  • douji4223 2017-03-14 12:50
    关注

    Yes you can do it with or without a form. But better with form

    <form method="post" action="/visitas">
        <input type="hidden" name="visitaID" value="$visita->id"/>
        <button class="btn btn-lg btn-success" type="submit">
            Confirmar Visita
        </button>
    </form>
    

    Define the route

    Route::post('visitas', 'VistaController@update');
    

    Write the function the controller

    public function update(Request $request)
    {
        $visita = Visita::find($request->visitaID);
        $visita->confirmacao = 1;
        $visita->update();
    
        return redirect()->back()->with('message', 'visita updated');
    }
    

    That's one way of doing it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?