mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
frontend update
This commit is contained in:
@@ -66,6 +66,7 @@ class SetupDevEnvironment extends Command
|
||||
public function migrateDatabase()
|
||||
{
|
||||
$this->call('migrate:fresh');
|
||||
$this->call('db:seed');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,6 +63,9 @@ class SetupProductionEnvironment extends Command
|
||||
public function migrateDatabase()
|
||||
{
|
||||
$this->call('migrate:fresh');
|
||||
$this->call('db:seed', [
|
||||
'--class' => 'PaymentGatewaysSeeder'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,6 +42,11 @@ class UpgradeApp extends Command
|
||||
$this->info('Upgrading your application to version ' . $this->argument('version'));
|
||||
$this->call('down');
|
||||
|
||||
// Version 1.7
|
||||
if ($this->argument('version') === 'v1.7') {
|
||||
$this->version_1_7();
|
||||
}
|
||||
|
||||
// Version 1.6
|
||||
if ($this->argument('version') === 'v1.6') {
|
||||
$this->version_1_6();
|
||||
@@ -51,6 +56,19 @@ class UpgradeApp extends Command
|
||||
$this->info('Your application was upgraded! 🥳🥳🥳');
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade script to version 1.7
|
||||
*/
|
||||
public function version_1_7() {
|
||||
|
||||
// Migrate new tables and changes
|
||||
$this->call('migrate');
|
||||
|
||||
$this->call('db:seed', [
|
||||
'--class' => 'PaymentGatewaysSeeder'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade script to version 1.6
|
||||
*/
|
||||
|
||||
@@ -3,12 +3,52 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\GatewayCollection;
|
||||
use App\Http\Resources\GatewayResource;
|
||||
use App\PaymentGateway;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GatewayController extends Controller
|
||||
{
|
||||
public function update(Request $request, $gateway)
|
||||
/**
|
||||
* Get all payment gateways
|
||||
*
|
||||
* @return GatewayCollection
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $request->all();
|
||||
return new GatewayCollection(PaymentGateway::all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single payment gateway by slug
|
||||
*
|
||||
* @param $slug
|
||||
* @return GatewayResource
|
||||
*/
|
||||
public function show($slug)
|
||||
{
|
||||
$gateway = PaymentGateway::where('slug', $slug)->firstOrFail();
|
||||
|
||||
return new GatewayResource($gateway);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update payment gateway options
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $slug
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $slug)
|
||||
{
|
||||
// TODO: validation request
|
||||
|
||||
$gateway = PaymentGateway::where('slug', $slug)->first();
|
||||
|
||||
// Update text data
|
||||
$gateway->update(make_single_input($request));
|
||||
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
}
|
||||
|
||||
37
app/Http/Controllers/Admin/InvoiceController.php
Normal file
37
app/Http/Controllers/Admin/InvoiceController.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use App\Http\Resources\InvoiceResource;
|
||||
use App\Invoice;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get all invoices
|
||||
*
|
||||
* @return InvoiceCollection
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return new InvoiceCollection(
|
||||
Invoice::all()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single invoice by $token
|
||||
* @param $token
|
||||
* @return InvoiceResource
|
||||
*/
|
||||
public function show($token)
|
||||
{
|
||||
$invoice = Invoice::where('token', $token)->firstOrFail();
|
||||
|
||||
return view('vuefilemanager.invoice')
|
||||
->with('invoice', $invoice);
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,66 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PlanCollection;
|
||||
use App\Http\Resources\PlanResource;
|
||||
use App\Plan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PlanController extends Controller
|
||||
{
|
||||
public function create(Request $request)
|
||||
{
|
||||
return $request->all();
|
||||
/**
|
||||
* Get all plans
|
||||
*
|
||||
* @return PlanCollection
|
||||
*/
|
||||
public function index() {
|
||||
|
||||
return new PlanCollection(Plan::all());
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
/**
|
||||
* Get plan record
|
||||
*
|
||||
* @param $id
|
||||
* @return PlanResource
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return $request->all();
|
||||
$plan = Plan::findOrFail($id);
|
||||
|
||||
return new PlanResource($plan);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new plan
|
||||
*
|
||||
* @param Request $request
|
||||
* @return PlanResource
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// TODO: validation request
|
||||
|
||||
$plan = Plan::create($request->input('attributes'));
|
||||
|
||||
return new PlanResource($plan);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update plan attribute
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// TODO: validation request
|
||||
$plan = Plan::findOrFail($id);
|
||||
|
||||
// Update text data
|
||||
$plan->update(make_single_input($request));
|
||||
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Http\Requests\Admin\ChangeRoleRequest;
|
||||
use App\Http\Requests\Admin\ChangeStorageCapacityRequest;
|
||||
use App\Http\Requests\Admin\CreateUserByAdmin;
|
||||
use App\Http\Requests\Admin\DeleteUserRequest;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Http\Resources\UserStorageResource;
|
||||
@@ -35,7 +36,9 @@ class UserController extends Controller
|
||||
*/
|
||||
public function details($id)
|
||||
{
|
||||
return new UserResource(User::findOrFail($id));
|
||||
return new UserResource(
|
||||
User::findOrFail($id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +49,22 @@ class UserController extends Controller
|
||||
*/
|
||||
public function storage($id)
|
||||
{
|
||||
return new UserStorageResource(User::findOrFail($id));
|
||||
return new UserStorageResource(
|
||||
User::findOrFail($id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user storage details
|
||||
*
|
||||
* @param $id
|
||||
* @return InvoiceCollection
|
||||
*/
|
||||
public function invoices($id)
|
||||
{
|
||||
return new InvoiceCollection(
|
||||
User::findOrFail($id)->invoices
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +74,9 @@ class UserController extends Controller
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
return new UsersCollection(User::all());
|
||||
return new UsersCollection(
|
||||
User::all()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,9 @@ namespace App\Http\Controllers\User;
|
||||
|
||||
use App\FileManagerFile;
|
||||
use App\FileManagerFolder;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use App\Http\Resources\StorageDetailResource;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Http\Resources\UserStorageResource;
|
||||
use App\Http\Tools\Demo;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
@@ -26,7 +28,7 @@ class AccountController extends Controller
|
||||
public function user()
|
||||
{
|
||||
// Get User
|
||||
$user = User::with(['favourites', 'latest_uploads'])
|
||||
$user = User::with(['favourites'])
|
||||
->where('id', Auth::id())
|
||||
->first();
|
||||
|
||||
@@ -48,6 +50,18 @@ class AccountController extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get me
|
||||
*
|
||||
* @return UserResource
|
||||
*/
|
||||
public function me()
|
||||
{
|
||||
return new UserResource(
|
||||
Auth::user()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage details
|
||||
*
|
||||
@@ -55,7 +69,15 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function storage()
|
||||
{
|
||||
return new UserStorageResource(Auth::user());
|
||||
return new UserStorageResource(
|
||||
Auth::user()
|
||||
);
|
||||
}
|
||||
|
||||
public function invoices() {
|
||||
return new InvoiceCollection(
|
||||
Auth::user()->invoices
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,6 +127,29 @@ class AccountController extends Controller
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user settings relationship
|
||||
*
|
||||
* @param Request $request
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function update_user_settings(Request $request)
|
||||
{
|
||||
// TODO: validation
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
// Update text data
|
||||
$user->settings->update(make_single_input($request));
|
||||
|
||||
return response('Saved!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change user password
|
||||
*
|
||||
|
||||
23
app/Http/Resources/GatewayCollection.php
Normal file
23
app/Http/Resources/GatewayCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class GatewayCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = GatewayResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/GatewayResource.php
Normal file
35
app/Http/Resources/GatewayResource.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class GatewayResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'gateways',
|
||||
'attributes' => [
|
||||
'status' => $this->status,
|
||||
'sandbox' => $this->sandbox,
|
||||
'name' => $this->name,
|
||||
'slug' => $this->slug,
|
||||
'logo' => $this->logo,
|
||||
'client_id' => $this->client_id,
|
||||
'secret' => $this->secret,
|
||||
'webhook' => $this->webhook,
|
||||
'optional' => $this->optional,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/InvoiceCollection.php
Normal file
23
app/Http/Resources/InvoiceCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class InvoiceCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = InvoiceResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
51
app/Http/Resources/InvoiceResource.php
Normal file
51
app/Http/Resources/InvoiceResource.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class InvoiceResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'invoices',
|
||||
'attributes' => [
|
||||
'token' => $this->token,
|
||||
'order' => $this->order,
|
||||
'user_id' => $this->user_id,
|
||||
'plan_id' => $this->plan_id,
|
||||
'notes' => $this->notes,
|
||||
'total' => $this->total,
|
||||
'currency' => $this->currency,
|
||||
'seller' => $this->seller,
|
||||
'client' => $this->client,
|
||||
'bag' => $this->bag,
|
||||
'created_at_formatted' => format_date($this->created_at),
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]
|
||||
],
|
||||
'relationships' => [
|
||||
'user' => [
|
||||
'data' => [
|
||||
'id' => (string)$this->user->id,
|
||||
'type' => 'user',
|
||||
'attributes' => [
|
||||
'name' => $this->user->name,
|
||||
'avatar' => $this->user->avatar,
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/PlanCollection.php
Normal file
23
app/Http/Resources/PlanCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PlanCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = PlanResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/PlanResource.php
Normal file
35
app/Http/Resources/PlanResource.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PlanResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'plans',
|
||||
'attributes' => [
|
||||
'status' => $this->status,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'price' => $this->price,
|
||||
'capacity_formatted' => format_gigabytes($this->capacity),
|
||||
'capacity' => $this->capacity,
|
||||
'created_at_formatted' => format_date($this->created_at),
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class UserResource extends JsonResource
|
||||
$faker = Factory::create();
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'user',
|
||||
'attributes' => [
|
||||
@@ -27,11 +27,34 @@ class UserResource extends JsonResource
|
||||
'email' => env('APP_DEMO') ? $faker->email : $this->email,
|
||||
'avatar' => $this->avatar,
|
||||
'role' => $this->role,
|
||||
'storage' => $this->storage,
|
||||
'created_at_formatted' => format_date($this->created_at, '%d. %B. %Y'),
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]
|
||||
],
|
||||
'relationships' => [
|
||||
'settings' => [
|
||||
'data' => [
|
||||
'id' => (string)$this->settings->id,
|
||||
'type' => 'settings',
|
||||
'attributes' => [
|
||||
'billing_name' => $this->settings->billing_name,
|
||||
'billing_address' => $this->settings->billing_address,
|
||||
'billing_state' => $this->settings->billing_state,
|
||||
'billing_city' => $this->settings->billing_city,
|
||||
'billing_postal_code' => $this->settings->billing_postal_code,
|
||||
'billing_country' => $this->settings->billing_country,
|
||||
'billing_phone_number' => $this->settings->billing_phone_number,
|
||||
]
|
||||
]
|
||||
],
|
||||
'storage' => [
|
||||
'data' => [
|
||||
'id' => '1',
|
||||
'type' => 'storage',
|
||||
'attributes' => $this->storage
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class UserStorageResource extends JsonResource
|
||||
return [
|
||||
'data' => [
|
||||
'id' => (string)$this->id,
|
||||
'type' => 'user-storage',
|
||||
'type' => 'storage',
|
||||
'attributes' => [
|
||||
'used' => Metric::bytes($this->used_capacity)->format(),
|
||||
'capacity' => format_gigabytes($this->settings->storage_capacity),
|
||||
|
||||
18
app/Invoice.php
Normal file
18
app/Invoice.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'seller' => 'array',
|
||||
'client' => 'array',
|
||||
'bag' => 'array',
|
||||
];
|
||||
|
||||
public function user() {
|
||||
return $this->hasOne(User::class, 'id', 'user_id');
|
||||
}
|
||||
}
|
||||
12
app/PaymentGateway.php
Normal file
12
app/PaymentGateway.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PaymentGateway extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
10
app/Plan.php
Normal file
10
app/Plan.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Plan extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
10
app/User.php
10
app/User.php
@@ -191,4 +191,14 @@ class User extends Authenticatable
|
||||
|
||||
return $this->hasOne(UserSettings::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user invoices
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function invoices() {
|
||||
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user