Removed old code; moved code under app/ to src/

This commit is contained in:
Gregory Ballantine 2023-05-13 00:09:46 -04:00
parent 114b256d97
commit 601b7173e8
17 changed files with 1 additions and 306 deletions

View File

@ -1,34 +0,0 @@
<?php
namespace Fieldprotocol\Music;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Album extends Eloquent {
protected $table = 'albums';
protected $fillable = [
'title',
'description',
'album_art',
'release_date',
];
public function songs() {
return $this->hasMany('Fieldprotocol\Music\Song');
}
public function links() {
return $this->hasMany('Fieldprotocol\Music\StoreLink', 'album_id');
}
public function releaseDate() {
return date('F j, Y', strtotime($this->release_date));
}
public function releaseYear() {
return date('Y', strtotime($this->release_date));
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace Fieldprotocol\Music;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Song extends Eloquent {
protected $table = 'songs';
protected $fillable = [
'title',
'album_id',
'track_order',
'audio_file',
];
public function album() {
return $this->belongsTo('Fieldprotocol\Music\Album');
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace Fieldprotocol\Music;
use Illuminate\Database\Eloquent\Model as Eloquent;
class StoreLink extends Eloquent {
protected $table = 'store_links';
protected $fillable = [
'link_name',
'link_ref',
];
public function album() {
return $this->belongsTo('Fieldprotocol\Music\Album', 'album_id');
}
}

View File

@ -1,57 +0,0 @@
<?php
namespace Fieldprotocol\User;
use Illuminate\Database\Eloquent\Model as Eloquent;
class User extends Eloquent {
protected $table = 'users';
protected $fillable = [
'id',
'username',
'first_name',
'last_name',
'email',
'posts'
];
public function getFullName() {
if (!$this->first_name || !$this->last_name) {
return null;
}
return "{$this->first_name} {$this->last_name}";
}
public function getName() {
return $this->getFullName() ?: $this->username;
}
public function getAvatarUrl($options = []) {
$size = isset($options['size']) ? $options['size'] : 45;
return 'http://www.gravatar.com/avatar/' . md5($this->email) . '?s=' . $size . '&d=identicon';
}
/*public function permissions() {
return $this->hasOne('Fieldprotocol\User\UserPermission', 'user_id');
}
public function hasPermission($permission) {
return (bool) $this->permissions->{$permission};
}
public function isAdmin() {
return $this->hasPermission('is_admin');
}
public function isEditor() {
return $this->hasPermission('is_editor');
}
public function isAuthor() {
return $this->hasPermission('is_author');
}*/
}

View File

@ -1,35 +0,0 @@
<?php
return [
'app' => [
'url' => 'https://halftoneband.com',
'hash' => [
'algo' => PASSWORD_BCRYPT,
'cost' => 10,
],
],
'db' => [
'driver' => 'mysql',
'host' => 'db.example.com',
'name' => 'db_name',
'username' => 'db_user',
'password' => 'db_secret',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
'auth' => [
'session' => 'user_id',
'remember' => 'user_r',
],
'twig' => [
'debug' => true,
],
'csrf' => [
'key' => 'csrf_token',
],
];

View File

@ -1,18 +0,0 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection([
'driver' => $app->config->get('db.driver'),
'host' => $app->config->get('db.host'),
'database' => $app->config->get('db.name'),
'username' => $app->config->get('db.username'),
'password' => $app->config->get('db.password'),
'charset' => $app->config->get('db.charset'),
'collation' => $app->config->get('db.collation'),
'prefix' => $app->config->get('db.prefix'),
]);
$capsule->bootEloquent();

View File

@ -1,38 +0,0 @@
<?php
// retrieve album info
$app->get('/apiv1/music/album-info/:albumid', function($albumid) use($app) {
if (!ctype_digit($albumid)) {
echo 'Don\'t do that';
return;
}
$album = $app->album->where('id', $albumid)->first();
if ($album) {
echo json_encode($album);
} else {
$app->notFound();
}
})->name('apiv1.music.album-info');
// retrieve an album's songs
$app->get('/apiv1/music/album-songs/:albumid', function($albumid) use($app) {
if (!ctype_digit($albumid)) {
echo 'Don\'t do that';
return;
}
$album = $app->album->where('id', $albumid)->first();
if ($album) {
$json = ['songs' => $album->songs];
echo json_encode($json);
} else {
$app->notFound();
}
})->name('apiv1.music.album-songs');

View File

@ -1,5 +0,0 @@
<?php
$app->notFound(function() use ($app) {
$app->render('errors/404.twig');
});

View File

@ -1,7 +0,0 @@
<?php
$app->get('/about', function() use($app) {
$app->render('pages/about.twig');
})->name('about');

View File

@ -1,7 +0,0 @@
<?php
$app->get('/contact', function() use($app) {
$app->render('pages/contact.twig');
})->name('contact');

View File

@ -1,7 +0,0 @@
<?php
$app->get('/home', function() use($app) {
$app->render('pages/home.twig');
})->name('home');

View File

@ -1,7 +0,0 @@
<?php
$app->get('/', function() use($app) {
$app->response->redirect($app->urlFor('home'), '303');
})->name('index');

View File

@ -1,16 +0,0 @@
<?php
// music page
$app->get('/music', function() use($app) {
$albums = $app->album->all()->sortByDesc('release_date')->values()->all();
$songs = $albums[0]->songs;
$links = $albums[0]->links;
$app->render('pages/music.twig', [
'albums' => $albums,
'songs' => $songs,
'links' => $links,
]);
})->name('music');

View File

@ -1,32 +0,0 @@
<?php
$app->get('/shows', function() use($app) {
$shows = json_decode(file_get_contents('http://api.bandsintown.com/artists/HALFtone/events.json?api_version=2.0&app_id=shows_halftoneband.com'));
foreach ($shows as $show) {
$show->date = date('M dS', strtotime($show->datetime));
$show->day = date('D', strtotime($show->datetime));
$show->time = date('H:i', strtotime($show->datetime));
}
$app->render('pages/shows.twig', [
'shows' => $shows,
]);
})->name('shows');
$app->get('/shows/json', function() use($app) {
$shows = json_decode(file_get_contents('http://api.bandsintown.com/artists/HALFtone/events.json?api_version=2.0&app_id=shows_halftoneband.com'));
foreach ($shows as $show) {
$show->date = date('M dS', strtotime($show->datetime));
$show->day = date('D', strtotime($show->datetime));
$show->time = date('H:i', strtotime($show->datetime));
print_r($show);
echo '<br /><br />';
}
die();
})->name('shows.json');

View File

@ -18,6 +18,6 @@ if (PHP_SAPI == 'cli-server') {
} }
} }
require_once __DIR__ . '/../app/start.php'; require_once __DIR__ . '/../src/start.php';
$app->run(); $app->run();