Added Seed box CRUD

Added Seed box CRUD
This commit is contained in:
cp6 2022-05-16 12:07:35 +10:00
parent e4f0d95128
commit 07c0b8a655
9 changed files with 936 additions and 0 deletions

View File

@ -0,0 +1,169 @@
<?php
namespace App\Http\Controllers;
use App\Models\IPs;
use App\Models\Labels;
use App\Models\Pricing;
use App\Models\SeedBoxes;
use App\Models\Shared;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class SeedBoxesController extends Controller
{
public function index()
{
$seedboxes = SeedBoxes::seedBoxesDataIndexPage();
return view('seedboxes.index', compact(['seedboxes']));
}
public function create()
{
return view('seedboxes.create');
}
public function store(Request $request)
{
$request->validate([
'title' => 'required|string',
'hostname' => 'string|nullable',
'seed_box_type' => 'required',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'disk' => 'numeric',
'bandwidth' => 'numeric',
'port_speed' => 'numeric',
'next_due_date' => 'required|date'
]);
$seedbox_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(6, $seedbox_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
Labels::deleteLabelsAssignedTo($seedbox_id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $seedbox_id);
SeedBoxes::create([
'id' => $seedbox_id,
'title' => $request->title,
'hostname' => $request->hostname,
'seed_box_type' => $request->seed_box_type,
'provider_id' => $request->provider_id,
'location_id' => $request->location_id,
'disk' => $request->disk,
'disk_type' => 'GB',
'disk_as_gb' => $request->disk,
'owned_since' => $request->owned_since,
'bandwidth' => $request->bandwidth,
'port_speed' => $request->port_speed,
'was_promo' => $request->was_promo
]);
SeedBoxes::seedBoxRelatedCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box created Successfully.');
}
public function show(SeedBoxes $seedbox)
{
$seedbox_extras = SeedBoxes::seedBoxDataShowPage($seedbox->id);
$labels = Labels::labelsForService($seedbox->id);
return view('seedboxes.show', compact(['seedbox', 'seedbox_extras', 'labels']));
}
public function edit(SeedBoxes $seedbox)
{
$seedbox = SeedBoxes::seedBoxEditDataPage($seedbox->id);
$labels = Labels::labelsForService($seedbox[0]->id);
return view('seedboxes.edit', compact(['seedbox', 'labels']));
}
public function update(Request $request, SeedBoxes $seedbox)
{
$request->validate([
'id' => 'required|size:8',
'title' => 'required|string',
'hostname' => 'string|nullable',
'seed_box_type' => 'required',
'disk' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'bandwidth' => 'numeric',
'port_speed' => 'numeric'
]);
DB::table('seedboxes')
->where('id', $seedbox->id)
->update([
'title' => $request->title,
'hostname' => $request->hostname,
'seed_box_type' => $request->seed_box_type,
'location_id' => $request->location_id,
'provider_id' => $request->provider_id,
'disk' => $request->disk,
'disk_type' => 'GB',
'disk_as_gb' => $request->disk,
'owned_since' => $request->owned_since,
'bandwidth' => $request->bandwidth,
'port_speed' => $request->port_speed,
'was_promo' => $request->was_promo
]);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->updatePricing($seedbox->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
Labels::deleteLabelsAssignedTo($seedbox->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $seedbox->id);
Cache::forget("labels_for_service.{$seedbox->id}");
SeedBoxes::seedBoxRelatedCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box updated Successfully.');
}
public function destroy(SeedBoxes $seedbox)
{
$seedbox_id = $seedbox->id;
$items = SeedBoxes::find($seedbox_id);
$items->delete();
$p = new Pricing();
$p->deletePricing($seedbox_id);
Labels::deleteLabelsAssignedTo($seedbox_id);
SeedBoxes::seedBoxRelatedCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box was deleted Successfully.');
}
}

58
app/Models/SeedBoxes.php Normal file
View File

@ -0,0 +1,58 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class SeedBoxes extends Model
{
use HasFactory;
protected $table = 'seedboxes';
public $incrementing = false;
protected $fillable = ['id', 'active', 'title', 'hostname', 'seed_box_type', 'provider_id', 'location_id', 'bandwidth', 'port_speed', 'disk', 'disk_type', 'disk_as_gb', 'was_promo', 'owned_since'];
public static function seedBoxRelatedCacheForget(): void
{
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_pricing');//All pricing
}
public static function seedBoxesDataIndexPage()
{
return DB::table('seedboxes as s')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->get(['s.*', 'p.name as provider_name', 'pr.*', 'l.name as location']);
}
public static function seedBoxDataShowPage(string $seed_box_id)
{
return DB::table('seedboxes as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->where('s.id', '=', $seed_box_id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
}
public static function seedBoxEditDataPage(string $seed_box_id)
{
return DB::table('seedboxes as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->where('s.id', '=', $seed_box_id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
}
}

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('seedboxes', function (Blueprint $table) {
$table->char('id', 8)->primary();
$table->tinyInteger('active')->default(1);
$table->string('title');
$table->string('hostname')->nullable();
$table->string('seed_box_type')->nullable();
$table->unsignedBigInteger('provider_id')->default(9999);
$table->unsignedBigInteger('location_id')->default(9999);
$table->integer('bandwidth')->nullable();
$table->integer('port_speed')->nullable();
$table->integer('disk')->default(10);
$table->char('disk_type', 2)->default('GB');
$table->integer('disk_as_gb')->nullable()->default(0);
$table->tinyInteger('was_promo')->default(0);
$table->date('owned_since')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('seedboxes');
}
};

View File

@ -36,6 +36,7 @@
<li><a class="dropdown-item" href="{{route('locations.index')}}">Locations</a></li> <li><a class="dropdown-item" href="{{route('locations.index')}}">Locations</a></li>
<li><a class="dropdown-item" href="{{route('os.index')}}">OS</a></li> <li><a class="dropdown-item" href="{{route('os.index')}}">OS</a></li>
<li><a class="dropdown-item" href="{{route('providers.index')}}">Providers</a></li> <li><a class="dropdown-item" href="{{route('providers.index')}}">Providers</a></li>
<li><a class="dropdown-item" href="{{route('seedboxes.index')}}">Seedboxes</a></li>
<li><a class="dropdown-item" href="{{route('yabs.index')}}">YABs</a></li> <li><a class="dropdown-item" href="{{route('yabs.index')}}">YABs</a></li>
<li><a class="dropdown-item" href="{{route('settings.index')}}">Settings</a></li> <li><a class="dropdown-item" href="{{route('settings.index')}}">Settings</a></li>
<li><a class="dropdown-item" href="{{route('account.index')}}">Account</a></li> <li><a class="dropdown-item" href="{{route('account.index')}}">Account</a></li>

View File

@ -0,0 +1,173 @@
@section('title') {{'Enter new seed box'}} @endsection
<x-app-layout>
<x-slot name="header">
{{ __('Insert a new seed box') }}
</x-slot>
<div class="container">
<div class="card shadow mt-3">
<div class="card-body">
<h4 class="mb-3">Seed box information</h4>
<x-auth-validation-errors></x-auth-validation-errors>
<a href="{{ route('shared.index') }}"
class="btn btn-primary py-0 px-4 mb-4">
Go back
</a>
<form action="{{ route('seedboxes.store') }}" method="POST">
@csrf
<div class="row">
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Title</span></div>
<input type="text"
class="form-control"
name="title">
@error('title') <span class="text-red-500">{{ $message }}
</span>@enderror
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Hostname</span></div>
<input type="text"
class="form-control"
name="hostname">
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Type</span></div>
<select class="form-control" id="seed_box_type" name="seed_box_type">
<option value="uTorrent" selected="">uTorrent</option>
<option value="BitTorrent">BitTorrent</option>
<option value="ruTorrent">ruTorrent</option>
<option value="Transmission">Transmission</option>
<option value="qBitTorrent">qBitTorrent</option>
<option value="Zona">Zona</option>
<option value="Deluge">Deluge</option>
<option value="Other">Other</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 mb-3">
<x-providers-select>
<x-slot name="current">10</x-slot>
</x-providers-select>
</div>
<div class="col-md-3 mb-3">
<x-number-input>
<x-slot name="title">Price</x-slot>
<x-slot name="name">price</x-slot>
<x-slot name="value">2.50</x-slot>
<x-slot name="max">9999</x-slot>
<x-slot name="step">0.01</x-slot>
<x-slot name="required"></x-slot>
</x-number-input>
</div>
<div class="col-md-3 mb-3">
<x-term-select></x-term-select>
</div>
<div class="col-md-3 mb-3">
<x-currency-select>
<x-slot name="current">{{Session::get('default_currency')}}</x-slot>
</x-currency-select>
</div>
</div>
<div class="row mb-2">
<div class="col-12 col-md-3 mb-3">
<x-locations-select>
<x-slot name="current">1</x-slot>
</x-locations-select>
</div>
<div class="col-12 col-md-3 mb-3">
<x-yes-no-select>
<x-slot name="title">Was promo</x-slot>
<x-slot name="name">was_promo</x-slot>
<x-slot name="value">0</x-slot>
</x-yes-no-select>
</div>
<div class="col-12 col-md-3 mb-3">
<x-date-input>
<x-slot name="title">Owned since</x-slot>
<x-slot name="name">owned_since</x-slot>
<x-slot name="value">{{Carbon\Carbon::now()->format('Y-m-d') }}</x-slot>
</x-date-input>
</div>
<div class="col-12 col-md-3 mb-3">
<x-date-input>
<x-slot name="title">Next due date</x-slot>
<x-slot name="name">next_due_date</x-slot>
<x-slot name="value">{{Carbon\Carbon::now()->addDays(30)->format('Y-m-d') }}</x-slot>
</x-date-input>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Disk GB</x-slot>
<x-slot name="name">disk</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">500</x-slot>
</x-number-input>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Bandwidth GB</x-slot>
<x-slot name="name">bandwidth</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">1000</x-slot>
</x-number-input>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Port speed Mbps</x-slot>
<x-slot name="name">port_speed</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">1000</x-slot>
</x-number-input>
</div>
</div>
<div class="row mb-3">
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label1</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label2</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label3</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label4</x-slot>
</x-labels-select>
</div>
</div>
<div>
<button type="submit"
class="btn btn-success py-0 px-4 mt-2">
Insert Seed box
</button>
</div>
</form>
</div>
</div>
</div>
</x-app-layout>

View File

@ -0,0 +1,219 @@
@section('title') {{$seedbox[0]->title}} {{'edit'}} @endsection
<x-app-layout>
<x-slot name="header">
Edit {{ $seedbox[0]->title }}
</x-slot>
<div class="container">
<div class="card mt-3 shadow">
<div class="card-body">
<a href="{{ route('seedboxes.index') }}"
class="btn btn-primary px-4 py-1">
Back to seed boxes
</a>
<x-auth-validation-errors></x-auth-validation-errors>
<form action="{{ route('seedboxes.update', $seedbox[0]->service_id) }}" method="POST">
@csrf
@method('PUT')
<div class="row mt-3">
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Title</span></div>
<input type="text"
class="form-control"
name="title" value="{{$seedbox[0]->title}}">
@error('title') <span class="text-red-500">{{ $message }}
</span>@enderror
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Hostname</span></div>
<input type="text"
class="form-control"
name="hostname" value="{{$seedbox[0]->hostname}}">
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<input type="hidden" name="id" value="{{$seedbox[0]->service_id}}">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Type</span></div>
<select class="form-control" name="seed_box_type">
<option
value="uTorrent" {{ ($seedbox[0]->seed_box_type === 'uTorrent') ? 'selected' : '' }}>
uTorrent
</option>
<option
value="BitTorrent" {{ ($seedbox[0]->seed_box_type === 'BitTorrent') ? 'selected' : '' }}>
BitTorrent
</option>
<option
value="ruTorrent" {{ ($seedbox[0]->seed_box_type === 'ruTorrent') ? 'selected' : '' }}>
ruTorrent
</option>
<option
value="Transmission" {{ ($seedbox[0]->seed_box_type === 'Transmission') ? 'selected' : '' }}>
Transmission
</option>
<option
value="qBitTorrent" {{ ($seedbox[0]->seed_box_type === 'qBitTorrent') ? 'selected' : '' }}>
qBitTorrent
</option>
<option
value="Zona" {{ ($seedbox[0]->seed_box_type === 'Zona') ? 'selected' : '' }}>
Zona
</option>
<option
value="Other" {{ ($seedbox[0]->seed_box_type === 'Other') ? 'selected' : '' }}>
Other
</option>
<option
value="Deluge" {{ ($seedbox[0]->seed_box_type === 'Deluge') ? 'selected' : '' }}>
Deluge
</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 mb-3">
<x-providers-select>
<x-slot name="current">{{$seedbox[0]->provider_id}}</x-slot>
</x-providers-select>
</div>
<div class="col-md-3 mb-3">
<x-number-input>
<x-slot name="title">Price</x-slot>
<x-slot name="name">price</x-slot>
<x-slot name="value">{{$seedbox[0]->price}}</x-slot>
<x-slot name="max">9999</x-slot>
<x-slot name="step">0.01</x-slot>
<x-slot name="required"></x-slot>
</x-number-input>
</div>
<div class="col-md-3 mb-3">
<x-term-select>
<x-slot name="current">{{$seedbox[0]->term}}</x-slot>
</x-term-select>
</div>
<div class="col-md-3 mb-3">
<x-currency-select>
<x-slot name="current">{{$seedbox[0]->currency}}</x-slot>
</x-currency-select>
</div>
</div>
<div class="row mb-2">
<div class="col-12 col-md-3 mb-3">
<x-locations-select>
<x-slot name="current">{{$seedbox[0]->location_id}}</x-slot>
</x-locations-select>
</div>
<div class="col-12 col-md-3 mb-3">
<x-yes-no-select>
<x-slot name="title">Promo price</x-slot>
<x-slot name="name">was_promo</x-slot>
<x-slot name="value">{{ $seedbox[0]->was_promo }}</x-slot>
</x-yes-no-select>
</div>
<div class="col-12 col-md-3 mb-3">
<x-date-input>
<x-slot name="title">Owned since</x-slot>
<x-slot name="name">owned_since</x-slot>
<x-slot name="value">{{$seedbox[0]->owned_since }}</x-slot>
</x-date-input>
</div>
<div class="col-12 col-md-3 mb-3">
<x-date-input>
<x-slot name="title">Next due date</x-slot>
<x-slot name="name">next_due_date</x-slot>
<x-slot name="value">{{$seedbox[0]->next_due_date }}</x-slot>
</x-date-input>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Disk GB</x-slot>
<x-slot name="name">disk</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">{{$seedbox[0]->disk_as_gb}}</x-slot>
</x-number-input>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Bandwidth GB</x-slot>
<x-slot name="name">bandwidth</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">{{$seedbox[0]->bandwidth}}</x-slot>
</x-number-input>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Port speed GB</x-slot>
<x-slot name="name">port_speed</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">{{$seedbox[0]->port_speed}}</x-slot>
</x-number-input>
</div>
</div>
<div class="row mb-3">
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label1</x-slot>
@if(isset($labels[0]->id))
<x-slot name="current">{{$labels[0]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label2</x-slot>
@if(isset($labels[1]->id))
<x-slot name="current">{{$labels[1]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label3</x-slot>
@if(isset($labels[2]->id))
<x-slot name="current">{{$labels[2]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label4</x-slot>
@if(isset($labels[3]->id))
<x-slot name="current">{{$labels[3]->id}}</x-slot>
@endif
</x-labels-select>
</div>
</div>
<div class="form-check mt-2">
<input class="form-check-input" name="is_active" type="checkbox"
value="1" {{ ($seedbox[0]->active === 1) ? 'checked' : '' }}>
<label class="form-check-label">
I still have this server
</label>
</div>
<div>
<button type="submit"
class="btn btn-success px-4 py-1 mt-3">
Update seed box
</button>
</div>
</form>
</div>
</div>
</div>
</x-app-layout>

View File

@ -0,0 +1,124 @@
@section('title') {{'Seed boxes'}} @endsection
@section('style')
<x-modal-style></x-modal-style>
@endsection
@section('scripts')
<script src="{{ asset('js/vue.min.js') }}"></script>
<script src="{{ asset('js/axios.min.js') }}"></script>
@endsection
<x-app-layout>
<x-slot name="header">
{{ __('Seed boxes') }}
</x-slot>
<div class="container" id="app">
<x-delete-confirm-modal></x-delete-confirm-modal>
<div class="card shadow mt-3">
<div class="card-body">
<a href="{{ route('seedboxes.create') }}" class="btn btn-primary mb-3">Add a seed box</a>
@if ($message = Session::get('success'))
<div class="alert alert-success" role="alert">
<p class="my-1">{{ $message }}</p>
</div>
@endif
<div class="table-responsive">
<table class="table table-bordered">
<thead class="table-light">
<tr class="bg-gray-100">
<th>Title</th>
<th>Type</th>
<th>Location</th>
<th>Provider</th>
<th>Disk</th>
<th>BWidth</th>
<th>Port</th>
<th>Price</th>
<th>Due</th>
<th>Had since</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@if(isset($seedboxes[0]))
@foreach($seedboxes as $row)
<tr>
<td>{{ $row->title }}</td>
<td>{{ $row->seed_box_type }}</td>
<td class="text-nowrap">{{ $row->location }}</td>
<td class="text-nowrap">{{ $row->provider_name }}</td>
<td>
@if($row->disk_as_gb >= 1000)
{{ number_format($row->disk_as_gb / 1000,1) }} <small>TB</small>
@else
{{ $row->disk_as_gb }} <small>GB</small>
@endif
</td>
<td>
@if($row->bandwidth >= 1000)
{{ number_format($row->bandwidth / 1000,1) }} <small>TB</small>
@else
{{ $row->bandwidth }} <small>GB</small>
@endif
</td>
<td>
@if($row->port_speed >= 1000)
{{ number_format($row->port_speed / 1000,1) }} <small>Gbps</small>
@else
{{ $row->port_speed }} <small>Mbps</small>
@endif
</td>
<td>{{ $row->price }} {{$row->currency}} {{\App\Process::paymentTermIntToString($row->term)}}</td>
<td>{{Carbon\Carbon::parse($row->next_due_date)->diffForHumans()}}</td>
<td class="text-nowrap">{{ $row->owned_since }}</td>
<td class="text-nowrap">
<form action="{{ route('seedboxes.destroy', $row->service_id) }}" method="POST">
@csrf
<a href="{{ route('seedboxes.show', $row->service_id) }}"
class="text-body mx-1">
<i class="fas fa-eye" title="view"></i>
</a>
<a href="{{ route('seedboxes.edit', $row->service_id) }}"
class="text-body mx-1">
<i class="fas fa-pen" title="edit"></i>
</a>
<i class="fas fa-trash text-danger ms-3" @click="modalForm"
id="btn-{{$row->title}}" title="{{$row->service_id}}"></i>
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td class="px-4 py-2 border text-red-500" colspan="3">No seed boxes found.</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
@if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1)
<p class="text-muted mt-4 text-end"><small>Built on Laravel
v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }})</small></p>
@endif
</div>
<script>
let app = new Vue({
el: "#app",
data: {
"modal_hostname": '',
"modal_id": '',
"delete_form_action": '',
showModal: false
},
methods: {
modalForm(event) {
this.showModal = true;
this.modal_hostname = event.target.id.replace('btn-', '');
this.modal_id = event.target.title;
this.delete_form_action = 'seedboxes/' + this.modal_id;
}
}
});
</script>
</x-app-layout>

View File

@ -0,0 +1,145 @@
@section('title') {{$seedbox->title}} {{'Seed box'}} @endsection
<x-app-layout>
<x-slot name="header">
{{ __('Seed box details') }}
</x-slot>
<div class="container">
<x-card class="shadow mt-3">
<div class="row">
<div class="col-12 col-md-6 mb-2">
<h2>{{ $seedbox->title }}</h2>
<code>@foreach($labels as $label)
@if($loop->last)
{{$label->label}}
@else
{{$label->label}},
@endif
@endforeach</code>
</div>
<div class="col-12 col-md-6 text-md-end">
<h6 class="text-muted pe-lg-4">{{ $seedbox->id }}</h6>
@if($seedbox->active !== 1)
<h6 class="text-danger pe-lg-4">not active</h6>
@endif
</div>
</div>
<div class="row">
<div class="'col-12 col-lg-6">
<div class="table-responsive">
<table class="table table-borderless text-nowrap">
<tbody>
<tr>
<td class="px-2 py-2 font-bold text-muted">Type</td>
<td>{{ $seedbox->seed_box_type }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Hostname</td>
<td><code>{{ $seedbox_extras[0]->hostname }}</code></td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Location</td>
<td>{{ $seedbox_extras[0]->location }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Provider</td>
<td>{{ $seedbox_extras[0]->provider_name }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Price</td>
<td>{{ $seedbox_extras[0]->price }} {{ $seedbox_extras[0]->currency }}
<small>{{\App\Process::paymentTermIntToString($seedbox_extras[0]->term)}}</small>
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Was promo</td>
<td>{{ ($seedbox_extras[0]->was_promo === 1) ? 'Yes' : 'No' }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Owned since</td>
<td>
@if(!is_null($seedbox->owned_since))
{{ date_format(new DateTime($seedbox->owned_since), 'jS F Y') }}
@endif
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Next due date</td>
<td>{{Carbon\Carbon::parse($seedbox_extras[0]->next_due_date)->diffForHumans()}}
({{Carbon\Carbon::parse($seedbox_extras[0]->next_due_date)->format('d/m/Y')}})
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Inserted</td>
<td>
@if(!is_null($seedbox->created_at))
{{ date_format(new DateTime($seedbox->created_at), 'jS M y g:i a') }}
@endif
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Updated</td>
<td>
@if(!is_null($seedbox->updated_at))
{{ date_format(new DateTime($seedbox->updated_at), 'jS M y g:i a') }}
@endif
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="'col-12 col-lg-6">
<table class="table table-borderless">
<tbody>
<tr>
<td class="px-2 py-2 font-bold text-muted">Disk</td>
<td>
@if($seedbox->disk_as_gb >= 1000)
{{ number_format($seedbox->disk_as_gb / 1000,1) }} <small>TB</small>
@else
{{ $seedbox->disk_as_gb }} <small>GB</small>
@endif
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Bandwidth</td>
<td>
@if($seedbox->bandwidth >= 1000)
{{ number_format($seedbox->bandwidth / 1000,1) }} <small>TB</small>
@else
{{ $seedbox->bandwidth }} <small>GB</small>
@endif
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Port speed</td>
<td>
@if($seedbox->port_speed >= 1000)
{{ number_format($seedbox->port_speed / 1000,1) }} <small>Gbps</small>
@else
{{ $seedbox->port_speed }} <small>Mbps</small>
@endif
</td>
</tr>
</tbody>
</table>
</div>
</div>
<a href="{{ route('seedboxes.index') }}"
class="btn btn-success btn-sm mx-2">
Go back
</a>
<a href="{{ route('seedboxes.edit', $seedbox->id) }}"
class="btn btn-primary btn-sm mx-2">
Edit
</a>
</x-card>
@if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1)
<p class="text-muted mt-4 text-end"><small>
Built on Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}
)</small>
</p>
@endif
</div>
</x-app-layout>

View File

@ -10,6 +10,7 @@ use App\Http\Controllers\MiscController;
use App\Http\Controllers\OsController; use App\Http\Controllers\OsController;
use App\Http\Controllers\ProvidersController; use App\Http\Controllers\ProvidersController;
use App\Http\Controllers\ResellerController; use App\Http\Controllers\ResellerController;
use App\Http\Controllers\SeedBoxesController;
use App\Http\Controllers\ServerController; use App\Http\Controllers\ServerController;
use App\Http\Controllers\SettingsController; use App\Http\Controllers\SettingsController;
use App\Http\Controllers\SharedController; use App\Http\Controllers\SharedController;
@ -63,6 +64,8 @@ Route::resource('servers', ServerController::class)->middleware(['auth']);
Route::resource('settings', SettingsController::class)->middleware(['auth']); Route::resource('settings', SettingsController::class)->middleware(['auth']);
Route::resource('seedboxes', SeedBoxesController::class)->middleware(['auth']);
Route::resource('shared', SharedController::class)->middleware(['auth']); Route::resource('shared', SharedController::class)->middleware(['auth']);
Route::resource('yabs', YabsController::class)->middleware(['auth']); Route::resource('yabs', YabsController::class)->middleware(['auth']);