This commit is contained in:
f4ilji
2024-12-03 22:36:36 +05:00
parent d0a9e663b7
commit 081f1a1c85
5 changed files with 148 additions and 29 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Console\Commands;
use App\Jobs\ImportUsers;
use Illuminate\Console\Command;
class TransferUsers extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'import:transfer-users';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
ImportUsers::dispatch();
}
}
+38 -24
View File
@@ -7,6 +7,7 @@ use App\Filament\Resources\UserResource\RelationManagers;
use App\Models\User;
use BezhanSalleh\FilamentShield\Contracts\HasShieldPermissions;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
@@ -31,33 +32,46 @@ class UserResource extends Resource implements HasShieldPermissions
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255)
->live(onBlur: true),
Forms\Components\TextInput::make('email')
->email()
->required()
->maxLength(255),
Forms\Components\DateTimePicker::make('email_verified_at'),
Section::make()->schema([
Forms\Components\Grid::make()->schema([
Forms\Components\TextInput::make('name')
->label('ФИО')
->required()
->maxLength(255)
->live(onBlur: true),
Forms\Components\TextInput::make('email')
->label('Email')
->email()
->required()
->unique(ignoreRecord: true)
->maxLength(255),
Forms\Components\DateTimePicker::make('email_verified_at')->label('Почта подтверждена'),
Forms\Components\TextInput::make('password')
->password()
->required(fn (string $context): bool => $context === 'create')
->dehydrated(fn ($state) => filled($state))
->maxLength(255),
Forms\Components\TextInput::make('password')
->label('Пароль')
->password()
->default(Str::password(15))
->required(fn (string $context): bool => $context === 'create')
->dehydrated(fn ($state) => filled($state))
->maxLength(255),
Forms\Components\Select::make('roles')
->label('Роль')
->relationship('roles', 'name')
->multiple()
->preload()
->searchable(),
Forms\Components\Select::make('roles')
->relationship('roles', 'name')
->multiple()
->preload()
->searchable(),
Forms\Components\Select::make('permissions')
->label('Разрешения')
->relationship('permissions', 'name')
->multiple()
->preload()
->searchable()
]),
Forms\Components\Select::make('permissions')
->relationship('permissions', 'name')
->multiple()
->preload()
->searchable()
]),
]);
}
@@ -20,8 +20,8 @@ class ClientFacultyController extends Controller
public function show(string $slug)
{
$faculties = FacultyResource::collection(Faculty::query()->where('is_active', true)->get());
$faculty = new FullFacultyResource(Faculty::where('slug', $slug)->where('is_active', true)->with(['departments.faculty', 'workers.userDetail'])->first());
$seo = $faculty->seo;
$faculty = new FullFacultyResource(Faculty::where('slug', $slug)->where('is_active', true)->with(['departments.faculty', 'workers.userDetail'])->firstOrFail());
$seo = $faculty->seo ?? null;
return Inertia::render('Client/Faculties/Show', compact('faculty', 'faculties', 'seo'));
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
namespace App\Jobs;
use App\Models\Post;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class ImportUsers implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct()
{
//
}
/**
* Execute the job.
*/
public function handle(): void
{
try {
$response = Http::get('http://crawdad-fresh-bream.ngrok-free.app/api/import/users/')->object();
foreach ($response as $user) {
$userDetail = $user->user_detail;
unset($user->user_detail);
$user = User::create([
'name' => $user->name,
'slug' => $user->slug,
'email' => $user->email,
'email_verified_at' => $user->email_verified_at,
'password' => $user->password,
'two_factor_secret' => $user->two_factor_secret,
'two_factor_recovery_codes' => $user->two_factor_recovery_codes,
'two_factor_confirmed_at' => $user->two_factor_confirmed_at,
'remember_token' => $user->remember_token,
'created_at' => $user->created_at,
'updated_at' => $user->updated_at,
]);
$user->userDetail()->create([
'user_id' => $user->id,
'is_only_worker' => $userDetail->is_only_worker,
'photo' => $userDetail->photo,
'academicTitle' => $userDetail->academicTitle,
'AcademicDegree' => $userDetail->AcademicDegree,
'education' => $userDetail->education,
'awards' => $userDetail->awards,
'professDisciplines' => $userDetail->professDisciplines,
'professionalRetraining' => $userDetail->professionalRetraining,
'professionalDevelopment' => $userDetail->professionalDevelopment,
'workExperience' => $userDetail->workExperience,
'attendedConferences' => $userDetail->attendedConferences,
'participationScienceProjects' => $userDetail->participationScienceProjects,
'publications' => $userDetail->publications,
'contactEmail' => $userDetail->contactEmail,
'contactPhone' => $userDetail->contactPhone,
'search_data' => $userDetail->search_data,
'other' => $userDetail->other,
'created_at' => $userDetail->created_at,
'updated_at' => $userDetail->updated_at,
]);
}
} catch (\Exception $e) {
Log::error('Error fetching posts: ' . $e->getMessage());
}
}
}
-3
View File
@@ -9,9 +9,6 @@ export default defineConfig({
plugins: [
laravel({
input: 'resources/js/app.js',
content: [
"./vendor/vormkracht10/filament-2fa/resources/**.*.blade.php",
],
ssr: 'resources/js/ssr.js',
refresh: true,
}),