Typehinted the database models.

This commit is contained in:
Peter Deltchev 2015-12-31 16:36:08 -08:00
parent 5ff04ff08d
commit cb27cddac7
20 changed files with 440 additions and 0 deletions

View file

@ -20,11 +20,19 @@
namespace Poniverse\Ponyfm;
use Poniverse\Ponyfm\Models\Album;
use ZipStream;
class AlbumDownloader
{
/**
* @var Album
*/
private $_album;
/**
* @var string
*/
private $_format;
function __construct($album, $format)

View file

@ -32,6 +32,33 @@ use Poniverse\Ponyfm\Traits\TrackCollection;
use Poniverse\Ponyfm\Traits\SlugTrait;
use Venturecraft\Revisionable\RevisionableTrait;
/**
* Poniverse\Ponyfm\Models\Album
*
* @property integer $id
* @property integer $user_id
* @property string $title
* @property string $slug
* @property string $description
* @property integer $cover_id
* @property integer $track_count
* @property integer $view_count
* @property integer $download_count
* @property integer $favourite_count
* @property integer $comment_count
* @property \Carbon\Carbon $created_at
* @property string $updated_at
* @property \Carbon\Carbon $deleted_at
* @property-read \Poniverse\Ponyfm\Models\User $user
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\ResourceUser[] $users
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Favourite[] $favourites
* @property-read \Poniverse\Ponyfm\Models\Image $cover
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Track[] $tracks
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Comment[] $comments
* @property-read mixed $url
* @property-read \Illuminate\Database\Eloquent\Collection|\Venturecraft\Revisionable\Revision[] $revisionHistory
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\Album userDetails()
*/
class Album extends Model
{
use SoftDeletes, SlugTrait, DispatchesJobs, TrackCollection, RevisionableTrait;

View file

@ -23,6 +23,27 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Poniverse\Ponyfm\Models\Comment
*
* @property integer $id
* @property integer $user_id
* @property string $ip_address
* @property string $content
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at
* @property integer $profile_id
* @property integer $track_id
* @property integer $album_id
* @property integer $playlist_id
* @property-read \Poniverse\Ponyfm\Models\User $user
* @property-read \Poniverse\Ponyfm\Models\Track $track
* @property-read \Poniverse\Ponyfm\Models\Album $album
* @property-read \Poniverse\Ponyfm\Models\Playlist $playlist
* @property-read \Poniverse\Ponyfm\Models\User $profile
* @property-read mixed $resource
*/
class Comment extends Model
{

View file

@ -22,6 +22,22 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Poniverse\Ponyfm\Models\Favourite
*
* @property integer $id
* @property integer $user_id
* @property integer $track_id
* @property integer $album_id
* @property integer $playlist_id
* @property string $created_at
* @property-read \Poniverse\Ponyfm\Models\User $user
* @property-read \Poniverse\Ponyfm\Models\Track $track
* @property-read \Poniverse\Ponyfm\Models\Album $album
* @property-read \Poniverse\Ponyfm\Models\Playlist $playlist
* @property-read mixed $resource
* @property-read mixed $type
*/
class Favourite extends Model
{
protected $table = 'favourites';

View file

@ -22,6 +22,15 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Poniverse\Ponyfm\Models\Follower
*
* @property integer $id
* @property integer $user_id
* @property integer $artist_id
* @property integer $playlist_id
* @property string $created_at
*/
class Follower extends Model
{
protected $table = 'followers';

View file

@ -27,6 +27,20 @@ use Poniverse\Ponyfm\Traits\SlugTrait;
use Illuminate\Database\Eloquent\Model;
use Venturecraft\Revisionable\RevisionableTrait;
/**
* Poniverse\Ponyfm\Models\Genre
*
* @property integer $id
* @property string $name
* @property string $slug
* @property string $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Track[] $tracks
* @property-read \Poniverse\Ponyfm\Models\Track $trackCountRelation
* @property-read mixed $track_count
* @property-read mixed $url
* @property-write mixed $title
* @property-read \Illuminate\Database\Eloquent\Collection|\Venturecraft\Revisionable\Revision[] $revisionHistory
*/
class Genre extends Model
{
protected $table = 'genres';

View file

@ -25,6 +25,19 @@ use Illuminate\Database\Eloquent\Model;
use Config;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* Poniverse\Ponyfm\Models\Image
*
* @property integer $id
* @property string $filename
* @property string $mime
* @property string $extension
* @property integer $size
* @property string $hash
* @property integer $uploaded_by
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
class Image extends Model
{
const NORMAL = 1;

View file

@ -22,6 +22,16 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Poniverse\Ponyfm\Models\License
*
* @property integer $id
* @property string $title
* @property string $description
* @property boolean $affiliate_distribution
* @property boolean $open_distribution
* @property boolean $remix
*/
class License extends Model
{
protected $table = 'licenses';

View file

@ -22,6 +22,17 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Poniverse\Ponyfm\Models\PinnedPlaylist
*
* @property integer $id
* @property integer $user_id
* @property integer $playlist_id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property-read \Poniverse\Ponyfm\Models\User $user
* @property-read \Poniverse\Ponyfm\Models\Playlist $playlist
*/
class PinnedPlaylist extends Model
{
protected $table = 'pinned_playlists';

View file

@ -31,6 +31,33 @@ use Poniverse\Ponyfm\Traits\TrackCollection;
use Poniverse\Ponyfm\Traits\SlugTrait;
use Venturecraft\Revisionable\RevisionableTrait;
/**
* Poniverse\Ponyfm\Models\Playlist
*
* @property integer $id
* @property integer $user_id
* @property string $title
* @property string $slug
* @property string $description
* @property boolean $is_public
* @property integer $track_count
* @property integer $view_count
* @property integer $download_count
* @property integer $favourite_count
* @property integer $follow_count
* @property integer $comment_count
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Track[] $tracks
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\ResourceUser[] $users
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Comment[] $comments
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\PinnedPlaylist[] $pins
* @property-read \Poniverse\Ponyfm\Models\User $user
* @property-read mixed $url
* @property-read \Illuminate\Database\Eloquent\Collection|\Venturecraft\Revisionable\Revision[] $revisionHistory
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\Playlist userDetails()
*/
class Playlist extends Model
{
use SoftDeletes, SlugTrait, DispatchesJobs, TrackCollection, RevisionableTrait;

View file

@ -26,6 +26,19 @@ use Auth;
use DB;
use Request;
/**
* Poniverse\Ponyfm\Models\ResourceLogItem
*
* @property integer $id
* @property integer $user_id
* @property integer $log_type
* @property string $ip_address
* @property integer $track_format_id
* @property integer $track_id
* @property integer $album_id
* @property integer $playlist_id
* @property \Carbon\Carbon $created_at
*/
class ResourceLogItem extends Model
{
protected $table = 'resource_log_items';

View file

@ -22,6 +22,22 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Poniverse\Ponyfm\Models\ResourceUser
*
* @property integer $id
* @property integer $user_id
* @property integer $track_id
* @property integer $album_id
* @property integer $playlist_id
* @property integer $artist_id
* @property boolean $is_followed
* @property boolean $is_favourited
* @property boolean $is_pinned
* @property integer $view_count
* @property integer $play_count
* @property integer $download_count
*/
class ResourceUser extends Model
{
protected $table = 'resource_users';

View file

@ -22,6 +22,13 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Poniverse\Ponyfm\Models\Role
*
* @property integer $id
* @property string $name
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\User[] $users
*/
class Role extends Model
{
protected $table = 'roles';

View file

@ -22,6 +22,14 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Poniverse\Ponyfm\Models\ShowSong
*
* @property integer $id
* @property string $title
* @property string $lyrics
* @property string $slug
*/
class ShowSong extends Model
{
protected $table = 'show_songs';

View file

@ -36,6 +36,63 @@ use Illuminate\Support\Str;
use Log;
use Venturecraft\Revisionable\RevisionableTrait;
/**
* Poniverse\Ponyfm\Models\Track
*
* @property integer $id
* @property integer $user_id
* @property integer $license_id
* @property integer $genre_id
* @property integer $track_type_id
* @property string $title
* @property string $slug
* @property string $description
* @property string $lyrics
* @property boolean $is_vocal
* @property boolean $is_explicit
* @property integer $cover_id
* @property boolean $is_downloadable
* @property float $duration
* @property integer $play_count
* @property integer $view_count
* @property integer $download_count
* @property integer $favourite_count
* @property integer $comment_count
* @property \Carbon\Carbon $created_at
* @property string $updated_at
* @property \Carbon\Carbon $deleted_at
* @property \Carbon\Carbon $published_at
* @property \Carbon\Carbon $released_at
* @property integer $album_id
* @property integer $track_number
* @property boolean $is_latest
* @property string $hash
* @property boolean $is_listed
* @property string $source
* @property string $original_tags
* @property string $metadata
* @property-read \Poniverse\Ponyfm\Models\Genre $genre
* @property-read \Poniverse\Ponyfm\Models\TrackType $trackType
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Comment[] $comments
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Favourite[] $favourites
* @property-read \Poniverse\Ponyfm\Models\Image $cover
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\ShowSong[] $showSongs
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\ResourceUser[] $users
* @property-read \Poniverse\Ponyfm\Models\User $user
* @property-read \Poniverse\Ponyfm\Models\Album $album
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\TrackFile[] $trackFiles
* @property-read mixed $year
* @property-read mixed $url
* @property-read mixed $download_directory
* @property-read mixed $status
* @property-read \Illuminate\Database\Eloquent\Collection|\Venturecraft\Revisionable\Revision[] $revisionHistory
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\Track userDetails()
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\Track published()
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\Track listed()
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\Track explicitFilter()
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\Track withComments()
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\Track mlpma()
*/
class Track extends Model
{
use SoftDeletes;

View file

@ -26,6 +26,24 @@ use Illuminate\Database\Eloquent\Model;
use App;
use File;
/**
* Poniverse\Ponyfm\Models\TrackFile
*
* @property integer $id
* @property integer $track_id
* @property boolean $is_master
* @property string $format
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property boolean $is_cacheable
* @property boolean $status
* @property string $expires_at
* @property integer $filesize
* @property-read \Poniverse\Ponyfm\Models\Track $track
* @property-read mixed $extension
* @property-read mixed $url
* @property-read mixed $size
*/
class TrackFile extends Model
{
// used for the "status" property

View file

@ -22,6 +22,13 @@ namespace Poniverse\Ponyfm\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Poniverse\Ponyfm\Models\TrackType
*
* @property integer $id
* @property string $title
* @property string $editor_title
*/
class TrackType extends Model
{
protected $table = 'track_types';

View file

@ -31,6 +31,37 @@ use Auth;
use Illuminate\Support\Str;
use Venturecraft\Revisionable\RevisionableTrait;
/**
* Poniverse\Ponyfm\Models\User
*
* @property integer $id
* @property string $display_name
* @property string $username
* @property boolean $sync_names
* @property string $email
* @property string $gravatar
* @property string $slug
* @property boolean $uses_gravatar
* @property boolean $can_see_explicit_content
* @property string $bio
* @property integer $track_count
* @property integer $comment_count
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property integer $avatar_id
* @property string $remember_token
* @property boolean $is_archived
* @property \Carbon\Carbon $disabled_at
* @property-read \Poniverse\Ponyfm\Models\Image $avatar
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\ResourceUser[] $users
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Role[] $roles
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Comment[] $comments
* @property-read \Illuminate\Database\Eloquent\Collection|\Poniverse\Ponyfm\Models\Track[] $tracks
* @property-read mixed $url
* @property-read mixed $message_url
* @property-read \Illuminate\Database\Eloquent\Collection|\Venturecraft\Revisionable\Revision[] $revisionHistory
* @method static \Illuminate\Database\Query\Builder|\Poniverse\Ponyfm\Models\User userDetails()
*/
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, \Illuminate\Contracts\Auth\Access\Authorizable
{
use Authenticatable, CanResetPassword, Authorizable, RevisionableTrait;

View file

@ -20,11 +20,19 @@
namespace Poniverse\Ponyfm;
use Poniverse\Ponyfm\Models\Playlist;
use ZipStream;
class PlaylistDownloader
{
/**
* @var Playlist
*/
private $_playlist;
/**
* @var string
*/
private $_format;
function __construct($playlist, $format)

119
config/ide-helper.php Normal file
View file

@ -0,0 +1,119 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Filename & Format
|--------------------------------------------------------------------------
|
| The default filename (without extension) and the format (php or json)
|
*/
'filename' => '_ide_helper',
'format' => 'php',
/*
|--------------------------------------------------------------------------
| Helper files to include
|--------------------------------------------------------------------------
|
| Include helper files. By default not included, but can be toggled with the
| -- helpers (-H) option. Extra helper files can be included.
|
*/
'include_helpers' => false,
'helper_files' => array(
base_path().'/vendor/laravel/framework/src/Illuminate/Support/helpers.php',
),
/*
|--------------------------------------------------------------------------
| Model locations to include
|--------------------------------------------------------------------------
|
| Define in which directories the ide-helper:models command should look
| for models.
|
*/
'model_locations' => array(
'app/Models',
),
/*
|--------------------------------------------------------------------------
| Extra classes
|--------------------------------------------------------------------------
|
| These implementations are not really extended, but called with magic functions
|
*/
'extra' => array(
'Eloquent' => array('Illuminate\Database\Eloquent\Builder', 'Illuminate\Database\Query\Builder'),
'Session' => array('Illuminate\Session\Store'),
),
'magic' => array(
'Log' => array(
'debug' => 'Monolog\Logger::addDebug',
'info' => 'Monolog\Logger::addInfo',
'notice' => 'Monolog\Logger::addNotice',
'warning' => 'Monolog\Logger::addWarning',
'error' => 'Monolog\Logger::addError',
'critical' => 'Monolog\Logger::addCritical',
'alert' => 'Monolog\Logger::addAlert',
'emergency' => 'Monolog\Logger::addEmergency',
)
),
/*
|--------------------------------------------------------------------------
| Interface implementations
|--------------------------------------------------------------------------
|
| These interfaces will be replaced with the implementing class. Some interfaces
| are detected by the helpers, others can be listed below.
|
*/
'interfaces' => array(
),
/*
|--------------------------------------------------------------------------
| Support for custom DB types
|--------------------------------------------------------------------------
|
| This setting allow you to map any custom database type (that you may have
| created using CREATE TYPE statement or imported using database plugin
| / extension to a Doctrine type.
|
| Each key in this array is a name of the Doctrine2 DBAL Platform. Currently valid names are:
| 'postgresql', 'db2', 'drizzle', 'mysql', 'oracle', 'sqlanywhere', 'sqlite', 'mssql'
|
| This name is returned by getName() method of the specific Doctrine/DBAL/Platforms/AbstractPlatform descendant
|
| The value of the array is an array of type mappings. Key is the name of the custom type,
| (for example, "jsonb" from Postgres 9.4) and the value is the name of the corresponding Doctrine2 type (in
| our case it is 'json_array'. Doctrine types are listed here:
| http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html
|
| So to support jsonb in your models when working with Postgres, just add the following entry to the array below:
|
| "postgresql" => array(
| "jsonb" => "json_array",
| ),
|
*/
'custom_db_types' => array(
),
);