Custom useful links via database / command (#41)
* Small change to the test command * Custom useful links via database and command
This commit is contained in:
parent
6d45731254
commit
b32352e925
53
app/Console/Commands/createUsefulLink.php
Normal file
53
app/Console/Commands/createUsefulLink.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\UsefulLink;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class createUsefulLink extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'create:usefullink';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create a useful link that user can see on the Dashboard';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->alert('You can add Icons to your useful links. Go to https://fontawesome.com/v5.15/icons?d=gallery&p=2 and copy an Icon name.');
|
||||||
|
|
||||||
|
$icon = $this->ask('Specify the class(es) of the font-awesome icon you want to use as the icon. (e.x: ad, fa fa-briefcase, fab fa-discord)', '');
|
||||||
|
$title = $this->ask('What do you want the title to be of this message?', 'Default Useful Link Title');
|
||||||
|
$message= $this->ask('Now please type the message you want to show. Tip: You can use HTML to format!');
|
||||||
|
$link = $this->ask('Please fill in a valid Link. Users can click the title to go to the link', 'https://bitsec.dev');
|
||||||
|
|
||||||
|
$usefulLink = UsefulLink::create([
|
||||||
|
'icon' => $icon,
|
||||||
|
'title' => $title,
|
||||||
|
'link' => $link,
|
||||||
|
'message' => $message
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->alert('Command ran successful inserted useful link into database');
|
||||||
|
|
||||||
|
$this->table(['Icon', 'Title', 'Link', 'Message'], [
|
||||||
|
[$icon, $title, $link, $message]
|
||||||
|
]);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\UsefulLink;
|
||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -19,14 +21,17 @@ class HomeController extends Controller
|
||||||
//set cookie as extra layer of defense against users that make multiple accounts
|
//set cookie as extra layer of defense against users that make multiple accounts
|
||||||
setcookie('4b3403665fea6' , base64_encode(1) , time() + (20 * 365 * 24 * 60 * 60));
|
setcookie('4b3403665fea6' , base64_encode(1) , time() + (20 * 365 * 24 * 60 * 60));
|
||||||
|
|
||||||
$useage = 0;
|
$usage = 0;
|
||||||
|
|
||||||
foreach (Auth::user()->Servers as $server){
|
foreach (Auth::user()->Servers as $server){
|
||||||
$useage += $server->product->price;
|
$usage += $server->product->price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$useful_links = DB::table('useful_links')->get();
|
||||||
|
|
||||||
return view('home')->with([
|
return view('home')->with([
|
||||||
'useage' => $useage
|
'useage' => $usage,
|
||||||
|
'useful_links' => $useful_links
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
app/Models/UsefulLink.php
Normal file
20
app/Models/UsefulLink.php
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UsefulLink extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'useful_links';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'icon',
|
||||||
|
'title',
|
||||||
|
'link',
|
||||||
|
'message'
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateUsefulLinksTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('useful_links', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('icon')->default('');
|
||||||
|
$table->string('title')->default('Default Title');
|
||||||
|
$table->string('link')->default('https://bitsec.dev');
|
||||||
|
$table->string('message')->default('Default Message');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
|
||||||
|
\App\Models\UsefulLink::create([
|
||||||
|
'icon' => 'fas fa-egg',
|
||||||
|
'title' => 'Pterodactyl Panel',
|
||||||
|
'link' => env('PTERODACTYL_URL' , 'http://localhost'),
|
||||||
|
'message' => 'Use your servers on our pterodactyl panel <small>(You can use the same login details)</small>'
|
||||||
|
]);
|
||||||
|
\App\Models\UsefulLink::create([
|
||||||
|
'icon' => 'fas fa-database',
|
||||||
|
'title' => 'phpMyAdmin',
|
||||||
|
'link' => env('PHPMYADMIN_URL' , 'http://localhost'),
|
||||||
|
'message' => 'View your database online using phpMyAdmin'
|
||||||
|
]);
|
||||||
|
\App\Models\UsefulLink::create([
|
||||||
|
'icon' => 'fab fa-discord',
|
||||||
|
'title' => 'Discord',
|
||||||
|
'link' => env('DISCORD_INVITE_URL'),
|
||||||
|
'message' => 'Need a helping hand? Want to chat? Got any questions? Join our discord!'
|
||||||
|
]);
|
||||||
|
\App\Models\UsefulLink::create([
|
||||||
|
'icon' => 'fas fa-link',
|
||||||
|
'title' => 'Useful Links',
|
||||||
|
'link' => '_blank',
|
||||||
|
'message' => 'Want to make your own links that show here? Use the command <code>php artisan create:usefullink</code></br> Delete links via database (for now)'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('useful_links');
|
||||||
|
}
|
||||||
|
}
|
|
@ -81,26 +81,17 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- /.card-header -->
|
<!-- /.card-header -->
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
@foreach ($useful_links as $useful_link)
|
||||||
<div class="alert alert-dismissible">
|
<div class="alert alert-dismissible">
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||||
<h5><a class="alert-link text-decoration-none" target="__blank" href="{{env('PTERODACTYL_URL' , 'http://localhost')}}"><i
|
<h5>
|
||||||
class="fas fa-egg mr-2"></i>Pterodactyl Panel</a></h5>
|
<a class="alert-link text-decoration-none" target="__blank" href="{{ $useful_link->link }}">
|
||||||
Use your servers on our pterodactyl panel <small>(You can use the same login details)</small>
|
<i class="{{ $useful_link->icon }} mr-2"></i>{{ $useful_link->title }}
|
||||||
</div>
|
</a>
|
||||||
|
</h5>
|
||||||
<div class="alert alert-dismissible">
|
{!! $useful_link->message !!}
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
|
||||||
<h5><a class="alert-link text-decoration-none" target="__blank" href="{{env('PHPMYADMIN_URL' , 'http://localhost')}}"><i
|
|
||||||
class="fas fa-database mr-2"></i>phpMyAdmin</a></h5>
|
|
||||||
View your database online using phpMyAdmin
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="alert alert-dismissible">
|
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
|
||||||
<h5><a class="alert-link text-decoration-none" target="__blank" href="{{env('DISCORD_INVITE_URL')}}"><i
|
|
||||||
class="fab fa-discord mr-2"></i>Discord</a></h5>
|
|
||||||
Need a helping hand? Want to chat? Got any questions? Join our discord!
|
|
||||||
</div>
|
</div>
|
||||||
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
<!-- /.card-body -->
|
<!-- /.card-body -->
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue