diff --git a/app/Http/routes.php b/app/Http/routes.php index 01bb506508de6401d535445e64ddd1cd4597017b..6ef66fb9250bd03d303f1d00a78100163fc4c19b 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -11,11 +11,6 @@ | */ -Route::get('/', function () { - return view('welcome'); -}); - - Route::group(['middleware' => 'web'], function () { Route::auth(); diff --git a/app/Permission.php b/app/Role.php similarity index 54% rename from app/Permission.php rename to app/Role.php index 9442dd1c1f7f8a7fdfe11d55a66ef27fa00fd9fb..666c5a0c075a6f29e486a57316a5eb002321d18d 100644 --- a/app/Permission.php +++ b/app/Role.php @@ -4,10 +4,10 @@ namespace App; use Illuminate\Database\Eloquent\Model; -class Permission extends Model +class Role extends Model { public function users() { - return $this->hasMany('App\User')->withTimestamps(); + return $this->hasMany('App\User', 'role_id'); } } diff --git a/app/Schedule.php b/app/Schedule.php new file mode 100644 index 0000000000000000000000000000000000000000..434ea30b635bef4039e03ff9651d249fbb0fb927 --- /dev/null +++ b/app/Schedule.php @@ -0,0 +1,18 @@ +<?php + +namespace App; + +use Illuminate\Database\Eloquent\Model; + +class Schedule extends Model +{ + public function users() + { + return $this->belongsTo('App\User'); + } + + public function tps() + { + return $this->belongsTo('App\Tps'); + } +} diff --git a/app/Tps.php b/app/Tps.php new file mode 100644 index 0000000000000000000000000000000000000000..6d8825e4d408ddd54d4b3d021095f74df69f2774 --- /dev/null +++ b/app/Tps.php @@ -0,0 +1,13 @@ +<?php + +namespace App; + +use Illuminate\Database\Eloquent\Model; + +class Tps extends Model +{ + public function schedule() + { + return $this->hasMany('App\Schedule', 'id_tps'); + } +} diff --git a/app/User.php b/app/User.php index 84be8ee027429f8ae47a0aee2cd285acf992e294..3fa6df92263a27f2d03bc9c5269f376d08251933 100644 --- a/app/User.php +++ b/app/User.php @@ -24,8 +24,13 @@ class User extends Authenticatable 'password', 'remember_token', ]; - public function permissions() + public function roles() { - return $this->belongsToMany('App\Permission')->withTimestamps(); + return $this->belongsTo('App\Role'); + } + + public function schedule() + { + return $this->hasMany('App\Schedule', 'id_user'); } } diff --git a/database/migrations/2016_03_31_095953_create_users_table.php b/database/migrations/2016_03_31_095953_create_users_table.php index fa960d652ed6344f8713bf697b1bf98ce44a273f..b31ed011ad62cc787ebbcc58afa52b106d997f33 100644 --- a/database/migrations/2016_03_31_095953_create_users_table.php +++ b/database/migrations/2016_03_31_095953_create_users_table.php @@ -18,6 +18,7 @@ class CreateUsersTable extends Migration $table->string('name'); $table->string('email')->unique(); $table->string('password'); + $table->integer('role_id')->unsigned(); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2016_03_31_092434_create_permissions_table.php b/database/migrations/2016_04_01_092434_create_roles_table.php similarity index 72% rename from database/migrations/2016_03_31_092434_create_permissions_table.php rename to database/migrations/2016_04_01_092434_create_roles_table.php index 84023a53e7f5d58d6fd9a251d456b95f337bafd5..0b22c92073ff9ad6868a133ea7452c82e31c4a09 100644 --- a/database/migrations/2016_03_31_092434_create_permissions_table.php +++ b/database/migrations/2016_04_01_092434_create_roles_table.php @@ -3,7 +3,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreatePermissionsTable extends Migration +class CreateRolesTable extends Migration { /** * Run the migrations. @@ -12,11 +12,10 @@ class CreatePermissionsTable extends Migration */ public function up() { - Schema::create('permissions', function(Blueprint $table) + Schema::create('roles', function(Blueprint $table) { $table->increments('id'); $table->string('name'); - $table->string('slug')->unique(); $table->text('description')->nullable(); $table->timestamps(); }); @@ -29,6 +28,6 @@ class CreatePermissionsTable extends Migration */ public function down() { - Schema::drop('permissions'); + Schema::drop('roles'); } } \ No newline at end of file diff --git a/database/migrations/2016_03_31_092544_create_permission_user_table.php b/database/migrations/2016_04_02_171120_create_tps_table.php similarity index 58% rename from database/migrations/2016_03_31_092544_create_permission_user_table.php rename to database/migrations/2016_04_02_171120_create_tps_table.php index 099f1c97cc052c80c0726252940a4cb17e686330..7306c9c4bafb06a68bbe74fec93bde950d7c24d7 100644 --- a/database/migrations/2016_03_31_092544_create_permission_user_table.php +++ b/database/migrations/2016_04_02_171120_create_tps_table.php @@ -3,7 +3,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreatePermissionUserTable extends Migration +class CreateTpsTable extends Migration { /** * Run the migrations. @@ -12,13 +12,14 @@ class CreatePermissionUserTable extends Migration */ public function up() { - Schema::create('permission_user', function(Blueprint $table) + Schema::create('tps', function(Blueprint $table) { $table->increments('id'); - $table->integer('permission_id'); - $table->integer('user_id'); + $table->integer('capacity_now'); + $table->integer('capacity_full'); + $table->integer('manager_id')->unsigned(); $table->timestamps(); - }); + }); } /** @@ -28,7 +29,6 @@ class CreatePermissionUserTable extends Migration */ public function down() { - Schema::drop('permission_user'); + Schema::drop('tps'); } - -} \ No newline at end of file +} diff --git a/database/migrations/2016_04_02_172129_create_schedule_table.php b/database/migrations/2016_04_02_172129_create_schedule_table.php new file mode 100644 index 0000000000000000000000000000000000000000..d45e5c13abbff3e5254c0716d9b61338878b87ee --- /dev/null +++ b/database/migrations/2016_04_02_172129_create_schedule_table.php @@ -0,0 +1,34 @@ +<?php + +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class CreateScheduleTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('schedule', function(Blueprint $table) + { + $table->increments('id'); + $table->integer('id_tps')->unsigned(); + $table->integer('id_user')->unsigned(); + $table->timestamp('time'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('schedule'); + } +}