update migrations
This commit is contained in:
parent
b153558a25
commit
9daedaedc5
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->datetime('last_login_at')->nullable();
|
||||||
|
$table->string('last_login_ip')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->removeColumn('last_login_at');
|
||||||
|
$table->removeColumn('last_login_ip');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
: void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->foreignId('directorat_id')->nullable();
|
||||||
|
$table->foreignId('sub_directorat_id')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
: void
|
||||||
|
{
|
||||||
|
Schema::withoutForeignKeyConstraints(function () {
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('directorat_id');
|
||||||
|
$table->dropColumn('sub_directorat_id');
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('profile_photo_path', 2048)->nullable()->after('email');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('profile_photo_path');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
54
Http/Controllers/Auth/SocialiteController.php
Normal file
54
Http/Controllers/Auth/SocialiteController.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Events\Verified;
|
||||||
|
use Laravel\Socialite\Facades\Socialite;
|
||||||
|
|
||||||
|
class SocialiteController extends Controller
|
||||||
|
{
|
||||||
|
public function redirect($provider)
|
||||||
|
{
|
||||||
|
// redirect from social site
|
||||||
|
if (request()->input('state')) {
|
||||||
|
// already logged in
|
||||||
|
// get user info from social site
|
||||||
|
$user = Socialite::driver($provider)->stateless()->user();
|
||||||
|
|
||||||
|
// check for existing user
|
||||||
|
$existingUser = User::where('email', $user->getEmail())->first();
|
||||||
|
|
||||||
|
if ($existingUser) {
|
||||||
|
auth()->login($existingUser, true);
|
||||||
|
|
||||||
|
return redirect()->to('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
$newUser = $this->createUser($user);
|
||||||
|
auth()->login($newUser, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// request login from social site
|
||||||
|
return Socialite::driver($provider)->redirect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function createUser($user)
|
||||||
|
{
|
||||||
|
$user = User::updateOrCreate([
|
||||||
|
'email' => $user->getEmail(),
|
||||||
|
], [
|
||||||
|
'name' => $user->getName(),
|
||||||
|
'password' => '',
|
||||||
|
'avatar' => $user->getAvatar(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($user->markEmailAsVerified()) {
|
||||||
|
event(new Verified($user));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
}
|
13
Resources/views/users/users/columns/_action.blade.php
Normal file
13
Resources/views/users/users/columns/_action.blade.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
@php
|
||||||
|
$route = explode('.', Route::currentRouteName());
|
||||||
|
@endphp
|
||||||
|
<div class="d-flex flex-row flex-center">
|
||||||
|
<a href="{{ route($route[0].'.'.$route[1].'.edit',['user' => $model->id]) }}"
|
||||||
|
class="kt_edit_form btn btn-icon btn-bg-light btn-active-light-primary btn-sm me-1">
|
||||||
|
{!! getIcon("pencil", "fs-1 text-info","duotune") !!}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{!! Form::open(['method' => 'DELETE','route' => [$route[0].'.'.$route[1].'.destroy', $model->id],'class'=>'']) !!}
|
||||||
|
{{ Form::button(getIcon("trash", "fs-1 text-danger","duotune"), ['type' => 'submit', 'class' => 'delete btn btn-icon btn-bg-light btn-active-light-danger btn-sm'] ) }}
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</div>
|
23
Resources/views/users/users/columns/_user.blade.php
Normal file
23
Resources/views/users/users/columns/_user.blade.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<!--begin:: Avatar -->
|
||||||
|
<div class="symbol symbol-circle symbol-50px overflow-hidden me-3">
|
||||||
|
<a href="{{ route('user-management.users.show', $model) }}">
|
||||||
|
@if($model->profile_photo_url)
|
||||||
|
<div class="symbol-label">
|
||||||
|
<img src="{{ $model->profile_photo_url }}" class="w-100"/>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="symbol-label fs-3 {{ app(\App\Actions\GetThemeType::class)->handle('bg-light-? text-?', $model->name) }}">
|
||||||
|
{{ substr($model->name, 0, 1) }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<!--end::Avatar-->
|
||||||
|
<!--begin::User details-->
|
||||||
|
<div class="d-flex flex-column">
|
||||||
|
<a href="{{ route('user-management.users.show', $model) }}" class="text-gray-800 text-hover-primary mb-1">
|
||||||
|
{{ $model->name }}
|
||||||
|
</a>
|
||||||
|
<span>{{ $model->email }}</span>
|
||||||
|
</div>
|
||||||
|
<!--begin::User details-->
|
Loading…
Reference in New Issue
Block a user