diff --git a/app/Http/Controllers/Api/CurrencyController.php b/app/Http/Controllers/Api/CurrencyController.php new file mode 100644 index 00000000..09e817cd --- /dev/null +++ b/app/Http/Controllers/Api/CurrencyController.php @@ -0,0 +1,15 @@ +validate([ + 'name' => ['required'], + 'email' => ['required', 'email', 'unique:users'], + 'password' => ['required', 'confirmed'], + 'currency' => ['required', 'exists:currencies,id'], + ]); + + $user = User::query() + ->create([ + 'name' => $request->input('name'), + 'email' => $request->input('email'), + 'password' => Hash::make($request->input('password')), + 'verification_token' => Str::random(100), + ]); + + $space = Space::query() + ->create([ + 'currency_id' => $request->input('currency'), + 'name' => $user->name . '\'s Space', + ]); + + $user->spaces()->attach($space->id, ['role' => 'admin']); + + (new SendVerificationMailAction())->execute($user->id); + + return [ + 'success' => true, + ]; + } +} diff --git a/app/Http/Resources/CurrencyResource.php b/app/Http/Resources/CurrencyResource.php new file mode 100644 index 00000000..ca800ebc --- /dev/null +++ b/app/Http/Resources/CurrencyResource.php @@ -0,0 +1,19 @@ + $this->id, + 'name' => $this->name, + 'symbol' => $this->symbol, + 'iso' => $this->iso, + ]; + } +} diff --git a/resources/assets/js/prototype/app.js b/resources/assets/js/prototype/app.js index c336c189..4405fdba 100644 --- a/resources/assets/js/prototype/app.js +++ b/resources/assets/js/prototype/app.js @@ -8,6 +8,7 @@ import translations from './translations'; import App from './components/App.vue'; import Login from './screens/Login.vue'; +import Register from './screens/Register.vue'; import Dashboard from './screens/Dashboard.vue'; import TransactionsIndex from './screens/Transactions/Index.vue'; import TransactionsCreate from './screens/Transactions/Create.vue'; @@ -27,6 +28,10 @@ const routes = [ path: '/prototype/login', name: 'login', component: Login, + }, { + path: '/prototype/register', + name: 'register', + component: Register, }, { path: '/prototype/dashboard', name: 'dashboard', diff --git a/resources/assets/js/prototype/screens/Login.vue b/resources/assets/js/prototype/screens/Login.vue index 45bf9a50..80986a5c 100644 --- a/resources/assets/js/prototype/screens/Login.vue +++ b/resources/assets/js/prototype/screens/Login.vue @@ -69,7 +69,9 @@ watch(showError, value => { -