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,
|
||||
'email' => $this->email,
|
||||
'age' => $this->age,
|
||||
'department_id' => $this->department_id,
|
||||
'department' => $this->department->name,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ class User extends Authenticatable
|
||||
'name',
|
||||
'email',
|
||||
'age',
|
||||
'department_id',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -31,8 +30,4 @@ class User extends Authenticatable
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
public function department()
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
}
|
||||
|
@ -12,21 +12,14 @@ class InitialMigrations extends Migration
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{/*
|
||||
Schema::create('departments', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
*/
|
||||
{
|
||||
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
//$table->integer('department_id')->unsigned();
|
||||
//$table->foreign('department_id')->references('id')->on('departments');
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
|
@ -11,7 +11,6 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//$this->call(DepartmentsTableSeeder::class);
|
||||
$this->call(UsersTableSeeder::class);
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,12 @@ class UsersTableSeeder extends Seeder
|
||||
{
|
||||
$faker = Faker\Factory::create('pt_PT');
|
||||
|
||||
//$departments = DB::table('departments')->pluck('id')->toArray();
|
||||
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;
|
||||
$createdAt = Carbon\Carbon::now()->subDays(30);
|
||||
@ -30,7 +29,6 @@ class UsersTableSeeder extends Seeder
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'password' => $password ?: $password = bcrypt('secret'),
|
||||
'remember_token' => str_random(10),
|
||||
//'department_id' => $departmentId,
|
||||
'created_at' => $createdAt,
|
||||
'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)
|
||||
module.exports = {
|
||||
@ -46216,8 +46214,6 @@ var render = function() {
|
||||
_vm._v(" "),
|
||||
_c("td", [_vm._v(_vm._s(user.age))]),
|
||||
_vm._v(" "),
|
||||
_c("td", [_vm._v(_vm._s(user.department))]),
|
||||
_vm._v(" "),
|
||||
_c("td", [
|
||||
_c(
|
||||
"a",
|
||||
@ -46294,8 +46290,6 @@ var staticRenderFns = [
|
||||
_vm._v(" "),
|
||||
_c("th", [_vm._v("Age")]),
|
||||
_vm._v(" "),
|
||||
_c("th", [_vm._v("Department")]),
|
||||
_vm._v(" "),
|
||||
_c("th", [_vm._v("Actions")])
|
||||
])
|
||||
])
|
||||
@ -46396,7 +46390,7 @@ exports = module.exports = __webpack_require__(2)(false);
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
@ -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 = {
|
||||
props: ['user', 'departments'],
|
||||
props: ['user'],
|
||||
methods: {
|
||||
saveUser: function saveUser() {
|
||||
var _this = this;
|
||||
@ -46574,48 +46562,6 @@ var render = function() {
|
||||
})
|
||||
]),
|
||||
_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(
|
||||
"a",
|
||||
@ -47216,13 +47162,15 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
|
||||
methods: {
|
||||
register: function register() {
|
||||
var _this = this;
|
||||
|
||||
axios.post('/api/register', {
|
||||
email: this.user.email,
|
||||
password: this.user.password,
|
||||
name: this.user.name
|
||||
}).then(function (response) {
|
||||
console.log(response);
|
||||
//this.$router.push('/');
|
||||
_this.$router.push('/');
|
||||
}).catch(function (registerError) {
|
||||
// Something went wrong!
|
||||
//this.registerError = true;
|
||||
|
@ -55,7 +55,7 @@ export default {
|
||||
name : this.user.name
|
||||
}).then(response => {
|
||||
console.log(response);
|
||||
//this.$router.push('/');
|
||||
this.$router.push('/');
|
||||
}).catch(registerError => {
|
||||
// Something went wrong!
|
||||
//this.registerError = true;
|
||||
|
@ -5,7 +5,7 @@
|
||||
<label for="inputName">Name</label>
|
||||
<input
|
||||
type="text" class="form-control" v-model="user.name"
|
||||
name="name" id="inputName"
|
||||
name="name" id="inputName"
|
||||
placeholder="Fullname"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -22,12 +22,6 @@
|
||||
name="age" id="inputAge"
|
||||
placeholder="Age"/>
|
||||
</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">
|
||||
<a class="btn btn-default" v-on:click.prevent="saveUser()">Save</a>
|
||||
@ -38,7 +32,7 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
module.exports={
|
||||
props: ['user', 'departments'],
|
||||
props: ['user'],
|
||||
methods: {
|
||||
saveUser: function(){
|
||||
axios.put('api/users/'+this.user.id, this.user)
|
||||
@ -62,6 +56,6 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
@ -5,7 +5,6 @@
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Age</th>
|
||||
<th>Department</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -14,7 +13,6 @@
|
||||
<td>{{ user.name }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>{{ user.age }}</td>
|
||||
<td>{{ user.department }}</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,2)">P2</a>
|
||||
@ -31,7 +29,7 @@
|
||||
module.exports={
|
||||
props: ['users'],
|
||||
data: function(){
|
||||
return {
|
||||
return {
|
||||
editingUser: null
|
||||
}
|
||||
},
|
||||
@ -39,7 +37,7 @@
|
||||
editUser: function(user){
|
||||
this.editingUser = user;
|
||||
this.$emit('edit-click', user);
|
||||
},
|
||||
},
|
||||
deleteUser: function(user){
|
||||
this.editingUser = null;
|
||||
this.$emit('delete-click', user);
|
||||
@ -48,7 +46,7 @@
|
||||
this.$root.$data['player'+player] = user;
|
||||
this.$emit('message', user.name+' selected as Player'+player);
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -58,4 +56,4 @@
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
Loading…
x
Reference in New Issue
Block a user