new Project new things
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Department extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function users()
|
||||||
|
{
|
||||||
|
return $this->hasMany(User::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,12 +32,6 @@ class LoginController extends Controller
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
return View('auth.login');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->middleware('guest')->except('logout');
|
$this->middleware('guest')->except('logout');
|
||||||
|
|
|
@ -68,11 +68,4 @@ class RegisterController extends Controller
|
||||||
'password' => bcrypt($data['password']),
|
'password' => bcrypt($data['password']),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
return View('auth.register');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
define('YOUR_SERVER_URL', 'http://projeto.dev/');
|
|
||||||
define('CLIENT_ID', '2');
|
|
||||||
define('CLIENT_SECRET','kRWo05fZm5NC9zVRJlmd9IOwqUfQGJwf8QjuPWA3');
|
|
||||||
|
|
||||||
class LoginControllerAPI extends Controller
|
|
||||||
{
|
|
||||||
public function login(Request $request)
|
|
||||||
{
|
|
||||||
$http = new \GuzzleHttp\Client;
|
|
||||||
$response = $http->post(YOUR_SERVER_URL.'/oauth/token', [
|
|
||||||
'form_params' => [
|
|
||||||
'grant_type' => 'password',
|
|
||||||
'client_id' => CLIENT_ID,
|
|
||||||
'client_secret' => CLIENT_SECRET,
|
|
||||||
'username' => $request->email,
|
|
||||||
'password' => $request->password,
|
|
||||||
'scope' => ''], 'exceptions' => false,]);
|
|
||||||
$errorCode= $response->getStatusCode();
|
|
||||||
if ($errorCode=='200') {
|
|
||||||
return json_decode((string) $response->getBody(), true);
|
|
||||||
} else {
|
|
||||||
return response()->json(['msg'=>'User credentials are invalid'], $errorCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function logout()
|
|
||||||
{
|
|
||||||
|
|
||||||
\Auth::guard('api')->user()->token()->revoke();
|
|
||||||
\Auth::guard('api')->user()->token()->delete();
|
|
||||||
|
|
||||||
return response()->json(['msg'=>'Token revoked'], 200);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Contracts\Support\Jsonable;
|
||||||
|
|
||||||
|
use App\Http\Resources\User as UserResource;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
use App\StoreUserRequest;
|
||||||
|
use Hash;
|
||||||
|
|
||||||
|
class UserControllerAPI extends Controller
|
||||||
|
{
|
||||||
|
public function getUsers(Request $request)
|
||||||
|
{
|
||||||
|
if ($request->has('page')) {
|
||||||
|
return UserResource::collection(User::paginate(5));
|
||||||
|
} else {
|
||||||
|
return UserResource::collection(User::all());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUser($id)
|
||||||
|
{
|
||||||
|
return new UserResource(User::find($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required',
|
||||||
|
'email' => 'required|email|unique:users,email',
|
||||||
|
'age' => 'integer|between:18,75',
|
||||||
|
'password' => 'min:3'
|
||||||
|
]);
|
||||||
|
$user = new User();
|
||||||
|
$user->fill($request->all());
|
||||||
|
$user->password = Hash::make($user->password);
|
||||||
|
$user->save();
|
||||||
|
return response()->json(new UserResource($user), 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required',
|
||||||
|
'email' => 'required|email|unique:users,email,'.$id,
|
||||||
|
'age' => 'integer|between:18,75'
|
||||||
|
]);
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
$user->update($request->all());
|
||||||
|
return new UserResource($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
$user->delete();
|
||||||
|
return response()->json(null, 204);
|
||||||
|
}
|
||||||
|
public function emailAvailable(Request $request)
|
||||||
|
{
|
||||||
|
$totalEmail = 1;
|
||||||
|
if ($request->has('email') && $request->has('id')) {
|
||||||
|
$totalEmail = DB::table('users')->where('email', '=', $request->email)->where('id', '<>', $request->id)->count();
|
||||||
|
} else if ($request->has('email')) {
|
||||||
|
$totalEmail = DB::table('users')->where('email', '=', $request->email)->count();
|
||||||
|
}
|
||||||
|
return response()->json($totalEmail == 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
class VueController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('vue.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function userProfile()
|
||||||
|
{
|
||||||
|
return view('vue.user.profile');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreDepartmentRequest 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|regex:/^[a-zA-Z ]+$/',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreUserRequest 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|regex:/^[a-zA-Z ]+$/',
|
||||||
|
'email' => 'required|email|unique:users',
|
||||||
|
'password' => 'required|min:8|confirmed',
|
||||||
|
'age' => 'required|integer|min:18|max:75',
|
||||||
|
'department_id' => 'required|integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateDepartmentRequest 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|regex:/^[a-zA-Z ]+$/',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateUserRequest 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|string|max:255',
|
||||||
|
'email' => 'required|email|unique:users,email,'.$this->user->id,
|
||||||
|
'password' => 'nullable|string|min:6|confirmed',
|
||||||
|
'age' => 'required|integer|min:18|max:75',
|
||||||
|
'department_id' => 'required|integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\Resource;
|
||||||
|
|
||||||
|
class User extends Resource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'email' => $this->email,
|
||||||
|
'age' => $this->age,
|
||||||
|
'nickname' => $this->nickname,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Laravel\Passport\Passport;
|
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
|
@ -25,7 +24,6 @@ class AuthServiceProvider extends ServiceProvider
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->registerPolicies();
|
$this->registerPolicies();
|
||||||
Passport::routes();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Laravel\Passport\HasApiTokens;
|
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
use HasApiTokens, Notifiable;
|
use Notifiable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
|
@ -16,7 +15,11 @@ class User extends Authenticatable
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name', 'email', 'password',
|
'name',
|
||||||
|
'email',
|
||||||
|
'age',
|
||||||
|
'nickname',
|
||||||
|
'blocked'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +28,8 @@ class User extends Authenticatable
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'password', 'remember_token',
|
'password', 'remember_token', 'admin'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,12 @@
|
||||||
"php": ">=7.0.0",
|
"php": ">=7.0.0",
|
||||||
"fideloper/proxy": "~3.3",
|
"fideloper/proxy": "~3.3",
|
||||||
"laravel/framework": "5.5.*",
|
"laravel/framework": "5.5.*",
|
||||||
"laravel/passport": "^4.0",
|
|
||||||
"laravel/tinker": "~1.0"
|
"laravel/tinker": "~1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"filp/whoops": "~2.0",
|
"filp/whoops": "~2.0",
|
||||||
"fzaninotto/faker": "~1.4",
|
"fzaninotto/faker": "~1.4",
|
||||||
"mockery/mockery": "~1.0",
|
"mockery/mockery": "0.9.*",
|
||||||
"phpunit/phpunit": "~6.0"
|
"phpunit/phpunit": "~6.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
|
@ -42,7 +42,7 @@ return [
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
'driver' => 'passport',
|
'driver' => 'token',
|
||||||
'provider' => 'users',
|
'provider' => 'users',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
|
@ -86,9 +86,6 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'prefix' => env(
|
'prefix' => 'laravel',
|
||||||
'CACHE_PREFIX',
|
|
||||||
str_slug(env('APP_NAME', 'laravel'), '_').'_cache'
|
|
||||||
),
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -57,9 +57,9 @@ return [
|
||||||
|
|
||||||
's3' => [
|
's3' => [
|
||||||
'driver' => 's3',
|
'driver' => 's3',
|
||||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
'key' => env('AWS_KEY'),
|
||||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
'secret' => env('AWS_SECRET'),
|
||||||
'region' => env('AWS_DEFAULT_REGION'),
|
'region' => env('AWS_REGION'),
|
||||||
'bucket' => env('AWS_BUCKET'),
|
'bucket' => env('AWS_BUCKET'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
'lifetime' => 120,
|
||||||
|
|
||||||
'expire_on_close' => false,
|
'expire_on_close' => false,
|
||||||
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
|
|
||||||
class CreatePasswordResetsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('password_resets', function (Blueprint $table) {
|
|
||||||
$table->string('email')->index();
|
|
||||||
$table->string('token');
|
|
||||||
$table->timestamp('created_at')->nullable();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('password_resets');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
class CreateUsersTable extends Migration
|
class InitialMigrations extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
|
@ -17,12 +17,22 @@ class CreateUsersTable extends Migration
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
|
$table->string('nickname');
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
|
$table->integer('age');
|
||||||
|
$table->integer('admin');
|
||||||
|
$table->integer('blocked');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
Schema::create('password_resets', function (Blueprint $table) {
|
||||||
|
$table->string('email')->index();
|
||||||
|
$table->string('token');
|
||||||
|
$table->timestamp('created_at')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse the migrations.
|
* Reverse the migrations.
|
||||||
*
|
*
|
||||||
|
@ -30,6 +40,7 @@ class CreateUsersTable extends Migration
|
||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
|
Schema::dropIfExists('password_resets');
|
||||||
Schema::dropIfExists('users');
|
Schema::dropIfExists('users');
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DepartmentsTableSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$departments = [
|
||||||
|
'Ciências Jurídicas',
|
||||||
|
'Ciências da Linguagem',
|
||||||
|
'Engenharia do Ambiente',
|
||||||
|
'Engenharia Civil',
|
||||||
|
'Engenharia Eletrotécnica',
|
||||||
|
'Engenharia Informática',
|
||||||
|
'Engenharia Mecânica',
|
||||||
|
'Gestão e Economia',
|
||||||
|
'Matemática'
|
||||||
|
];
|
||||||
|
$createdAt = Carbon\Carbon::now()->subMonths(2);
|
||||||
|
foreach ($departments as $department) {
|
||||||
|
DB::table('departments')->insert([
|
||||||
|
'name' => $department,
|
||||||
|
'created_at' => $createdAt,
|
||||||
|
'updated_at' => $createdAt,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class UsersTableSeeder extends Seeder
|
class UsersTableSeeder extends Seeder
|
||||||
{
|
{
|
||||||
|
private $numberOfUsers = 30;
|
||||||
/**
|
/**
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
*
|
*
|
||||||
|
@ -11,7 +12,28 @@ class UsersTableSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
//
|
$faker = Faker\Factory::create('pt_PT');
|
||||||
factory(App\User::class, 50)->create();
|
for ($i = 0; $i < $this->numberOfUsers; ++$i) {
|
||||||
|
DB::table('users')->insert($this->fakeUser($faker));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fakeUser(Faker\Generator $faker)
|
||||||
|
{
|
||||||
|
static $password;
|
||||||
|
$createdAt = Carbon\Carbon::now()->subDays(30);
|
||||||
|
$updatedAt = $faker->dateTimeBetween($createdAt);
|
||||||
|
return [
|
||||||
|
'name' => $faker->name,
|
||||||
|
'email' => $faker->unique()->safeEmail,
|
||||||
|
'nickname' => $faker->unique()->name,
|
||||||
|
'password' => $password ?: $password = bcrypt('secret'),
|
||||||
|
'remember_token' => str_random(10),
|
||||||
|
'age' => $faker->numberBetween(18, 75),
|
||||||
|
'admin' => 0,
|
||||||
|
'blocked' => 0,
|
||||||
|
'created_at' => $createdAt,
|
||||||
|
'updated_at' => $updatedAt,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,20 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm run development",
|
"dev": "npm run development",
|
||||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
"development": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
"watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
"watch-poll": "npm run watch -- --watch-poll",
|
"watch-poll": "npm run watch -- --watch-poll",
|
||||||
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
"hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
"prod": "npm run production",
|
"prod": "npm run production",
|
||||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
"production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"axios": "^0.17",
|
"axios": "^0.16.2",
|
||||||
"bootstrap-sass": "^3.3.7",
|
"bootstrap-sass": "^3.3.7",
|
||||||
"cross-env": "^5.1",
|
"cross-env": "^5.0.1",
|
||||||
"jquery": "^3.2",
|
"jquery": "^3.1.1",
|
||||||
"laravel-mix": "^1.0",
|
"laravel-mix": "^1.0",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"vue": "^2.5.7"
|
"vue": "^2.1.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "npm run development",
|
||||||
|
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"watch-poll": "npm run watch -- --watch-poll",
|
||||||
|
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"prod": "npm run production",
|
||||||
|
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"axios": "^0.16.2",
|
||||||
|
"bootstrap-sass": "^3.3.7",
|
||||||
|
"cross-env": "^5.0.1",
|
||||||
|
"jquery": "^3.1.1",
|
||||||
|
"laravel-mix": "^1.0",
|
||||||
|
"lodash": "^4.17.4",
|
||||||
|
"vue": "^2.1.10"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "npm run development",
|
||||||
|
"development": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"watch-poll": "npm run watch -- --watch-poll",
|
||||||
|
"hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||||
|
"prod": "npm run production",
|
||||||
|
"production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"axios": "^0.16.2",
|
||||||
|
"bootstrap-sass": "^3.3.7",
|
||||||
|
"cross-env": "^5.0.1",
|
||||||
|
"jquery": "^3.1.1",
|
||||||
|
"laravel-mix": "^1.0",
|
||||||
|
"lodash": "^4.17.4",
|
||||||
|
"vue": "^2.1.10"
|
||||||
|
}
|
||||||
|
}
|
|
@ -8350,3 +8350,34 @@ button.close {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.close-btn {
|
||||||
|
border: none;
|
||||||
|
float: right;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.board {
|
||||||
|
max-width: 276px;
|
||||||
|
margin: 0 auto;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 0px 0 0 0px;
|
||||||
|
border-color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.board div {
|
||||||
|
display: inline-block;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 2px 2px 2px 2px;
|
||||||
|
border-color: black;
|
||||||
|
margin-left: -2px;
|
||||||
|
margin-top: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.board img {
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
margin: 5px;
|
||||||
|
padding: 0;
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,9 @@
|
||||||
html {
|
@charset "utf-8";
|
||||||
background: url("/img/background.png");
|
/* Custom rules */
|
||||||
|
.inline {
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
.error {
|
||||||
|
color: red;
|
||||||
color: white;
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#divLobby {
|
|
||||||
|
|
||||||
background: url("/img/background.png");
|
|
||||||
border:5px solid green;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#divTab {
|
|
||||||
|
|
||||||
border:5px solid black;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
}
|
|
0
laravel/public/fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.eot
vendored
Executable file → Normal file
0
laravel/public/fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.svg
vendored
Executable file → Normal file
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
0
laravel/public/fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.ttf
vendored
Executable file → Normal file
0
laravel/public/fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.woff
vendored
Executable file → Normal file
0
laravel/public/fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.woff2
vendored
Executable file → Normal file
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 691 B |
|
@ -0,0 +1,76 @@
|
||||||
|
/******/ (function(modules) { // webpackBootstrap
|
||||||
|
/******/ // The module cache
|
||||||
|
/******/ var installedModules = {};
|
||||||
|
/******/
|
||||||
|
/******/ // The require function
|
||||||
|
/******/ function __webpack_require__(moduleId) {
|
||||||
|
/******/
|
||||||
|
/******/ // Check if module is in cache
|
||||||
|
/******/ if(installedModules[moduleId]) {
|
||||||
|
/******/ return installedModules[moduleId].exports;
|
||||||
|
/******/ }
|
||||||
|
/******/ // Create a new module (and put it into the cache)
|
||||||
|
/******/ var module = installedModules[moduleId] = {
|
||||||
|
/******/ i: moduleId,
|
||||||
|
/******/ l: false,
|
||||||
|
/******/ exports: {}
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // Execute the module function
|
||||||
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||||
|
/******/
|
||||||
|
/******/ // Flag the module as loaded
|
||||||
|
/******/ module.l = true;
|
||||||
|
/******/
|
||||||
|
/******/ // Return the exports of the module
|
||||||
|
/******/ return module.exports;
|
||||||
|
/******/ }
|
||||||
|
/******/
|
||||||
|
/******/
|
||||||
|
/******/ // expose the modules object (__webpack_modules__)
|
||||||
|
/******/ __webpack_require__.m = modules;
|
||||||
|
/******/
|
||||||
|
/******/ // expose the module cache
|
||||||
|
/******/ __webpack_require__.c = installedModules;
|
||||||
|
/******/
|
||||||
|
/******/ // define getter function for harmony exports
|
||||||
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||||
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||||
|
/******/ Object.defineProperty(exports, name, {
|
||||||
|
/******/ configurable: false,
|
||||||
|
/******/ enumerable: true,
|
||||||
|
/******/ get: getter
|
||||||
|
/******/ });
|
||||||
|
/******/ }
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||||
|
/******/ __webpack_require__.n = function(module) {
|
||||||
|
/******/ var getter = module && module.__esModule ?
|
||||||
|
/******/ function getDefault() { return module['default']; } :
|
||||||
|
/******/ function getModuleExports() { return module; };
|
||||||
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||||
|
/******/ return getter;
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // Object.prototype.hasOwnProperty.call
|
||||||
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||||
|
/******/
|
||||||
|
/******/ // __webpack_public_path__
|
||||||
|
/******/ __webpack_require__.p = "";
|
||||||
|
/******/
|
||||||
|
/******/ // Load entry module and return exports
|
||||||
|
/******/ return __webpack_require__(__webpack_require__.s = 53);
|
||||||
|
/******/ })
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ ({
|
||||||
|
|
||||||
|
/***/ 53:
|
||||||
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
(function webpackMissingModule() { throw new Error("Cannot find module \"/home/vagrant/memoryGame/resources/assets/js/tictactoe.js\""); }());
|
||||||
|
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
/******/ });
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"/js/app.js": "/js/app.js",
|
"/js/vueapp.js": "/js/vueapp.js",
|
||||||
"/css/app.css": "/css/app.css"
|
"/js/tictactoe.js": "/js/tictactoe.js"
|
||||||
}
|
}
|
|
@ -19,31 +19,26 @@ Laravel is a web application framework with expressive, elegant syntax. We belie
|
||||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||||
|
|
||||||
Laravel is accessible, yet powerful, providing tools needed for large, robust applications.
|
Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation give you tools you need to build any application with which you are tasked.
|
||||||
|
|
||||||
## Learning Laravel
|
## Learning Laravel
|
||||||
|
|
||||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of any modern web application framework, making it a breeze to get started learning the framework.
|
Laravel has the most extensive and thorough documentation and video tutorial library of any modern web application framework. The [Laravel documentation](https://laravel.com/docs) is thorough, complete, and makes it a breeze to get started learning the framework.
|
||||||
|
|
||||||
If you're not in the mood to read, [Laracasts](https://laracasts.com) contains over 1100 video tutorials on a range of topics including Laravel, modern PHP, unit testing, JavaScript, and more. Boost the skill level of yourself and your entire team by digging into our comprehensive video library.
|
If you're not in the mood to read, [Laracasts](https://laracasts.com) contains over 900 video tutorials on a range of topics including Laravel, modern PHP, unit testing, JavaScript, and more. Boost the skill level of yourself and your entire team by digging into our comprehensive video library.
|
||||||
|
|
||||||
## Laravel Sponsors
|
## Laravel Sponsors
|
||||||
|
|
||||||
We would like to extend our thanks to the following sponsors for helping fund on-going Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](http://patreon.com/taylorotwell):
|
We would like to extend our thanks to the following sponsors for helping fund on-going Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](http://patreon.com/taylorotwell):
|
||||||
|
|
||||||
- **[Vehikl](https://vehikl.com/)**
|
- **[Vehikl](http://vehikl.com)**
|
||||||
- **[Tighten Co.](https://tighten.co)**
|
- **[Tighten Co.](https://tighten.co)**
|
||||||
- **[British Software Development](https://www.britishsoftware.co)**
|
- **[British Software Development](https://www.britishsoftware.co)**
|
||||||
|
- **[Styde](https://styde.net)**
|
||||||
- [Fragrantica](https://www.fragrantica.com)
|
- [Fragrantica](https://www.fragrantica.com)
|
||||||
- [SOFTonSOFA](https://softonsofa.com/)
|
- [SOFTonSOFA](https://softonsofa.com/)
|
||||||
- [User10](https://user10.com)
|
- [User10](https://user10.com)
|
||||||
- [Soumettre.fr](https://soumettre.fr/)
|
- [Soumettre.fr](https://soumettre.fr/)
|
||||||
- [CodeBrisk](https://codebrisk.com)
|
|
||||||
- [1Forge](https://1forge.com)
|
|
||||||
- [TECPRESSO](https://tecpresso.co.jp/)
|
|
||||||
- [Pulse Storm](http://www.pulsestorm.net/)
|
|
||||||
- [Runtime Converter](http://runtimeconverter.com/)
|
|
||||||
- [WebL'Agence](https://weblagence.com/)
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
@ -51,7 +46,7 @@ Thank you for considering contributing to the Laravel framework! The contributio
|
||||||
|
|
||||||
## Security Vulnerabilities
|
## Security Vulnerabilities
|
||||||
|
|
||||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
|
|
||||||
/**
|
|
||||||
* First we will load all of this project's JavaScript dependencies which
|
|
||||||
* includes Vue and other libraries. It is a great starting point when
|
|
||||||
* building robust, powerful web applications using Vue and Laravel.
|
|
||||||
*/
|
|
||||||
|
|
||||||
require('./bootstrap');
|
|
||||||
|
|
||||||
window.Vue = require('vue');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Next, we will create a fresh Vue application instance and attach it to
|
|
||||||
* the page. Then, you may begin adding components to this application
|
|
||||||
* or customize the JavaScript scaffolding to fit your unique needs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Vue.component('example', require('./components/Example.vue'));
|
|
||||||
|
|
||||||
const app = new Vue({
|
|
||||||
el: '#app'
|
|
||||||
});
|
|
|
@ -29,13 +29,13 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||||
* a simple convenience so we don't have to attach every token manually.
|
* a simple convenience so we don't have to attach every token manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let token = document.head.querySelector('meta[name="csrf-token"]');
|
// let token = document.head.querySelector('meta[name="csrf-token"]');
|
||||||
|
|
||||||
if (token) {
|
// if (token) {
|
||||||
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
// window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
||||||
} else {
|
// } else {
|
||||||
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
|
// console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Echo exposes an expressive API for subscribing to channels and listening
|
* Echo exposes an expressive API for subscribing to channels and listening
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8 col-md-offset-2">
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">Example Component</div>
|
|
||||||
|
|
||||||
<div class="panel-body">
|
|
||||||
I'm an example component!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
mounted() {
|
|
||||||
console.log('Component mounted.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-center">{{ title }}</h3>
|
||||||
|
</div> <!--<br>
|
||||||
|
<h2>Current Player : {{ currentPlayer }}</h2>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div class="game-zone-content">
|
||||||
|
<div class="alert alert-success" v-if="showSuccess">
|
||||||
|
<button type="button" class="close-btn" v-on:click="showSuccess=false">×</button>
|
||||||
|
<strong>{{ successMessage }} <a v-show="gameEnded" v-on:click.prevent="restartGame">Restart</a></strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="board">
|
||||||
|
<div v-for="(piece, key) of board" >
|
||||||
|
<img v-bind:src="pieceImageURL(piece)" v-on:click="clickPiece(key)">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</template type="text/javascript">
|
||||||
|
|
||||||
|
|
||||||
|
data: function(){
|
||||||
|
return {
|
||||||
|
title: 'Memory Game',
|
||||||
|
showSuccess: false,
|
||||||
|
showFailure: false,
|
||||||
|
successMessage: '',
|
||||||
|
failMessage: '',
|
||||||
|
currentValue: 1,
|
||||||
|
gameEnded:false,
|
||||||
|
player1User: undefined,
|
||||||
|
player2User: undefined,
|
||||||
|
board: [0,0,0,0,0,0,0,0,0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
|
@ -0,0 +1,81 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="jumbotron">
|
||||||
|
<h1>{{ title }}</h1>
|
||||||
|
</div>
|
||||||
|
<user-list :users="users" @edit-click="editUser" @delete-click="deleteUser" @message="childMessage" ref="usersListRef"></user-list>
|
||||||
|
|
||||||
|
<div class="alert alert-success" v-if="showSuccess">
|
||||||
|
|
||||||
|
<button type="button" class="close-btn" v-on:click="showSuccess=false">×</button>
|
||||||
|
<strong>{{ successMessage }}</strong>
|
||||||
|
</div>
|
||||||
|
<user-edit :user="currentUser" @user-saved="savedUser" @user-canceled="cancelEdit" v-if="currentUser"></user-edit>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
import UserList from './userList.vue';
|
||||||
|
import UserEdit from './userEdit.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data: {
|
||||||
|
title: 'User Profile',
|
||||||
|
editingUser: false,
|
||||||
|
showSuccess: false,
|
||||||
|
showFailure: false,
|
||||||
|
successMessage: '',
|
||||||
|
failMessage: '',
|
||||||
|
currentUser: null,
|
||||||
|
user: null
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
editUser: function(user){
|
||||||
|
this.currentUser = user;
|
||||||
|
this.editingUser = true;
|
||||||
|
this.showSuccess = false;
|
||||||
|
},
|
||||||
|
saveUser: function(){
|
||||||
|
this.editingUser = false; // desaparece na vista esta secção
|
||||||
|
axios.put('api/users/'+this.currentUser.username,this.currentUser)
|
||||||
|
.then(response=>{
|
||||||
|
this.showSuccess = true;
|
||||||
|
this.successMessage = 'Your details have been saved';
|
||||||
|
// Copies response.data.data properties to this.currentUser
|
||||||
|
// without changing this.currentUser reference
|
||||||
|
Object.assign(this.currentUser, response.data.data);
|
||||||
|
this.currentUser = null;
|
||||||
|
this.editingUser = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
cancelEdit: function(){
|
||||||
|
this.showSuccess = false;
|
||||||
|
this.editingUser = false;
|
||||||
|
axios.get('api/users/'+this.currentUser.username)
|
||||||
|
.then(response=>{
|
||||||
|
console.dir (this.currentUser);
|
||||||
|
// Copies response.data.data properties to this.currentUser
|
||||||
|
// without changing this.currentUser reference
|
||||||
|
Object.assign(this.currentUser, response.data.data);
|
||||||
|
console.dir (this.currentUser);
|
||||||
|
this.currentUser = null;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getLoginUser: function() {
|
||||||
|
axios.get('api/login')
|
||||||
|
.then(response=>{this.user = response.data.data;});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
p {
|
||||||
|
font-size: 2em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,10 @@
|
||||||
|
/*jshint esversion: 6 */
|
||||||
|
|
||||||
|
require('./bootstrap');
|
||||||
|
|
||||||
|
window.Vue = require('vue');
|
||||||
|
|
||||||
|
const app = new Vue({
|
||||||
|
el: '#app',
|
||||||
|
|
||||||
|
});
|