Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ivr #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
13 changes: 12 additions & 1 deletion app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Actions\Fortify;

use App\Models\User;
use GeneralSettings;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Laravel\Fortify\Contracts\CreatesNewUsers;
Expand All @@ -12,6 +13,10 @@ class CreateNewUser implements CreatesNewUsers
{
use PasswordValidationRules;

public function __construct(GeneralSettings $generalSettings)
{
$this->settings = $generalSettings;
}
/**
* Validate and create a newly registered user.
*
Expand All @@ -27,10 +32,16 @@ public function create(array $input)
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
])->validate();

return User::create([
$user = User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
]);

if($default_role = $this->settings->default_role){
$user->assignRole($default_role);
}

return $user;
}
}
54 changes: 50 additions & 4 deletions app/Http/Controllers/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,64 @@
namespace App\Http\Controllers;

use DateTimeZone;
use GeneralSettings;
use Illuminate\Http\Request;
use ProviderSettings;
use Spatie\Permission\Models\Role;

class SettingController extends Controller
{
public function settingsPage()
private $generalSettings;

public function __construct(GeneralSettings $generalSettings, ProviderSettings $providerSettings)
{
$this->settings = $generalSettings;
$this->providerSettings = $providerSettings;
}

public function settingsPage(Request $request)
{
$providers = $request->input('providers');
if($providers){
$settings = $this->providerSettings;
return inertia()->render('Settings/ProviderSettings', [
'settings' => $settings
]);
}

$timezones = $this->available_timezones();
return inertia()->render('Settings/Settings', [
'timezones' => $timezones
$settings = $this->settings;
$roles = Role::pluck('name', 'id');
return inertia()->render('Settings/GeneralSettings', [
'timezones' => $timezones,
'settings' => $settings,
'roles' => $roles
]);
}

public function updateSettings(Request $request)
{
$inputs = $request->all();

if($inputs['settingType'] == 'providers'){
foreach($inputs as $key => $input){
if(!empty($input)){
$this->providerSettings->{$key} = $input;
}
}
$this->providerSettings->save();
}
elseif($inputs['settingType'] == 'general'){
foreach($inputs as $key => $input){
if(!empty($input)){
$this->settings->{$key} = $input;
}
}
$this->settings->save();
}
return redirect()->route('settings')->with('success', 'Settings updated successfully.');
}

function available_timezones() {
$timezones = [];

Expand All @@ -36,4 +82,4 @@ function available_timezones() {
}


}
}
6 changes: 5 additions & 1 deletion app/Http/Controllers/Users/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use App\Http\Controllers\Controller;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Hash;
use Inertia\Inertia;
use Spatie\Permission\Models\Role;
Expand Down Expand Up @@ -66,13 +68,15 @@ public function store(Request $request)
$user = User::firstOrCreate(['email' => $inputs['email']],[
'name' => $inputs['name'],
'email' => $inputs['email'],
'password' => Hash::make($inputs['password'])
'password' => Hash::make($inputs['password']),
'email_verified_at' => now()
]);

if($user->wasRecentlyCreated){
if($inputs['role']){
$role = Role::findOrCreate($inputs['role'], 'web');
$user->assignRole($role);

}
return redirect()->route('users.index')->with('success', 'User stored succefully.');
}
Expand Down
38 changes: 38 additions & 0 deletions app/Listeners/WelcomeUserNotification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Listeners;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Mail;

class WelcomeUserNotification
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}

/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
$mailData = [
'name' => $event->user->name,
'email' => $event->user->email
];
Mail::send('emails.welcome', $mailData, function($message) use ($mailData) {
$message->to($mailData['email']);
$message->subject('WelcomeMail');
});
}
}
3 changes: 2 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
class User extends Authenticatable implements MustVerifyEmail
{
use HasApiTokens;
use HasFactory;
Expand All @@ -29,6 +29,7 @@ class User extends Authenticatable
'name',
'email',
'password',
'email_verified_at'
];

/**
Expand Down
3 changes: 3 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class EventServiceProvider extends ServiceProvider
Registered::class => [
SendEmailVerificationNotification::class,
],
'Illuminate\Auth\Events\Verified' => [
'App\Listeners\WelcomeUserNotification',
],
];

/**
Expand Down
3 changes: 3 additions & 0 deletions app/Settings/GeneralSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
class GeneralSettings extends Settings{

public string $timezone;
public string $smtp_from_name;
public string $fallback_number;
public string $default_role;

public static function group(): string
{
Expand Down
20 changes: 20 additions & 0 deletions app/Settings/ProviderSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
use Spatie\LaravelSettings\Settings;

class ProviderSettings extends Settings{

public string $provider_type;
public string $accountSid;
public string $accountToken;
public string $serviceSID;
public string $account_apiKey;
public string $account_apiSecret;
public string $spaceUrl;
public string $projectId;
public string $projectToken;

public static function group(): string
{
return 'provider';
}
}
2 changes: 1 addition & 1 deletion config/fortify.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
'features' => [
Features::registration(),
Features::resetPasswords(),
// Features::emailVerification(),
Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
Features::twoFactorAuthentication([
Expand Down
3 changes: 2 additions & 1 deletion config/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* put them (manually) here.
*/
'settings' => [
GeneralSettings::class
GeneralSettings::class,
ProviderSettings::class
],

/*
Expand Down
98 changes: 98 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"vue": "^3.2.31"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.2",
"@fortawesome/free-brands-svg-icons": "^6.1.2",
"@fortawesome/free-regular-svg-icons": "^6.1.2",
"@fortawesome/free-solid-svg-icons": "^6.1.2",
"flowbite": "^1.5.1",
"flowbite-vue": "^0.0.5",
"vue-toastification": "^2.0.0-rc.5"
Expand Down
Binary file modified resources/.DS_Store
Binary file not shown.
Binary file modified resources/js/.DS_Store
Binary file not shown.
Loading