app/Http/Controllers/Empresa/TareasController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request)
    {
        $tarea = Tarea::find($request->get('id'));
        ($request->has('nombre'))?$tarea->nombre=$request->get('nombre'):'';
        ($request->has('detalle'))?$tarea->detalle=$request->get('detalle'):'';
        ($request->has('fecha'))?$tarea->fecha=$request->get('fecha'):'';
        if ($request->has('recordatorio')) {
            $tarea->fecha_notificacion=Carbon::parse($tarea->fecha)->subMinutes($request->get('recordatorio'))->toDateTimeString();
        }
        if ($request->has('valor')) {
            $tarea->realizado=$request->get('valor');
            if ($request->get('valor')==1) {
                $tarea->fecha_completada=Carbon::now()->toDateTimeString();
            }
        }
        $tarea->save();
        return response()->json(['id'=>$tarea->id]);
    }
public function update ( Request $ request ) { $ tarea = Tarea :: find ( $ request -> get ( 'id' ) ) ; ( $ request -> has ( 'nombre' ) ) ? $ tarea -> nombre = $ request -> get ( 'nombre' ) : '' ; ( $ request -> has ( 'detalle' ) ) ? $ tarea -> detalle = $ request -> get ( 'detalle' ) : '' ; ( $ request -> has ( 'fecha' ) ) ? $ tarea -> fecha = $ request -> get ( 'fecha' ) : '' ; if ( $ request -> has ( 'recordatorio' ) ) { $ tarea -> fecha_notificacion = Carbon :: parse ( $ tarea -> fecha ) -> subMinutes ( $ request -> get ( 'recordatorio' ) ) -> toDateTimeString ( ) ; } if ( $ request -> has ( 'valor' ) ) { $ tarea -> realizado = $ request -> get ( 'valor' ) ; if ( $ request -> get ( 'valor' ) == 1 ) { $ tarea -> fecha_completada = Carbon :: now ( ) -> toDateTimeString ( ) ; } } $ tarea -> save ( ) ; return response ( ) -> json ( [ 'id' => $ tarea -> id ] ) ; }
Update the specified resource in storage.
Update the specified resource in storage .