Merge pull request #150 from Poniverse/shift-40782

Co-authored-by: Laravel Shift <shift@laravelshift.com>
This commit is contained in:
Adam Lavin 2021-02-14 19:35:55 +00:00 committed by GitHub
commit 3d511c42e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 1928 additions and 512 deletions

49
.env.example Normal file
View file

@ -0,0 +1,49 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

View file

@ -28,7 +28,7 @@ use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
* A list of the exception types that are not reported.
*
* @var array
*/
@ -47,27 +47,14 @@ class Handler extends ExceptionHandler
];
/**
* Report or log an exception.
* Register the exception handling callbacks for the application.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Throwable $e)
public function register()
{
parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Throwable $e)
{
return parent::render($request, $e);
$this->reportable(function (Throwable $e) {
//
});
}
}

View file

@ -32,7 +32,7 @@ class Kernel extends HttpKernel
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
@ -58,7 +58,6 @@ class Kernel extends HttpKernel
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,

View file

@ -2,9 +2,9 @@
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class CheckForMaintenanceMode extends Middleware
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.

View file

@ -22,6 +22,7 @@ namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
@ -31,13 +32,17 @@ class RedirectIfAuthenticated
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @param string|null ...$guards
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
public function handle(Request $request, Closure $next, ...$guards)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);

View file

@ -10,7 +10,7 @@ class TrustProxies extends Middleware
/**
* The trusted proxies for this application.
*
* @var array
* @var array|string|null
*/
protected $proxies;
@ -19,5 +19,5 @@ class TrustProxies extends Middleware
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;
}

View file

