Skip to content

Commit

Permalink
Merge pull request #8 from ggvunh/develop
Browse files Browse the repository at this point in the history
login register
  • Loading branch information
Dev-Muscles authored Oct 11, 2017
2 parents b9c9230 + 68f9a0f commit 994dfb2
Show file tree
Hide file tree
Showing 22 changed files with 413 additions and 51 deletions.
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# see http://about.travis-ci.org/docs/user/languages/php/ for more hints
language: php

# list any PHP version you want to test against
php:
- 7.0
# optionally specify a list of environments, for example to test different RDBMS
services:
- mysql
# execute any number of scripts before the test run, custom env's are available as variables
before_script:
- mysql -e 'CREATE DATABASE forge;'
- composer self-update
- composer install --no-interaction
# omitting "script:" will default to phpunit
# use the $DB env variable to determine the phpunit.xml to use
script:
- php artisan migrate --force
- php artisan migrate:refresh --force
- php artisan db:seed --force
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct()
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',

'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
Expand All @@ -63,7 +63,7 @@ protected function validator(array $data)
protected function create(array $data)
{
return User::create([
'name' => $data['name'],

'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
Expand Down
37 changes: 37 additions & 0 deletions app/Http/Requests/LoginRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(){
return [
'name' => 'required',
'email' => 'required',
'password' => 'required'
];
public function messages(){
return [
'name.required' => 'xin nhap name',
'email.required' => 'Xin nhap email',
'password.required' => 'xin nhap mat khau'
];
}
}
4 changes: 2 additions & 2 deletions app/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class Order extends Model
{
protected $fillable=[
'user_id','order_date','total_price','order_address',
'order_phone','order_status','comfirmation'
'user_id', 'order_date', 'total_price', 'order_address',
'order_phone', 'order_status', 'comfirmation'
];

public function user() {
Expand Down
2 changes: 1 addition & 1 deletion app/OrderDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class OrderDetail extends Model
{
protected $fillable=['order_id','product_id','quality','unit_price'];
protected $fillable=['order_id', 'product_id', 'quality', 'unit_price'];

public function order() {
return $this->belongsTo('App\Order');
Expand Down
2 changes: 1 addition & 1 deletion app/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Photo extends Model
{
protected $fillable=['product_id','url'];
protected $fillable=['product_id', 'url'];

public function product() {
return $this->hasOne('App\Product');
Expand Down
4 changes: 2 additions & 2 deletions app/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class Product extends Model
{
protected $fillable=[
'name','category_id','description','unit_price',
'manufacturer_id','photo','quality_in_store','status','review'
'name', 'category_id', 'description', 'unit_price',
'manufacturer_id', 'quality_in_store', 'status', 'review'
];

public function category() {
Expand Down
2 changes: 1 addition & 1 deletion app/Specification.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Specification extends Model
{
protected $fillable=['product_id','key','value'];
protected $fillable=['product_id', 'key', 'value'];

public function product() {
return $this->belongsTo(App\Product);
Expand Down
2 changes: 1 addition & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password','role','address','phone','status'
'name', 'email', 'password', 'role', 'address', 'phone', 'status'
];

public function orders() {
Expand Down
4 changes: 2 additions & 2 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'strict' => false,
'engine' => null,
],

Expand Down
32 changes: 32 additions & 0 deletions database/migrations/2017_10_07_114428_create_categories_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
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->string('name');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateManufacturersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('manufacturers', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('manufacturers');
}
}
39 changes: 39 additions & 0 deletions database/migrations/2017_10_07_114748_create_orders_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('orders', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->nullable();
$table->date('order_date');
$table->float('total_price');
$table->string('order_address');
$table->string('order_phone');
$table->string('order_status');
$table->string('comfirmation');
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('orders');
}
}
42 changes: 42 additions & 0 deletions database/migrations/2017_10_07_114941_create_products_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->integer('category_id')->unsigned()->nullable();
$table->string('description');
$table->float('unit_price');
$table->integer('manufacturer_id')->unsigned()->nullable();
$table->integer('quality_in_store');
$table->string('status');
$table->string('review');
$table->foreign('category_id')->references('id')->on('categories');
$table->foreign('manufacturer_id')->references('id')->on('manufacturers');
$table->timestamps();

});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSpecificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('specifications', function (Blueprint $table) {
$table->increments('id');
$table->integer('product_id')->unsigned()->nullable();
$table->string('key');
$table->float('value');
$table->foreign('product_id')->references('id')->on('products');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('specifications');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrderDetailsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('order_details', function (Blueprint $table) {
$table->increments('id');
$table->integer('order_id')->unsigned()->nullable();
$table->integer('product_id')->unsigned()->nullable();
$table->integer('quality');
$table->float('unit_price');
$table->foreign('product_id')->references('id')->on('products');
$table->foreign('order_id')->references('id')->on('orders');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('order_details');
}
}
Loading

0 comments on commit 994dfb2

Please sign in to comment.