laravel用json格式提交数据,验证层怎么写
展开全部
1 安装好最基本的laravel框架
2 创建migration文件:
./artisan migrate:make create-badmin-table
3 发现app/database/migration/下面多了一个php文件:
2014_10_19_090336_create-badmin-table.php
4 往up和down里面增加内容;
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBadminTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('badmin', function($table)
{
$table->increments('id');
$table->string('nickname', 100)->unique();
$table->string('username', 100)->unique();
$table->string('email', 100)->unique();
$table->string('password', 64);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('badmin');
}
}
5 配置好local的database,app/config/local/database.php
<?php
return array(
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => ’test',
'username' => 'yejianfeng',
'password' => '123456',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),
'migrations' => 'migrations',
);
2 创建migration文件:
./artisan migrate:make create-badmin-table
3 发现app/database/migration/下面多了一个php文件:
2014_10_19_090336_create-badmin-table.php
4 往up和down里面增加内容;
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBadminTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('badmin', function($table)
{
$table->increments('id');
$table->string('nickname', 100)->unique();
$table->string('username', 100)->unique();
$table->string('email', 100)->unique();
$table->string('password', 64);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('badmin');
}
}
5 配置好local的database,app/config/local/database.php
<?php
return array(
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => ’test',
'username' => 'yejianfeng',
'password' => '123456',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),
'migrations' => 'migrations',
);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询