@ -33,6 +33,7 @@ use DB;
use Exception;
use Gate;
use Helpers;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
@ -89,6 +90,7 @@ use Venturecraft\Revisionable\RevisionableTrait;
*/
class Album extends Model implements Searchable, Commentable, Favouritable
{
use HasFactory;
use SoftDeletes, SlugTrait, TrackCollection, RevisionableTrait, IndexedInElasticsearchTrait;
protected $elasticsearchType = 'album';

View file

@ -22,6 +22,7 @@ namespace App\Models;
use App\Traits\SlugTrait;
use DB;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\SoftDeletes;
@ -57,6 +58,8 @@ use Venturecraft\Revisionable\RevisionableTrait;
*/
class Genre extends Model
{
use HasFactory;
protected $table = 'genres';
protected $fillable = ['name', 'slug'];

View file

@ -36,6 +36,7 @@ use External;
use Gate;
use getid3_writetags;
use Helpers;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
@ -148,6 +149,7 @@ use Venturecraft\Revisionable\RevisionableTrait;
*/
class Track extends Model implements Searchable, Commentable, Favouritable
{
use HasFactory;
use SoftDeletes, IndexedInElasticsearchTrait;
protected $elasticsearchType = 'track';

View file

@ -31,6 +31,7 @@ use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
@ -104,6 +105,7 @@ use Venturecraft\Revisionable\RevisionableTrait;
*/
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, \Illuminate\Contracts\Auth\Access\Authorizable, Searchable, Commentable
{
use HasFactory;
use Authenticatable, CanResetPassword, Authorizable, RevisionableTrait, IndexedInElasticsearchTrait;
protected $elasticsearchType = 'user';

View file

@ -42,7 +42,6 @@ class EventServiceProvider extends ServiceProvider
*/
public function boot()
{
parent::boot();
//
}

View file

@ -21,28 +21,32 @@
namespace App\Providers;
use App\Models\User;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Routing\Router;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/home';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
@ -50,26 +54,34 @@ class RouteServiceProvider extends ServiceProvider
*/
public function boot()
{
parent::boot();
$this->configureRateLimiting();
Route::model('userId', User::class);
Route::bind('userSlug', function ($value) {
return User::where('slug', $value)->first();
$this->routes(function () {
Route::model('userId', User::class);
Route::bind('userSlug', function ($value) {
return User::where('slug', $value)->first();
});
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Define the routes for the application.
* Configure the rate limiters for the application.
*
* @return void
*/
public function map()
protected function configureRateLimiting()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}

View file

@ -10,14 +10,14 @@
"license": "AGPL",
"type": "project",
"require": {
"php": "^7.2.5|^8.0",
"laravel/framework": "^7.29",
"php": "^7.4|^8.0",
"laravel/framework": "^8.27",
"codescale/ffmpeg-php": "2.7.0",
"guzzlehttp/guzzle": "^6.3.1|^7.0.1",
"guzzlehttp/guzzle": "^7.0.1",
"doctrine/dbal": "^3.0",
"venturecraft/revisionable": "^1.36",
"pda/pheanstalk": "^4.0",
"cviebrock/laravel-elasticsearch": "^4.0",
"cviebrock/laravel-elasticsearch": "^8.0",
"barryvdh/laravel-debugbar": "^3.5",
"predis/predis": "^1.1",
"ksubileau/color-thief-php": "^1.3",
@ -34,25 +34,26 @@
"fideloper/proxy": "^4.4"
},
"require-dev": {
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^8.5.8|^9.3.3",
"mockery/mockery": "^1.4.2",
"phpunit/phpunit": "^9.3.3",
"symfony/dom-crawler": "^5.2",
"symfony/css-selector": "^5.2",
"laravel/browser-kit-testing": "^6.2",
"nategood/httpful": "^0.2.20",
"nunomaduro/collision": "^4.3",
"nunomaduro/collision": "^5.0",
"fakerphp/faker": "^1.9.1",
"facade/ignition": "^2.0"
"facade/ignition": "^2.5",
"barryvdh/laravel-ide-helper": "^2.9"
},
"autoload": {
"classmap": [
"database/factories",
"database/migrations",
"database/seeds",
"app/Library"
],
"psr-4": {
"App\\": "app/"
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
@ -67,6 +68,11 @@
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"@php artisan ide-helper:generate",
"@php artisan ide-helper:meta"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"

1699
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -41,6 +41,11 @@ return [
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',

View file

@ -13,9 +13,6 @@ return [
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
@ -29,6 +26,9 @@ return [
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "null"
|
*/
'stores' => [
@ -46,6 +46,7 @@ return [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
'lock_connection' => null,
],
'file' => [
@ -75,6 +76,7 @@ return [
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
'lock_connection' => 'default',
],
'dynamodb' => [

View file

@ -15,7 +15,7 @@ return [
|
*/
'paths' => ['api/*'],
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],

View file

@ -15,19 +15,6 @@ return [
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks

View file

@ -44,13 +44,13 @@ return [
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
@ -59,12 +59,12 @@ return [
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
@ -83,12 +83,12 @@ return [
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [

View file

@ -81,7 +81,7 @@ return [
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],

View file

@ -0,0 +1,59 @@
<?php
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015-2017 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class AlbumFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \App\Models\Album::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->sentence(5),
'slug' => $this->faker->slug,
'description' => $this->faker->paragraph(5),
];
}
}

View file

@ -0,0 +1,74 @@
<?php
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015-2017 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @property int $id
* @property int $user_id
* @property string $title
* @property string $slug
* @property string $description
* @property int $cover_id
* @property int $track_count
* @property int $view_count
* @property int $download_count
* @property int $favourite_count
* @property int $comment_count
* @property \Carbon\Carbon $created_at
* @property string $updated_at
* @property \Carbon\Carbon $deleted_at
*/
class GenreFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \App\Models\Genre::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->word,
'slug' => $this->faker->slug,
];
}
}

View file

@ -1,98 +0,0 @@
<?php
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015-2017 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
use App\Models\User;
$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
return [
'username' => $faker->userName,
'display_name' => $faker->userName,
'slug' => $faker->slug,
'email' => $faker->email,
'can_see_explicit_content' => true,
'uses_gravatar' => true,
'bio' => $faker->paragraph,
'track_count' => 0,
'comment_count' => 0,
];
});
$factory->define(\App\Models\Track::class, function (Faker\Generator $faker) {
$user = factory(User::class)->create();
return [
'user_id' => $user->id,
'hash' => $faker->md5,
'title' => $faker->sentence(5),
'slug' => $faker->slug,
'track_type_id' => \App\Models\TrackType::UNCLASSIFIED_TRACK,
'track_number' => null,
'description' => $faker->paragraph(5),
'lyrics' => $faker->paragraph(5),
'is_vocal' => true,
'is_explicit' => false,
'is_downloadable' => true,
'is_listed' => true,
'metadata' => '{"this":{"is":["very","random","metadata"]}}',
'duration' => $faker->randomFloat(null, 30, 600),
];
});
$factory->define(\App\Models\Genre::class, function (Faker\Generator $faker) {
return [
'name' => $faker->word,
'slug' => $faker->slug,
];
});
/**
* @property int $id
* @property int $user_id
* @property string $title
* @property string $slug
* @property string $description
* @property int $cover_id
* @property int $track_count
* @property int $view_count
* @property int $download_count
* @property int $favourite_count
* @property int $comment_count
* @property \Carbon\Carbon $created_at
* @property string $updated_at
* @property \Carbon\Carbon $deleted_at
*/
$factory->define(\App\Models\Album::class, function (Faker\Generator $faker) {
return [
'title' => $faker->sentence(5),
'slug' => $faker->slug,
'description' => $faker->paragraph(5),
];
});

View file

@ -0,0 +1,72 @@
<?php
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015-2017 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class TrackFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \App\Models\Track::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$user = User::factory()->create();
return [
'user_id' => $user->id,
'hash' => $this->faker->md5,
'title' => $this->faker->sentence(5),
'slug' => $this->faker->slug,
'track_type_id' => \App\Models\TrackType::UNCLASSIFIED_TRACK,
'track_number' => null,
'description' => $this->faker->paragraph(5),
'lyrics' => $this->faker->paragraph(5),
'is_vocal' => true,
'is_explicit' => false,
'is_downloadable' => true,
'is_listed' => true,
'metadata' => '{"this":{"is":["very","random","metadata"]}}',
'duration' => $this->faker->randomFloat(null, 30, 600),
];
}
}

View file

@ -0,0 +1,65 @@
<?php
/**
* Pony.fm - A community for pony fan music.
* Copyright (C) 2015-2017 Feld0.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \App\Models\User::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'username' => $this->faker->userName,
'display_name' => $this->faker->userName,
'slug' => $this->faker->slug,
'email' => $this->faker->email,
'can_see_explicit_content' => true,
'uses_gravatar' => true,
'bio' => $this->faker->paragraph,
'track_count' => 0,
'comment_count' => 0,
];
}
}

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUuidToFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('failed_jobs', function (Blueprint $table) {
$table->string('uuid')->after('id')->nullable()->unique();
});
DB::table('failed_jobs')->whereNull('uuid')->cursor()->each(function ($job) {
DB::table('failed_jobs')
->where('id', $job->id)
->update(['uuid' => (string) Str::uuid()]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('failed_jobs', function (Blueprint $table) {
$table->dropColumn('uuid');
});
}
}

View file

@ -18,6 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Database\Seeders;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;

View file

@ -18,7 +18,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class GenreTableSeeder extends Seeder
{

View file

@ -18,7 +18,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ShowSongTableSeeder extends Seeder
{

View file

@ -1,18 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php"
colors="true">
<coverage>
<include>
<directory suffix=".php">app/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">app/</directory>
</whitelist>
</filter>
<php>
<server name="APP_ENV" value="testing"/>
<server name="APP_KEY" value="CMOxJYitit2cFgI9FbbxJJpWxBBZl6RU"/>

View file

@ -1,23 +1,33 @@
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is maintenance / demo mode via the "down" command we
| will require this file so that any prerendered template can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/
@ -25,36 +35,21 @@ require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
| Run The Application
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Kernel::class);
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response);

View file

@ -91,6 +91,7 @@ return [
'array' => 'The :attribute must have at least :min items.',
],
'not_in' => 'The selected :attribute is invalid.',
'multiple_of' => 'The :attribute must be a multiple of :value.',
'not_regex' => 'The :attribute format is invalid.',
'numeric' => 'The :attribute must be a number.',
'password' => 'The password is incorrect.',

View file

@ -1,6 +1,7 @@
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
/*
|--------------------------------------------------------------------------
@ -15,4 +16,4 @@ use Illuminate\Foundation\Inspiring;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->describe('Display an inspiring quote');
})->purpose('Display an inspiring quote');

View file

@ -6,3 +6,4 @@ services.json
events.scanned.php
routes.scanned.php
down
maintenance.php

View file

@ -35,7 +35,7 @@ class ApiAuthTest extends TestCase
*/
public function testApiCreatesNewUser()
{
$user = factory(User::class)->make();
$user = User::factory()->make();
$accessTokenInfo = new AccessToken('nonsense-token');
$accessTokenInfo->setIsActive(true);
$accessTokenInfo->setScopes(['basic', 'ponyfm:tracks:upload']);
@ -61,7 +61,7 @@ class ApiAuthTest extends TestCase
public function testApiClientIdIsRecordedWhenUploadingTrack()
{
$user = factory(User::class)->make();
$user = User::factory()->make();
$accessTokenInfo = new AccessToken('nonsense-token');
$accessTokenInfo->setIsActive(true);

View file

@ -35,7 +35,7 @@ class ApiTest extends TestCase
public function testUploadWithoutFile()
{
$user = factory(User::class)->create();
$user = User::factory()->create();
$this->actingAs($user)
->post('/api/v1/tracks', [])
@ -80,11 +80,11 @@ class ApiTest extends TestCase
public function testUploadWithOptionalData()
{
/** @var Track $track */
$track = factory(Track::class)->make();
$track = Track::factory()->make();
/** @var Genre $genre */
$genre = factory(Genre::class)->make();
$genre = Genre::factory()->make();
/** @var Album $album */
$album = factory(Album::class)->make();
$album = Album::factory()->make();
$this->callUploadWithParameters([
'title' => $track->title,
@ -135,9 +135,9 @@ class ApiTest extends TestCase
public function testGetTrackDetails()
{
/** @var Track $track */
$track = factory(Track::class)->create();
$track = Track::factory()->create();
/** @var Genre $genre */
$genre = factory(Genre::class)->create();
$genre = Genre::factory()->create();
$track->genre()->associate($genre);
$this->seeInDatabase('tracks', ['id' => $track->id]);

View file

@ -142,7 +142,7 @@ class TestCase extends BaseTestCase
\App\Jobs\EncodeTrackFile::class,
\App\Jobs\UpdateSearchIndexForEntity::class,
]);
$this->user = factory(User::class)->create();
$this->user = User::factory()->create();
$file = $this->getTestFileForUpload('ponyfm-test.flac');