1
0
Эх сурвалжийг харах

删除多余migrations文件

moell 9 жил өмнө
parent
commit
b2e6f7ad24

+ 8 - 2
app/Http/Requests/Backend/Category/CreateRequest.php

@@ -24,8 +24,14 @@ class CreateRequest extends Request
     public function rules()
     {
         return [
-            'title' => 'required|min:5',
-            'content' => 'required'
+            'name' => 'required',
+        ];
+    }
+
+    public function messages()
+    {
+        return [
+            'name.required' => '分类名不能为空'
         ];
     }
 }

+ 1 - 1
app/Models/Article.php

@@ -10,7 +10,7 @@ class Article extends Model implements Transformable
 {
     use TransformableTrait;
 
-    protected $table = 'article';
+    protected $table = 'articles';
 
     protected $fillable = [];
 

+ 3 - 3
database/migrations/2016_07_25_130523_create_article_table.php → database/migrations/2016_07_25_130523_create_articles_table.php

@@ -3,7 +3,7 @@
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 
-class CreateArticleTable extends Migration
+class CreateArticlesTable extends Migration
 {
     /**
      * Run the migrations.
@@ -12,7 +12,7 @@ class CreateArticleTable extends Migration
      */
     public function up()
     {
-        Schema::create('article', function(Blueprint $table) {
+        Schema::create('articles', function(Blueprint $table) {
             $table->increments('id');
             $table->string('title', 200)->default('')->comment('文章标题');
             $table->longText('content')->defualt('')->comment('文章内容');
@@ -36,6 +36,6 @@ class CreateArticleTable extends Migration
      */
     public function down()
     {
-        Schema::drop('article');
+        Schema::drop('articles');
     }
 }

+ 0 - 33
database/migrations/2016_08_07_135242_create_users_table.php

@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateUsersTable extends Migration
-{
-
-	/**
-	 * Run the migrations.
-	 *
-	 * @return void
-	 */
-	public function up()
-	{
-		Schema::create('users', function(Blueprint $table) {
-            $table->increments('id');
-
-            $table->timestamps();
-		});
-	}
-
-	/**
-	 * Reverse the migrations.
-	 *
-	 * @return void
-	 */
-	public function down()
-	{
-		Schema::drop('users');
-	}
-
-}

+ 0 - 33
database/migrations/2016_08_07_135407_create_articles_table.php

@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateArticlesTable extends Migration
-{
-
-	/**
-	 * Run the migrations.
-	 *
-	 * @return void
-	 */
-	public function up()
-	{
-		Schema::create('articles', function(Blueprint $table) {
-            $table->increments('id');
-
-            $table->timestamps();
-		});
-	}
-
-	/**
-	 * Reverse the migrations.
-	 *
-	 * @return void
-	 */
-	public function down()
-	{
-		Schema::drop('articles');
-	}
-
-}

+ 0 - 33
database/migrations/2016_08_07_141208_create_users_table.php

@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateUsersTable extends Migration
-{
-
-	/**
-	 * Run the migrations.
-	 *
-	 * @return void
-	 */
-	public function up()
-	{
-		Schema::create('users', function(Blueprint $table) {
-            $table->increments('id');
-
-            $table->timestamps();
-		});
-	}
-
-	/**
-	 * Reverse the migrations.
-	 *
-	 * @return void
-	 */
-	public function down()
-	{
-		Schema::drop('users');
-	}
-
-}

+ 0 - 33
database/migrations/2016_08_07_143014_create_users_table.php

@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateUsersTable extends Migration
-{
-
-	/**
-	 * Run the migrations.
-	 *
-	 * @return void
-	 */
-	public function up()
-	{
-		Schema::create('users', function(Blueprint $table) {
-            $table->increments('id');
-
-            $table->timestamps();
-		});
-	}
-
-	/**
-	 * Reverse the migrations.
-	 *
-	 * @return void
-	 */
-	public function down()
-	{
-		Schema::drop('users');
-	}
-
-}

+ 0 - 33
database/migrations/2016_08_07_143050_create_users_table.php

@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateUsersTable extends Migration
-{
-
-	/**
-	 * Run the migrations.
-	 *
-	 * @return void
-	 */
-	public function up()
-	{
-		Schema::create('users', function(Blueprint $table) {
-            $table->increments('id');
-
-            $table->timestamps();
-		});
-	}
-
-	/**
-	 * Reverse the migrations.
-	 *
-	 * @return void
-	 */
-	public function down()
-	{
-		Schema::drop('users');
-	}
-
-}

+ 0 - 33
database/migrations/2016_08_07_143056_create_categories_table.php

@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class CreateCategoriesTable extends Migration
-{
-
-	/**
-	 * Run the migrations.
-	 *
-	 * @return void
-	 */
-	public function up()
-	{
-		Schema::create('categories', function(Blueprint $table) {
-            $table->increments('id');
-
-            $table->timestamps();
-		});
-	}
-
-	/**
-	 * Reverse the migrations.
-	 *
-	 * @return void
-	 */
-	public function down()
-	{
-		Schema::drop('categories');
-	}
-
-}

+ 9 - 5
public/js/backend.js

@@ -14,7 +14,7 @@ $(function() {
     $("#category-form").bootstrapValidator({
         validatorDefaultParam,
         fields: {
-            title: {
+            name: {
                 validators: {
                     notEmpty: {
                         message: "分类名称不能为空"
@@ -24,9 +24,11 @@ $(function() {
         }
     });
 
-    $("#category-form #reset-btn").click(function(){
+    /*$("#category-form #reset-btn").click(function(){
         $('#category-form').data('bootstrapValidator').resetForm(true);
-    });
+        $('#category-form')[0].reset();
+    });*/
+    Moell.form.reset("#category-form", "#reset-btn");
 
     /* 文章操作验证 */
     $("#article-form").bootstrapValidator({
@@ -49,9 +51,11 @@ $(function() {
         }
     });
 
-    $("#article-form #reset-btn").click(function(){
+    /*$("#article-form #reset-btn").click(function(){
         $('#article-form').data('bootstrapValidator').resetForm(true);
-    });
+    });*/
+
+    Moell.form.reset("#article-form", "#reset-btn");
 
 
 });

+ 15 - 7
public/js/moell.js

@@ -4,25 +4,33 @@ var _token = $("meta[name='_token']").attr('content');
 
 (function(Moell) {
     Moell.ajax = {
-        delete : function (url) {
+        delete: function (url) {
 
-            layer.confirm('你确认删除吗?',{
+            layer.confirm('你确认删除吗?', {
                 btn: ['删除', '取消']
-            }, function() {
-                $.post(url, {'_method':"DELETE", '_token': _token}, function(data){
+            }, function () {
+                $.post(url, {'_method': "DELETE", '_token': _token}, function (data) {
                     var msg;
                     var icon;
                     if (data.status == 0) {
-                        layer.msg('删除成功', {time: 5000, icon:6});
+                        layer.msg('删除成功', {time: 5000, icon: 6});
                         window.location.href = window.location.href;
                     } else {
-                        layer.msg('删除失败', {time: 5000, icon:5});
+                        layer.msg('删除失败', {time: 5000, icon: 5});
                     }
                 });
 
-            }, function() {
+            }, function () {
                 layer.close();
             })
         }
+    },
+    Moell.form = {
+        reset: function (form, resetBtn) {
+            $(resetBtn).click(function () {
+                $(form).data('bootstrapValidator').resetForm(true);
+                $(form)[0].reset();
+            });
+        }
     }
 })(Moell);

+ 10 - 0
resources/views/backend/alert/warning.blade.php

@@ -0,0 +1,10 @@
+@if($errors->any())
+    <div class="alert alert-warning alert-dismissible">
+        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
+        <i class="icon fa fa-warning"></i>
+        错误提示!
+        @foreach($errors->all() as $error)
+            <p>{{ $error }}</p>
+        @endforeach
+    </div>
+@endif

+ 1 - 7
resources/views/backend/category/create.blade.php

@@ -10,14 +10,8 @@
 
 @section('content')
     <div class="row">
-        @if($errors->any())
-            <ul class="alert alert-danger">
-                @foreach($errors->all() as $error)
-                    <li>{{ $error }}</li>
-                @endforeach
-            </ul>
-        @endif
         <div class="col-xs-12">
+            @include('backend.alert.warning')
             <div class="box box-solid">
                 <form role="form" method="post" action="{{ url('backend/category') }}" id="category-form">
                     <div class="box-body">

+ 2 - 8
resources/views/backend/category/edit.blade.php

@@ -10,13 +10,7 @@
 
 @section('content')
     <div class="row">
-        @if($errors->any())
-            <ul class="alert alert-danger">
-                @foreach($errors->all() as $error)
-                    <li>{{ $error }}</li>
-                @endforeach
-            </ul>
-        @endif
+        @include('backend.alert.warning')
         <div class="col-xs-12">
             <div class="box box-solid">
                 <form role="form" method="post" action="{{ route('backend.category.update', ['id' => $category->id]) }}" id="category-form">
@@ -34,7 +28,7 @@
                             <div class="row">
                                 <div class='col-md-6'>
                                     @inject('categoryPresenter', 'App\Presenters\CategoryPresenter')
-                                    {!! $categoryPresenter->getSelect($category->id, '顶级分类') !!}
+                                    {!! $categoryPresenter->getSelect($category->parent_id, '顶级分类') !!}
                                 </div>
                             </div>
                         </div>