- admin client order

This commit is contained in:
Peter Papp
2021-03-22 10:43:37 +01:00
parent 80b24cd753
commit 3c01ce5ad3
10 changed files with 1022 additions and 252 deletions
+36 -1
View File
@@ -3,8 +3,14 @@
namespace App\Http\Controllers\Oasis;
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\Support\Str;
use Notification;
class AdminController extends Controller
{
@@ -27,4 +33,33 @@ class AdminController extends Controller
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
);
}
}
+1
View File
@@ -34,6 +34,7 @@ class User extends Authenticatable
];
protected $casts = [
'id' => 'string',
'email_verified_at' => 'datetime',
];
@@ -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 [
//
];
}
}
+16
View File
@@ -29,5 +29,21 @@ class AppServiceProvider extends ServiceProvider
// Set locale for carbon dates
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).'';
*/
namespace App\Services;
namespace App\Services\Oasis;
class CzechRegisterSearchService
{