浏览代码

手机号

Silent 6 年之前
父节点
当前提交
d6e93d474e

+ 12 - 0
app/Http/Controllers/Admin/StudentController.php

xqd xqd
@@ -9,6 +9,7 @@ use App\Models\StudentCourseTeacher;
 use App\Models\Teacher;
 use App\Models\TeacherStudent;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
 
 class StudentController extends Controller
 {
@@ -59,6 +60,17 @@ class StudentController extends Controller
             return $this->showWarning('数据错误');
         }
 
+        $validator = Validator::make($request->input('data'), [
+            'phone' => 'required|unique:students'
+        ], [
+            'phone.required' => '手机必填',
+            'phone.unique' => '手机已存在',
+        ]);
+
+        if($validator->fails()) {
+            return back()->withErrors($validator);
+        }
+
         $res = $this->model->create($request->input('data'));
 
         if(!$res) {

+ 30 - 0
database/migrations/2018_08_07_161532_add_phone_to_students.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddPhoneToStudents extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('students', function (Blueprint $table) {
+            $table->string('phone', 200)->nullable()->after('name')->comment('手机');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 10 - 0
resources/views/admin/students/create.blade.php

xqd
@@ -38,6 +38,16 @@
                                 @endif
                             </div>
 
+                            <div class="form-group row">
+                                <label class="col-sm-2 col-sm-offset-1 control-label">手机</label>
+                                <div class="col-sm-8">
+                                    <input type="text" name="data[phone]" class="form-control" placeholder="请输入学员姓名" value="{{ isset(old('data')['phone']) ? old('data')['phone'] : '' }}" required>
+                                </div>
+                                @if($errors->has('phone'))
+                                    <span class="help-block">{{ $errors->first('phone') }}</span>
+                                @endif
+                            </div>
+
                             <div class="form-group row">
                                 <label class="col-sm-2 col-sm-offset-1 control-label">年龄</label>
                                 <div class="col-sm-8">

+ 48 - 47
wechat/pages/article/article.js

xqd xqd xqd xqd xqd
@@ -21,20 +21,20 @@ Page({
     }],
     selectedTab: 'video',
   },
-  onLoad: function(a) {
+  onLoad: function (a) {
     // app.pageOnLoad(this);
     this.loadMoreGoodsList('both');
   },
   swiperTab: function (e) {
     var that = this;
-    console.log(e);
+    // console.log(e);
     that.setData({
       selectedTab: e.detail.currentItemId
     });
   },
   clickTab: function (e) {
     var that = this;
-    console.log(e)
+    // console.log(e)
     if (this.data.selectedTab === e.target.dataset.current) {
       return false;
     } else {
@@ -43,14 +43,14 @@ Page({
       })
     }
   },
-  onReady: function() {},
-  onShow: function() {
+  onReady: function () { },
+  onShow: function () {
     // app.pageOnShow(this);
   },
-  onHide: function() {},
-  onUnload: function() {},
-  onPullDownRefresh: function() {},
-  loadMoreGoodsList: function(tab) {
+  onHide: function () { },
+  onUnload: function () { },
+  onPullDownRefresh: function () { },
+  loadMoreGoodsList: function (tab) {
     var tab = tab || this.data.selectedTab;
     var o = this;
     // if (!is_loading_more) {
@@ -96,38 +96,39 @@ Page({
         'type': tab
       },
       success: res => {
-        if (res.data.list.length > 0) {
-          if(res.data.type == 'video') {
-            var t = o.data.video_list.concat(res.data.list);
-            o.setData({
-              video_list: t,
-              page: i + 1
-            });
-          } else if (res.data.type == 'article') {
-            var t = o.data.article_list.concat(res.data.list);
-            o.setData({
-              article_list: t,
-              page: i + 1
-            });
-          } else if (res.data.type == 'both') {
-            var t = o.data.video_list.concat(res.data.video_list);
-            o.setData({
-              video_list: t,
-              page: i + 1
-            });
-            var t = o.data.article_list.concat(res.data.article_list);
-            o.setData({
-              article_list: t,
-              page: i + 1
-            });
+        if (res.data.status == 'success') {
+          if (res.data.type != 'both' && res.data.list.length <= 0) {
+            wx.showToast({
+              title: '到底了',
+              icon: 'none',
+              duration: 800
+            })
+          } else {
+            if (res.data.type == 'video') {
+              var t = o.data.video_list.concat(res.data.list);
+              o.setData({
+                video_list: t,
+                page: i + 1
+              });
+            } else if (res.data.type == 'article') {
+              var t = o.data.article_list.concat(res.data.list);
+              o.setData({
+                article_list: t,
+                page: i + 1
+              });
+            } else if (res.data.type == 'both') {
+              var t = o.data.video_list.concat(res.data.video_list);
+              o.setData({
+                video_list: t,
+                page: i + 1
+              });
+              var t = o.data.article_list.concat(res.data.article_list);
+              o.setData({
+                article_list: t,
+                page: i + 1
+              });
+            }
           }
-          
-        } else {
-          wx.showToast({
-            title: '到底了',
-            icon: 'none',
-            duration: 800
-          })
         }
       }
     })
@@ -152,18 +153,18 @@ Page({
     // });
     // }
   },
-  play: function(a) {
+  play: function (a) {
     var t = a.currentTarget.dataset.index;
     wx.createVideoContext("video_" + this.data.show_video).pause(), this.setData({
       show_video: t,
       show: !0
     });
   },
-  onReachBottom: function() {
+  onReachBottom: function () {
     this.loadMoreGoodsList();
     // is_no_more || this.loadMoreGoodsList();
   },
-  more: function(a) {
+  more: function (a) {
     var t = this,
       o = a.target.dataset.index,
       i = t.data.video_list,
@@ -173,11 +174,11 @@ Page({
       });
     this.animation = e, -1 != i[o].show ? (e.rotate(0).step(), i[o].show = -1) : (e.rotate(0).step(),
       i[o].show = 0), t.setData({
-      video_list: i,
-      animationData: this.animation.export()
-    });
+        video_list: i,
+        animationData: this.animation.export()
+      });
   },
-  redirectToArticle: function(e) {
+  redirectToArticle: function (e) {
     let id = e.currentTarget.dataset.id;
     wx.navigateTo({
       url: '/pages/article-detail/index?id=' + id

+ 1 - 1
wechat/pages/article/article.wxml

xqd
@@ -1,7 +1,7 @@
 <view class="swiper-tab">
   <view class="swiper-tab-item {{ item.tab == selectedTab ? 'active' : '' }}" data-current="{{ item.tab }}" bindtap="clickTab" wx:for="{{ tabList }}">{{ item.title }}</view>
 </view>
-<swiper current="{{ selectedTab }}" duration="300" bindchange="swiperTab">
+<swiper current-item-id="{{ selectedTab }}" duration="300" bindchange="swiperTab">
   <swiper-item item-id="video">
     <view class="after-navber">
       <view class="info">