diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 582e790..c66f950 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -12,13 +12,22 @@ class TransactionController extends Controller { //THis should also reduce user's available credits public function newOrder(Request $request) { + $user = Auth::user(); $order = new Order; + $order->service_id = $request->service; $order->user_id = Auth::user()->id; $order->quantity = $request->quantity; $order->url = $request->url; $order->note = $request->note ?: ''; $order->status = 'processing'; + + $cost = ceil($order->quantity*$order->service->price/1000); + $user->credits = $user->credits - $cost; + if ($cost > $user->credits) { + abort(520, 'Insufficient Credits'); + } + $user->save(); $order->save(); } } diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 045d00e..a234e76 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -21,7 +21,7 @@ class CreateUsersTable extends Migration $table->string('password'); $table->string('role'); $table->boolean('active')->default(true); - $table->bigInteger('credits')->default(0); + $table->unsignedBigInteger('credits')->default(0); $table->rememberToken(); $table->timestamps(); }); diff --git a/resources/js/panel/credits.vue b/resources/js/panel/credits.vue new file mode 100644 index 0000000..9ffb918 --- /dev/null +++ b/resources/js/panel/credits.vue @@ -0,0 +1,3 @@ + +hello + diff --git a/resources/js/panel/orders.vue b/resources/js/panel/orders.vue index f5ca992..a0f19b4 100644 --- a/resources/js/panel/orders.vue +++ b/resources/js/panel/orders.vue @@ -1,7 +1,7 @@ - NewAdd credits + NewAdd credits Pending Orders diff --git a/resources/js/panel/panel.vue b/resources/js/panel/panel.vue index d5aca62..e245103 100644 --- a/resources/js/panel/panel.vue +++ b/resources/js/panel/panel.vue @@ -28,8 +28,8 @@ - + @@ -48,9 +48,6 @@ import Settings from './settings.vue' import PastOrders from './orders.vue' import NewOrder from './services.vue' -/* function getServices() { */ - -/* } */ function getServices() { return fetch("/panel/services", { method: 'GET', diff --git a/resources/js/panel/services.vue b/resources/js/panel/services.vue index 18e4225..7bafb8b 100644 --- a/resources/js/panel/services.vue +++ b/resources/js/panel/services.vue @@ -1,28 +1,44 @@ - Services - Credits - + Services + Credits + - Credits: {{credits}} - Name -Credits per 1000Min Qt.Max Qt. - - - - - + Credits: {{credits.toLocaleString('en')}} + + + + + NameCredits per 1000Min Qt.Max Qt. + + + + + + + - - - - - + + + + + {{selected.name}} Cost: {{cost.toLocaleString('en')}} Quantity - / {{selected.maximum.toLocaleString('en')}} + / + {{selected.maximum.toLocaleString('en')}} Location @@ -31,24 +47,36 @@ United Kingdom Germany France - + + URL - Submit + Submit + + - - + + Success! - + + + + + + + diff --git a/resources/js/panel/sidebar.vue b/resources/js/panel/sidebar.vue index 946e7e2..850537f 100644 --- a/resources/js/panel/sidebar.vue +++ b/resources/js/panel/sidebar.vue @@ -8,7 +8,7 @@ - + diff --git a/resources/scss/main.scss b/resources/scss/main.scss index 322e844..b8277bd 100644 --- a/resources/scss/main.scss +++ b/resources/scss/main.scss @@ -1003,12 +1003,13 @@ main.panel { margin-top: 1em; flex-flow: wrap; gap: 10px; - button { + a { width: 25%; font-size: 1.1rem; background: none; border: none; color: grey; + text-align: center; } .selected { color: black; @@ -1018,12 +1019,18 @@ main.panel { .menu-slider { width: 55%; div { - // margin-left: auto; + transition: all 0.2s; width: 50%; border-bottom: 2px solid black; + flex: 2; } } +.menu-slider.credits div { + // margin-left: auto; + transform: translateX(100%); +} + .services-pane { li { display: flex;