Register
Login e register ok... list users ok redirects ok
This commit is contained in:
parent
30d6ec3322
commit
3e4ee18386
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Http\Resources\Department as DepartmentResource;
|
|
||||||
use App\Department;
|
|
||||||
|
|
||||||
class DepartmentControllerAPI extends Controller
|
|
||||||
{
|
|
||||||
//
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
return DepartmentResource::collection(Department::all());
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,8 +19,6 @@ class User extends Resource
|
|||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'email' => $this->email,
|
'email' => $this->email,
|
||||||
'age' => $this->age,
|
'age' => $this->age,
|
||||||
'department_id' => $this->department_id,
|
|
||||||
'department' => $this->department->name,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ class User extends Authenticatable
|
|||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'age',
|
'age',
|
||||||
'department_id',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,8 +30,4 @@ class User extends Authenticatable
|
|||||||
'password', 'remember_token',
|
'password', 'remember_token',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function department()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Department::class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,21 +12,14 @@ class InitialMigrations extends Migration
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{/*
|
{
|
||||||
Schema::create('departments', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->string('name')->unique();
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
Schema::create('users', function (Blueprint $table) {
|
Schema::create('users', function (Blueprint $table) {
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
//$table->integer('department_id')->unsigned();
|
|
||||||
//$table->foreign('department_id')->references('id')->on('departments');
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
Schema::create('password_resets', function (Blueprint $table) {
|
Schema::create('password_resets', function (Blueprint $table) {
|
||||||
|
@ -11,7 +11,6 @@ class DatabaseSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
//$this->call(DepartmentsTableSeeder::class);
|
|
||||||
$this->call(UsersTableSeeder::class);
|
$this->call(UsersTableSeeder::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,12 @@ class UsersTableSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$faker = Faker\Factory::create('pt_PT');
|
$faker = Faker\Factory::create('pt_PT');
|
||||||
|
|
||||||
//$departments = DB::table('departments')->pluck('id')->toArray();
|
|
||||||
for ($i = 0; $i < $this->numberOfUsers; ++$i) {
|
for ($i = 0; $i < $this->numberOfUsers; ++$i) {
|
||||||
DB::table('users')->insert($this->fakeUser($faker/*, $faker->randomElement($departments)*/));
|
DB::table('users')->insert($this->fakeUser($faker));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fakeUser(Faker\Generator $faker/*, $departmentId*/)
|
private function fakeUser(Faker\Generator $faker)
|
||||||
{
|
{
|
||||||
static $password;
|
static $password;
|
||||||
$createdAt = Carbon\Carbon::now()->subDays(30);
|
$createdAt = Carbon\Carbon::now()->subDays(30);
|
||||||
@ -30,7 +29,6 @@ class UsersTableSeeder extends Seeder
|
|||||||
'email' => $faker->unique()->safeEmail,
|
'email' => $faker->unique()->safeEmail,
|
||||||
'password' => $password ?: $password = bcrypt('secret'),
|
'password' => $password ?: $password = bcrypt('secret'),
|
||||||
'remember_token' => str_random(10),
|
'remember_token' => str_random(10),
|
||||||
//'department_id' => $departmentId,
|
|
||||||
'created_at' => $createdAt,
|
'created_at' => $createdAt,
|
||||||
'updated_at' => $updatedAt,
|
'updated_at' => $updatedAt,
|
||||||
];
|
];
|
||||||
|
62
laravel_server/public/js/vueapp.js
vendored
62
laravel_server/public/js/vueapp.js
vendored
@ -46165,8 +46165,6 @@ exports.push([module.i, "\ntr.activerow[data-v-0228aba0] {\n \t\tbackground: #1
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
// Component code (not registered)
|
// Component code (not registered)
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -46216,8 +46214,6 @@ var render = function() {
|
|||||||
_vm._v(" "),
|
_vm._v(" "),
|
||||||
_c("td", [_vm._v(_vm._s(user.age))]),
|
_c("td", [_vm._v(_vm._s(user.age))]),
|
||||||
_vm._v(" "),
|
_vm._v(" "),
|
||||||
_c("td", [_vm._v(_vm._s(user.department))]),
|
|
||||||
_vm._v(" "),
|
|
||||||
_c("td", [
|
_c("td", [
|
||||||
_c(
|
_c(
|
||||||
"a",
|
"a",
|
||||||
@ -46294,8 +46290,6 @@ var staticRenderFns = [
|
|||||||
_vm._v(" "),
|
_vm._v(" "),
|
||||||
_c("th", [_vm._v("Age")]),
|
_c("th", [_vm._v("Age")]),
|
||||||
_vm._v(" "),
|
_vm._v(" "),
|
||||||
_c("th", [_vm._v("Department")]),
|
|
||||||
_vm._v(" "),
|
|
||||||
_c("th", [_vm._v("Actions")])
|
_c("th", [_vm._v("Actions")])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
@ -46396,7 +46390,7 @@ exports = module.exports = __webpack_require__(2)(false);
|
|||||||
|
|
||||||
|
|
||||||
// module
|
// module
|
||||||
exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
|
exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
|
||||||
|
|
||||||
// exports
|
// exports
|
||||||
|
|
||||||
@ -46437,15 +46431,9 @@ exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
props: ['user', 'departments'],
|
props: ['user'],
|
||||||
methods: {
|
methods: {
|
||||||
saveUser: function saveUser() {
|
saveUser: function saveUser() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
@ -46574,48 +46562,6 @@ var render = function() {
|
|||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
_vm._v(" "),
|
_vm._v(" "),
|
||||||
_c("div", { staticClass: "form-group" }, [
|
|
||||||
_c("label", { attrs: { for: "department_id" } }, [_vm._v("Department:")]),
|
|
||||||
_vm._v(" "),
|
|
||||||
_c(
|
|
||||||
"select",
|
|
||||||
{
|
|
||||||
directives: [
|
|
||||||
{
|
|
||||||
name: "model",
|
|
||||||
rawName: "v-model",
|
|
||||||
value: _vm.user.department_id,
|
|
||||||
expression: "user.department_id"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
staticClass: "form-control",
|
|
||||||
attrs: { id: "department_id", name: "department_id" },
|
|
||||||
on: {
|
|
||||||
change: function($event) {
|
|
||||||
var $$selectedVal = Array.prototype.filter
|
|
||||||
.call($event.target.options, function(o) {
|
|
||||||
return o.selected
|
|
||||||
})
|
|
||||||
.map(function(o) {
|
|
||||||
var val = "_value" in o ? o._value : o.value
|
|
||||||
return val
|
|
||||||
})
|
|
||||||
_vm.$set(
|
|
||||||
_vm.user,
|
|
||||||
"department_id",
|
|
||||||
$event.target.multiple ? $$selectedVal : $$selectedVal[0]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_vm._l(_vm.departments, function(department) {
|
|
||||||
return _c("option", { domProps: { value: department.id } }, [
|
|
||||||
_vm._v(" " + _vm._s(department.name) + " ")
|
|
||||||
])
|
|
||||||
})
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
_vm._v(" "),
|
|
||||||
_c("div", { staticClass: "form-group" }, [
|
_c("div", { staticClass: "form-group" }, [
|
||||||
_c(
|
_c(
|
||||||
"a",
|
"a",
|
||||||
@ -47216,13 +47162,15 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
register: function register() {
|
register: function register() {
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
axios.post('/api/register', {
|
axios.post('/api/register', {
|
||||||
email: this.user.email,
|
email: this.user.email,
|
||||||
password: this.user.password,
|
password: this.user.password,
|
||||||
name: this.user.name
|
name: this.user.name
|
||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
//this.$router.push('/');
|
_this.$router.push('/');
|
||||||
}).catch(function (registerError) {
|
}).catch(function (registerError) {
|
||||||
// Something went wrong!
|
// Something went wrong!
|
||||||
//this.registerError = true;
|
//this.registerError = true;
|
||||||
|
@ -55,7 +55,7 @@ export default {
|
|||||||
name : this.user.name
|
name : this.user.name
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
//this.$router.push('/');
|
this.$router.push('/');
|
||||||
}).catch(registerError => {
|
}).catch(registerError => {
|
||||||
// Something went wrong!
|
// Something went wrong!
|
||||||
//this.registerError = true;
|
//this.registerError = true;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<label for="inputName">Name</label>
|
<label for="inputName">Name</label>
|
||||||
<input
|
<input
|
||||||
type="text" class="form-control" v-model="user.name"
|
type="text" class="form-control" v-model="user.name"
|
||||||
name="name" id="inputName"
|
name="name" id="inputName"
|
||||||
placeholder="Fullname"/>
|
placeholder="Fullname"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -22,12 +22,6 @@
|
|||||||
name="age" id="inputAge"
|
name="age" id="inputAge"
|
||||||
placeholder="Age"/>
|
placeholder="Age"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="department_id">Department:</label>
|
|
||||||
<select class="form-control" id="department_id" name="department_id" v-model="user.department_id" >
|
|
||||||
<option v-for="department in departments" v-bind:value="department.id"> {{ department.name }} </option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<a class="btn btn-default" v-on:click.prevent="saveUser()">Save</a>
|
<a class="btn btn-default" v-on:click.prevent="saveUser()">Save</a>
|
||||||
@ -38,7 +32,7 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
module.exports={
|
module.exports={
|
||||||
props: ['user', 'departments'],
|
props: ['user'],
|
||||||
methods: {
|
methods: {
|
||||||
saveUser: function(){
|
saveUser: function(){
|
||||||
axios.put('api/users/'+this.user.id, this.user)
|
axios.put('api/users/'+this.user.id, this.user)
|
||||||
@ -62,6 +56,6 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Age</th>
|
<th>Age</th>
|
||||||
<th>Department</th>
|
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -14,7 +13,6 @@
|
|||||||
<td>{{ user.name }}</td>
|
<td>{{ user.name }}</td>
|
||||||
<td>{{ user.email }}</td>
|
<td>{{ user.email }}</td>
|
||||||
<td>{{ user.age }}</td>
|
<td>{{ user.age }}</td>
|
||||||
<td>{{ user.department }}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<a class="btn btn-xs btn-success" v-on:click.prevent="definePlayer(user,1)">P1</a>
|
<a class="btn btn-xs btn-success" v-on:click.prevent="definePlayer(user,1)">P1</a>
|
||||||
<a class="btn btn-xs btn-success" v-on:click.prevent="definePlayer(user,2)">P2</a>
|
<a class="btn btn-xs btn-success" v-on:click.prevent="definePlayer(user,2)">P2</a>
|
||||||
@ -31,7 +29,7 @@
|
|||||||
module.exports={
|
module.exports={
|
||||||
props: ['users'],
|
props: ['users'],
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
editingUser: null
|
editingUser: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -39,7 +37,7 @@
|
|||||||
editUser: function(user){
|
editUser: function(user){
|
||||||
this.editingUser = user;
|
this.editingUser = user;
|
||||||
this.$emit('edit-click', user);
|
this.$emit('edit-click', user);
|
||||||
},
|
},
|
||||||
deleteUser: function(user){
|
deleteUser: function(user){
|
||||||
this.editingUser = null;
|
this.editingUser = null;
|
||||||
this.$emit('delete-click', user);
|
this.$emit('delete-click', user);
|
||||||
@ -48,7 +46,7 @@
|
|||||||
this.$root.$data['player'+player] = user;
|
this.$root.$data['player'+player] = user;
|
||||||
this.$emit('message', user.name+' selected as Player'+player);
|
this.$emit('message', user.name+' selected as Player'+player);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -58,4 +56,4 @@
|
|||||||
color: #fff !important;
|
color: #fff !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user