mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-13 16:55:01 +00:00
- added subscriptionrequest
- Oasis model trait
This commit is contained in:
@@ -34,13 +34,21 @@ class AdminController extends Controller
|
||||
return response($result[0], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new client and send email with payment details
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function register_new_client(Request $request)
|
||||
{
|
||||
// Create user
|
||||
$newbie = User::create([
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make(Str::random()),
|
||||
]);
|
||||
|
||||
// Store user settings
|
||||
$newbie
|
||||
->settings()
|
||||
->create([
|
||||
@@ -53,10 +61,19 @@ class AdminController extends Controller
|
||||
'country' => $request->country,
|
||||
'phone_number' => $request->phone_number,
|
||||
'timezone' => '1.0',
|
||||
]);
|
||||
|
||||
// Store subscription request
|
||||
$newbie
|
||||
->subscriptionRequest()
|
||||
->create([
|
||||
'requested_plan' => $request->plan,
|
||||
]);
|
||||
|
||||
$newbie->notify(new PaymentRequiredNotification());
|
||||
// Send notification with payment details
|
||||
$newbie->notify(new PaymentRequiredNotification(
|
||||
$newbie->subscriptionRequest
|
||||
));
|
||||
|
||||
return response(
|
||||
new UserResource($newbie), 201
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Oasis;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SubscriptionRequest extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'requested_plan'
|
||||
];
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($order) {
|
||||
$order->id = (string)Str::uuid();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use App\Notifications\ResetPassword;
|
||||
use App\Services\HelperService;
|
||||
use App\Services\StripeService;
|
||||
use App\Traits\Oasis;
|
||||
use ByteUnits\Metric;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -20,6 +21,8 @@ class User extends Authenticatable
|
||||
{
|
||||
use Notifiable, Billable, Sortable, HasFactory, HasApiTokens;
|
||||
|
||||
use Oasis;
|
||||
|
||||
protected $guarded = [
|
||||
'id',
|
||||
'role'
|
||||
|
||||
@@ -14,11 +14,11 @@ class PaymentRequiredNotification extends Notification
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
* @param $order
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($order)
|
||||
{
|
||||
//
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,10 +40,13 @@ class PaymentRequiredNotification extends Notification
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$url = url("/platba/{$this->order['id']}");
|
||||
|
||||
return (new MailMessage)
|
||||
->line('The introduction to the notification.')
|
||||
->action('Notification Action', url('/'))
|
||||
->line('Thank you for using our application!');
|
||||
->subject('🏝 Platobne instrukcie pre zakupenie balicka a aktivaciu Vasho konta')
|
||||
->line('🏝 Platobne instrukcie pre zakupenie balicka a aktivaciu Vasho konta')
|
||||
->action('Prejst na platbu', $url)
|
||||
->line('Dakujeme za zaujem o nase sluzby!');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\Oasis\SubscriptionRequest;
|
||||
|
||||
trait Oasis
|
||||
{
|
||||
/**
|
||||
* Get user subscription request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function subscriptionRequest()
|
||||
{
|
||||
return $this->hasOne(SubscriptionRequest::class);
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,7 @@ class AddItemsToUserSettingsTable extends Migration
|
||||
{
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSubscriptionRequestsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('subscription_requests', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary()->index();
|
||||
$table->uuid('user_id')->index();
|
||||
$table->string('requested_plan');
|
||||
$table->enum('status', ['requested', 'payed', 'cancelled'])->default('requested');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('subscription_requests');
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,11 @@ class OasisAdminTest extends TestCase
|
||||
'plan' => 'virtualni-sanon-basic',
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('subscription_requests', [
|
||||
'requested_plan' => 'virtualni-sanon-basic',
|
||||
'status' => 'requested',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'email' => 'john@doe.com',
|
||||
]);
|
||||
@@ -93,7 +98,6 @@ class OasisAdminTest extends TestCase
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'ico' => '08995281',
|
||||
'payment_activation' => 0,
|
||||
'requested_plan' => 'virtualni-sanon-basic',
|
||||
]);
|
||||
|
||||
$newbie = User::whereEmail('john@doe.com')
|
||||
|
||||
Reference in New Issue
Block a user