mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
- admin client order
This commit is contained in:
@@ -3,8 +3,14 @@
|
|||||||
namespace App\Http\Controllers\Oasis;
|
namespace App\Http\Controllers\Oasis;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Services\CzechRegisterSearchService;
|
use App\Http\Resources\UserResource;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Notifications\Oasis\PaymentRequiredNotification;
|
||||||
|
use App\Services\Oasis\CzechRegisterSearchService;
|
||||||
|
use Hash;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Notification;
|
||||||
|
|
||||||
class AdminController extends Controller
|
class AdminController extends Controller
|
||||||
{
|
{
|
||||||
@@ -27,4 +33,33 @@ class AdminController extends Controller
|
|||||||
|
|
||||||
return response($result[0], 200);
|
return response($result[0], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function register_new_client(Request $request)
|
||||||
|
{
|
||||||
|
$newbie = User::create([
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make(Str::random()),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newbie
|
||||||
|
->settings()
|
||||||
|
->create([
|
||||||
|
'ico' => $request->ico,
|
||||||
|
'name' => $request->name,
|
||||||
|
'address' => $request->address,
|
||||||
|
'state' => $request->state,
|
||||||
|
'city' => $request->city,
|
||||||
|
'postal_code' => $request->postal_code,
|
||||||
|
'country' => $request->country,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'timezone' => '1.0',
|
||||||
|
'requested_plan' => $request->plan,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newbie->notify(new PaymentRequiredNotification());
|
||||||
|
|
||||||
|
return response(
|
||||||
|
new UserResource($newbie), 201
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class User extends Authenticatable
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
'id' => 'string',
|
||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
61
app/Notifications/Oasis/PaymentRequiredNotification.php
Normal file
61
app/Notifications/Oasis/PaymentRequiredNotification.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications\Oasis;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
class PaymentRequiredNotification extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return ['mail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail($notifiable)
|
||||||
|
{
|
||||||
|
return (new MailMessage)
|
||||||
|
->line('The introduction to the notification.')
|
||||||
|
->action('Notification Action', url('/'))
|
||||||
|
->line('Thank you for using our application!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($notifiable)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,5 +29,21 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
// Set locale for carbon dates
|
// Set locale for carbon dates
|
||||||
setlocale(LC_TIME, $get_time_locale);
|
setlocale(LC_TIME, $get_time_locale);
|
||||||
|
|
||||||
|
// Get all migrations with all directories
|
||||||
|
$this->loadMigrationsFrom(
|
||||||
|
$this->get_migration_paths()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function get_migration_paths(): array
|
||||||
|
{
|
||||||
|
$mainPath = database_path('migrations');
|
||||||
|
$directories = glob($mainPath . '/*', GLOB_ONLYDIR);
|
||||||
|
|
||||||
|
return array_merge([$mainPath], $directories);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
* echo ''.print_r($out, 1).'';
|
* echo ''.print_r($out, 1).'';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services\Oasis;
|
||||||
|
|
||||||
class CzechRegisterSearchService
|
class CzechRegisterSearchService
|
||||||
{
|
{
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
"kyslik/column-sortable": "^6.4",
|
"kyslik/column-sortable": "^6.4",
|
||||||
"laravel/cashier": "^12.9.1",
|
"laravel/cashier": "^12.9.1",
|
||||||
"laravel/fortify": "^1.7.7",
|
"laravel/fortify": "^1.7.7",
|
||||||
"laravel/framework": "^8.26.1",
|
"laravel/framework": "^8.30.1",
|
||||||
"laravel/sanctum": "^2.9",
|
"laravel/sanctum": "^2.9",
|
||||||
"laravel/tinker": "^2.0",
|
"laravel/tinker": "^2.6.1",
|
||||||
"laravel/ui": "^3.0",
|
"laravel/ui": "^3.0",
|
||||||
"league/flysystem-aws-s3-v3": "^1.0",
|
"league/flysystem-aws-s3-v3": "^1.0",
|
||||||
"league/flysystem-cached-adapter": "^1.0",
|
"league/flysystem-cached-adapter": "^1.0",
|
||||||
|
|||||||
1058
composer.lock
generated
1058
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddItemsToUserSettingsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('user_settings', function (Blueprint $table) {
|
||||||
|
$table->boolean('payment_activation')->after('storage_capacity')->default(0);
|
||||||
|
|
||||||
|
$table->string('ico')->after('phone_number')->nullable();
|
||||||
|
$table->string('requested_plan')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('user_settings', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('ico');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
use App\Http\Controllers\Oasis\AdminController;
|
use App\Http\Controllers\Oasis\AdminController;
|
||||||
|
|
||||||
Route::group(['prefix' => 'admin'], function () {
|
Route::group(['middleware' => 'auth:sanctum', 'prefix' => 'admin'], function () {
|
||||||
|
|
||||||
Route::get('/company-details', [AdminController::class, 'get_company_details']);
|
Route::get('/company-details', [AdminController::class, 'get_company_details']);
|
||||||
|
|
||||||
|
// Users
|
||||||
|
Route::post('/users/create', [AdminController::class, 'register_new_client']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,12 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Oasis;
|
namespace Tests\Feature\Oasis;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Notifications\Oasis\PaymentRequiredNotification;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
use Notification;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class OasisAdminTest extends TestCase
|
class OasisAdminTest extends TestCase
|
||||||
@@ -15,6 +19,11 @@ class OasisAdminTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_get_register_by_ico()
|
public function it_get_register_by_ico()
|
||||||
{
|
{
|
||||||
|
$admin = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
Sanctum::actingAs($admin);
|
||||||
|
|
||||||
$response = [
|
$response = [
|
||||||
"name" => "GDPR Cloud Solution, s.r.o.",
|
"name" => "GDPR Cloud Solution, s.r.o.",
|
||||||
"ico" => "08995281",
|
"ico" => "08995281",
|
||||||
@@ -39,6 +48,11 @@ class OasisAdminTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_try_to_get_register_by_ico_with_not_found_result()
|
public function it_try_to_get_register_by_ico_with_not_found_result()
|
||||||
{
|
{
|
||||||
|
$admin = User::factory(User::class)
|
||||||
|
->create();
|
||||||
|
|
||||||
|
Sanctum::actingAs($admin);
|
||||||
|
|
||||||
Http::fake([
|
Http::fake([
|
||||||
'https://or.justice.cz/ias/ui/rejstrik-0899528199' => Http::response([], 200),
|
'https://or.justice.cz/ias/ui/rejstrik-0899528199' => Http::response([], 200),
|
||||||
]);
|
]);
|
||||||
@@ -46,4 +60,45 @@ class OasisAdminTest extends TestCase
|
|||||||
$this->getJson('/api/oasis/admin/company-details?ico=0899528199')
|
$this->getJson('/api/oasis/admin/company-details?ico=0899528199')
|
||||||
->assertNotFound();
|
->assertNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_register_new_client_from_admin_panel()
|
||||||
|
{
|
||||||
|
Notification::fake();
|
||||||
|
|
||||||
|
$admin = User::factory(User::class)
|
||||||
|
->create(['role' => 'admin']);
|
||||||
|
|
||||||
|
Sanctum::actingAs($admin);
|
||||||
|
|
||||||
|
$this->postJson('/api/oasis/admin/users/create', [
|
||||||
|
'ico' => '08995281',
|
||||||
|
'name' => 'GDPR Cloud Solution, s.r.o.',
|
||||||
|
'email' => 'john@doe.com',
|
||||||
|
'phone_number' => '+420950123456',
|
||||||
|
'address' => 'Zbraslavská 12/11',
|
||||||
|
'state' => 'CZ',
|
||||||
|
'city' => 'Praha',
|
||||||
|
'postal_code' => '15900',
|
||||||
|
'country' => 'CZ',
|
||||||
|
'plan' => 'virtualni-sanon-basic',
|
||||||
|
])->assertStatus(201);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('users', [
|
||||||
|
'email' => 'john@doe.com',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('user_settings', [
|
||||||
|
'ico' => '08995281',
|
||||||
|
'payment_activation' => 0,
|
||||||
|
'requested_plan' => 'virtualni-sanon-basic',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newbie = User::whereEmail('john@doe.com')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
Notification::assertSentTo($newbie, PaymentRequiredNotification::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user