init commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class BandController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$this->addCssFile('band.css');
|
||||
return $this->render('band');
|
||||
}
|
||||
}
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
protected array $css = [
|
||||
"bootstrap.min.css",
|
||||
"bootstrap-theme.min.css",
|
||||
"common.css",
|
||||
"main.css"
|
||||
];
|
||||
|
||||
protected array $js = [
|
||||
"functions.js",
|
||||
"jquery-1.11.3.min.js",
|
||||
"bootstrap.min.js"
|
||||
];
|
||||
|
||||
protected function addJsFile(string $js): void
|
||||
{
|
||||
$this->js[] = $js;
|
||||
}
|
||||
|
||||
protected function addCssFile(string $css): void
|
||||
{
|
||||
$this->css[] = $css;
|
||||
}
|
||||
|
||||
protected function render(string $view, array $data = [])
|
||||
{
|
||||
$menu = config("menu");
|
||||
$css_files = $this->css;
|
||||
$js_files = $this->js;
|
||||
|
||||
return view($view,
|
||||
compact('menu'),
|
||||
compact(['css_files', 'js_files']),
|
||||
compact('data')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Loaders\GigsLoader;
|
||||
|
||||
class GigsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private GigsLoader $loader,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$events = $this->loader->getEvents();
|
||||
$this->addCssFile('gigs.css');
|
||||
|
||||
return $this->render('gigs')
|
||||
->with(compact('events'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class MainController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->render('home');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Loaders\PlaylistLoader;
|
||||
|
||||
class PlaylistController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private PlaylistLoader $loader,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$menu = config("menu");
|
||||
$css_files = $this->css;
|
||||
$js_files = $this->js;
|
||||
$playlist = $this->loader->getPlaylist();
|
||||
|
||||
return view('playlist',
|
||||
compact('menu'),
|
||||
compact(['css_files', 'js_files','playlist']),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class RiderController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->render('rider');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Loaders;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\ORM\Event;
|
||||
|
||||
class GigsLoader
|
||||
{
|
||||
public function getEvents(): array
|
||||
{
|
||||
$data = Event::select(
|
||||
"Event.Name as event",
|
||||
"Event.PlaceId as place_id",
|
||||
"Place.Name as place",
|
||||
"Place.Address as address",
|
||||
"Place.Phone as phone",
|
||||
"Place.Url as url",
|
||||
DB::Raw("DAY(Event.Date) as mday"),
|
||||
DB::Raw("MONTH(Event.Date) as month"),
|
||||
DB::Raw("DATE_FORMAT(Event.Time, '%H:%s') as time"),
|
||||
DB::Raw("CONCAT(DATE_FORMAT(Event.Date,'%Y-%m-%d'),
|
||||
'T',DATE_FORMAT(Event.Time, '%H:%i:%s')) as fulldate")
|
||||
)->join("Place", function ($join){
|
||||
$join->on("Place.Id", "=", "Event.PlaceId")
|
||||
->where("Place.DeleteDate", NULL);
|
||||
});
|
||||
$data = $data->get();
|
||||
|
||||
return $data ? $data->toArray() : [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Loaders;
|
||||
|
||||
use App\Models\ORM\Track;
|
||||
|
||||
class PlaylistLoader
|
||||
{
|
||||
public function getPlaylist(): array
|
||||
{
|
||||
$data = Track::select(
|
||||
"Track.Name as Track",
|
||||
"Performer.Name as Performer"
|
||||
)->join('Performer', function ($join) {
|
||||
$join->on('Performer.Id', "=", "Track.Performer")
|
||||
->where('Performer.DeleteDate', NULL);
|
||||
})->orderBy('Performer')->get();
|
||||
|
||||
return $data ? $data->toArray() : [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\ORM;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
const DELETED_AT = 'DeleteDate';
|
||||
const UPDATED_AT = 'UpdatedDate';
|
||||
const CREATED_AT = 'DateOfCreation';
|
||||
|
||||
protected $primaryKey = 'Id';
|
||||
protected $table = 'Event';
|
||||
protected $fillable = ['Name', 'Date', 'Time', 'Archived'];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\ORM;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Track extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
const DELETED_AT = 'DeleteDate';
|
||||
const UPDATED_AT = 'UpdatedDate';
|
||||
const CREATED_AT = 'DateOfCreation';
|
||||
|
||||
protected $primaryKey = 'Id';
|
||||
protected $table = 'Track';
|
||||
protected $fillable = ['Name', 'Length'];
|
||||
}
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Views;
|
||||
|
||||
class MenuGenerator
|
||||
{
|
||||
private string $common_class = 'common_mnu';
|
||||
private string $dropdown_class = 'dropdown';
|
||||
private array $menu;
|
||||
|
||||
public function __construct(?string $common_class, ?string $dropdown_class)
|
||||
{
|
||||
$this->common_class = $common_class ?? $this->common_class;
|
||||
$this->dropdown_class = $dropdown_class ?? $this->dropdown_class;
|
||||
$this->menu = config("menu");
|
||||
}
|
||||
|
||||
public function getRawMenu(): array
|
||||
{
|
||||
return $this->menu;
|
||||
}
|
||||
|
||||
public function getMenu(): string
|
||||
{
|
||||
$uls = $this->createMenu($this->menu);
|
||||
return "<ul class='nav navbar-nav'>$uls</ul>";
|
||||
}
|
||||
|
||||
private function getCommonBlock(string $class, string $name, ?string $link): string
|
||||
{
|
||||
return "<li class='$class'><a href='$link'>$name</a></li>";
|
||||
}
|
||||
|
||||
private function getDropdownBlock(string $class, string $name, array $children): string
|
||||
{
|
||||
$submenu = '';
|
||||
foreach($children as $child) {
|
||||
if($child['visible'] === 1) {
|
||||
$submenu .= $this->getCommonBlock($this->common_class, $child['name'], $child['url']);
|
||||
}
|
||||
}
|
||||
|
||||
return "<li class='$class'>
|
||||
<a href='#' class='dropdown-toggle' data-toggle='dropdown'
|
||||
role='button' aria-haspopup='true' aria-expanded='false'>$name
|
||||
<span class='caret'></span>
|
||||
</a><ul class='dropdown-menu'>$submenu</ul>
|
||||
</li>";
|
||||
}
|
||||
|
||||
private function createMenu(array $menu): string
|
||||
{
|
||||
$result = '';
|
||||
|
||||
foreach($menu as $arr) {
|
||||
$arr['link'] = isset($arr['url']) ? sprintf("/%s", $arr['url']) : null;
|
||||
|
||||
if ($arr['visible'] === 1) {
|
||||
if (isset($arr['children']) && (count($arr['children']) > 0)) {
|
||||
$result .= $this->getDropdownBlock($this->dropdown_class, $arr['name'], $arr['children']);
|
||||
} else {
|
||||
$result .= $this->getCommonBlock($this->common_class, $arr['name'], $arr['link']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user