<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                > 原文出處:https://www.phodal.com/blog/bare-minimum-iot-system-restful-template/ 下面這部分來自于之前的博客,這里就不多加論述了。 ~~~ 這個也就是我們要的模板, ~~~ ## 修改Create() ~~~ public function create() { $maxid=Athomes::max('id'); return View::make('athome.create')->with('maxid',$maxid); } ~~~ 這里需要在app/views/創建一個athome里面創建一個create.blade.php,至于maxid,暫時還不需要,后面會用到show。如果只需要模板,可以簡化為 ~~~ public function create() { return View::make('athome.create'); } ~~~ 這里只是對其中代碼的進行一下說明。 ## 創建表單 ### 創建表單之前 由于使用到了bootstrap以及bootstrap-select,記得添加css。 ~~~ <link rel="stylesheet" type="text/css" href="<?= url('css/bootstrap.min.css') ?>" /> <link rel="stylesheet" type="text/css" href="<?= url('css/bootstrap-select.min.css') ?>" /> ~~~ 以及javascript ~~~ <script type="text/javascript" src="<?= url('js/jquery.min.js')?>"></script> <script type="text/javascript" src="<?= url('js/bootstrap.min.js') ?>"></script> <script type="text/javascript" src="<?= url('js/bootstrap-select.min.js') ?>"></script> <script> $('.selectpicker').selectpicker(); </script> ~~~ ### 創建表單 這里用到的是之前提到的那個作者寫下的,稍微修改了一下。 ~~~ <div class="row-fluid"> {{ HTML::ul($errors->all()) }} {{ Form::open(array('url' => 'athome')) }} <div class="form-group"> {{ Form::label('led1', '開關1') }} {{ Form::select('led1',array('關','開'),$selected=NULL,array('class'=>'selectpicker')) }} </div> <div class="form-group"> {{ Form::label('sensors1', 'sensors1') }} {{ Form::text('sensors1', Input::old('sensors1'), array('class' => 'form-control')) }} </div> <div class="form-group"> {{ Form::label('sensors2', 'sensors2') }} {{ Form::text('sensors2', Input::old('sensors2'), array('class' => 'form-control')) }} </div> <div class="form-group"> {{ Form::label('temperature', 'temperature') }} {{ Form::text('temperature', Input::old('temperature'), array('class' => 'form-control')) }} </div> {{ Form::submit('Create!', array('class' => 'btn btn-primary')) }} {{ Form::close() }} </div> ~~~ 開關一開始打算用checkbox,加上bootstrap-switch實現 ~~~ <div id="dimension-switch" class="make-switch has-switch"> <div class="switch-animate switch-on"> <span class="switch-left">ON</span><label>?</label><span class="switch-right">OFF</span> </div> </div> ~~~ 弱弱地覺得還是沒掌握好的節奏,所以最后用select來實現。 還需要修改一下之前的create(),添加一行 ~~~ return Redirect::to('athome'); ~~~ 也就是添加完后,重定向到首頁查看,最后例子給出的create如下 ~~~ public function store() { $rules = array( 'led1'=>'required', 'sensors1' => 'required|numeric|Min:-50|Max:80', 'sensors2' => 'required|numeric|Min:-50|Max:80', 'temperature' => 'required|numeric|Min:-50|Max:80' ); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('athome/create') ->withErrors($validator); } else { // store $nerd = new Athomes; $nerd->sensors1 = Input::get('sensors1'); $nerd->sensors2 = Input::get('sensors2'); $nerd->temperature = Input::get('temperature'); $nerd->led1 = Input::get('led1'); $nerd->save(); Session::flash('message', 'Successfully created athome!'); return Redirect::to('athome'); } } ~~~ ## 編輯edit 完整的blade模板文件 ~~~ <!DOCTYPE html lang="zh-cn"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <meta name="keywords" content=""> <meta name="viewport" content="width=device-width"> <meta name="description" content=""> <title>@yield('title')</title> <link rel="stylesheet" type="text/css" href="<?= url('css/bootstrap.min.css') ?>" /> <link rel="stylesheet" type="text/css" href="<?= url('css/bootstrap-select.min.css') ?>" /> <link rel="stylesheet" href="<?= url('css/justified-nav.css') ?>" type="text/css" media="screen" /> </head> <body> <div class="container"> <div class="container"> <div class="row-fluid"> <h1>Edit {{ $athome->id }}</h1> <!-- if there are creation errors, they will show here --> {{ HTML::ul($errors->all()) }} {{ Form::model($athome, array('route' => array('athome.update', $athome->id), 'method' => 'PUT')) }} <div class="form-group"> {{ Form::label('led1', '開關1') }} {{ Form::select('led1',array('關','開'),$selected=NULL,array('class'=>'selectpicker')) }} </div> <div class="form-group"> {{ Form::label('sensors1', '傳感器1') }} {{ Form::text('sensors1', Input::old('sensors1'), array('class' => 'form-control')) }} </div> <div class="form-group"> {{ Form::label('sensors2', '傳感器2') }} {{ Form::text('sensors2', Input::old('sensors2'), array('class' => 'form-control')) }} </div> <div class="form-group"> {{ Form::label('temperature', '溫度傳感器') }} {{ Form::text('temperature', Input::old('temperature'), array('class' => 'form-control')) }} </div> {{ Form::submit('Edit the Nerd!', array('class' => 'btn btn-primary')) }} {{ Form::close() }} </div> </div> <div class="footer"> <p>? Company 2013</p> </div> </div> </div> <script type="text/javascript" src="<?= url('js/jquery.min.js')?>"></script> <script type="text/javascript" src="<?= url('js/bootstrap.min.js') ?>"></script> <script type="text/javascript" src="<?= url('js/bootstrap-select.min.js') ?>"></script> <script> $('.selectpicker').selectpicker(); </script> <script type="text/javascript" src="<?= url('js/log.js') ?>"></script> </body> </html> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看