├── .gitattributes ├── .gitignore ├── CONTRIBUTING.md ├── app ├── Acme │ └── Transformers │ │ ├── LessonTransformer.php │ │ ├── TagTransformer.php │ │ └── Transformer.php ├── commands │ └── .gitkeep ├── config │ ├── app.php │ ├── auth.php │ ├── cache.php │ ├── compile.php │ ├── database.php │ ├── local │ │ ├── app.php │ │ └── database.php │ ├── mail.php │ ├── packages │ │ └── .gitkeep │ ├── queue.php │ ├── remote.php │ ├── services.php │ ├── session.php │ ├── testing │ │ ├── cache.php │ │ ├── database.php │ │ └── session.php │ ├── view.php │ └── workbench.php ├── controllers │ ├── .gitkeep │ ├── ApiController.php │ ├── BaseController.php │ ├── HomeController.php │ ├── LessonsController.php │ └── TagsController.php ├── database │ ├── migrations │ │ ├── .gitkeep │ │ ├── 2015_02_08_233056_create_lessons_table.php │ │ ├── 2015_02_11_072054_create_tags_table.php │ │ ├── 2015_02_11_073107_create_lesson_tag_table.php │ │ └── 2015_02_11_105105_create_users_table.php │ ├── production.sqlite │ └── seeds │ │ ├── .gitkeep │ │ ├── DatabaseSeeder.php │ │ ├── LessonTagTableSeeder.php │ │ ├── LessonsTableSeeder.php │ │ ├── TagsTableSeeder.php │ │ └── UsersTableSeeder.php ├── filters.php ├── lang │ └── en │ │ ├── pagination.php │ │ ├── reminders.php │ │ └── validation.php ├── models │ ├── Lesson.php │ ├── Tag.php │ └── User.php ├── routes.php ├── start │ ├── artisan.php │ ├── global.php │ └── local.php ├── storage │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── logs │ │ └── .gitignore │ ├── meta │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── views │ │ └── .gitignore ├── tests │ ├── ApiTester.php │ ├── LessonsTest.php │ ├── TestCase.php │ └── helpers │ │ ├── ApiTester.php │ │ └── Factory.php └── views │ ├── emails │ └── auth │ │ └── reminder.blade.php │ └── hello.php ├── artisan ├── bootstrap ├── autoload.php ├── paths.php └── start.php ├── chgrp_chmod_app_storage_dir ├── composer.json ├── laravelapi.dev ├── phpunit.xml ├── public ├── .htaccess ├── favicon.ico ├── index.php ├── packages │ └── .gitkeep └── robots.txt ├── readme.md └── server.php /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bootstrap/compiled.php 2 | /vendor 3 | composer.phar 4 | composer.lock 5 | .env.*.php 6 | .env.php 7 | .DS_Store 8 | Thumbs.db 9 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Please submit all issues and pull requests to the [laravel/framework](http://github.com/laravel/framework) repository! 4 | -------------------------------------------------------------------------------- /app/Acme/Transformers/LessonTransformer.php: -------------------------------------------------------------------------------- 1 | $item['title'], 34 | 'body' => $item['body'], 35 | 'active' => (boolean)$item['some_bool'] 36 | ]; 37 | } 38 | } -------------------------------------------------------------------------------- /app/Acme/Transformers/TagTransformer.php: -------------------------------------------------------------------------------- 1 | $tag['name'] 35 | ]; 36 | } 37 | } -------------------------------------------------------------------------------- /app/Acme/Transformers/Transformer.php: -------------------------------------------------------------------------------- 1 | true, 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application URL 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This URL is used by the console to properly generate URLs when using 24 | | the Artisan command line tool. You should set this to the root of 25 | | your application so that it is used when running Artisan tasks. 26 | | 27 | */ 28 | 29 | 'url' => 'http://laravelapi.dev', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Timezone 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may specify the default timezone for your application, which 37 | | will be used by the PHP date and date-time functions. We have gone 38 | | ahead and set this to a sensible default for you out of the box. 39 | | 40 | */ 41 | 42 | 'timezone' => 'UTC', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application Locale Configuration 47 | |-------------------------------------------------------------------------- 48 | | 49 | | The application locale determines the default locale that will be used 50 | | by the translation service provider. You are free to set this value 51 | | to any of the locales which will be supported by the application. 52 | | 53 | */ 54 | 55 | 'locale' => 'en', 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Fallback Locale 60 | |-------------------------------------------------------------------------- 61 | | 62 | | The fallback locale determines the locale to use when the current one 63 | | is not available. You may change the value to correspond to any of 64 | | the language folders that are provided through your application. 65 | | 66 | */ 67 | 68 | 'fallback_locale' => 'en', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Encryption Key 73 | |-------------------------------------------------------------------------- 74 | | 75 | | This key is used by the Illuminate encrypter service and should be set 76 | | to a random, 32 character string, otherwise these encrypted strings 77 | | will not be safe. Please do this before deploying an application! 78 | | 79 | */ 80 | 81 | 'key' => '9xEshnzihphSQ0GRA8LMfXmktRKc3IqH', 82 | 83 | 'cipher' => MCRYPT_RIJNDAEL_128, 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | Autoloaded Service Providers 88 | |-------------------------------------------------------------------------- 89 | | 90 | | The service providers listed here will be automatically loaded on the 91 | | request to your application. Feel free to add your own services to 92 | | this array to grant expanded functionality to your applications. 93 | | 94 | */ 95 | 96 | 'providers' => array( 97 | 98 | 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 99 | 'Illuminate\Auth\AuthServiceProvider', 100 | 'Illuminate\Cache\CacheServiceProvider', 101 | 'Illuminate\Session\CommandsServiceProvider', 102 | 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 103 | 'Illuminate\Routing\ControllerServiceProvider', 104 | 'Illuminate\Cookie\CookieServiceProvider', 105 | 'Illuminate\Database\DatabaseServiceProvider', 106 | 'Illuminate\Encryption\EncryptionServiceProvider', 107 | 'Illuminate\Filesystem\FilesystemServiceProvider', 108 | 'Illuminate\Hashing\HashServiceProvider', 109 | 'Illuminate\Html\HtmlServiceProvider', 110 | 'Illuminate\Log\LogServiceProvider', 111 | 'Illuminate\Mail\MailServiceProvider', 112 | 'Illuminate\Database\MigrationServiceProvider', 113 | 'Illuminate\Pagination\PaginationServiceProvider', 114 | 'Illuminate\Queue\QueueServiceProvider', 115 | 'Illuminate\Redis\RedisServiceProvider', 116 | 'Illuminate\Remote\RemoteServiceProvider', 117 | 'Illuminate\Auth\Reminders\ReminderServiceProvider', 118 | 'Illuminate\Database\SeedServiceProvider', 119 | 'Illuminate\Session\SessionServiceProvider', 120 | 'Illuminate\Translation\TranslationServiceProvider', 121 | 'Illuminate\Validation\ValidationServiceProvider', 122 | 'Illuminate\View\ViewServiceProvider', 123 | 'Illuminate\Workbench\WorkbenchServiceProvider', 124 | 'Way\Generators\GeneratorsServiceProvider' 125 | 126 | ), 127 | 128 | /* 129 | |-------------------------------------------------------------------------- 130 | | Service Provider Manifest 131 | |-------------------------------------------------------------------------- 132 | | 133 | | The service provider manifest is used by Laravel to lazy load service 134 | | providers which are not needed for each request, as well to keep a 135 | | list of all of the services. Here, you may set its storage spot. 136 | | 137 | */ 138 | 139 | 'manifest' => storage_path().'/meta', 140 | 141 | /* 142 | |-------------------------------------------------------------------------- 143 | | Class Aliases 144 | |-------------------------------------------------------------------------- 145 | | 146 | | This array of class aliases will be registered when this application 147 | | is started. However, feel free to register as many as you wish as 148 | | the aliases are "lazy" loaded so they don't hinder performance. 149 | | 150 | */ 151 | 152 | 'aliases' => array( 153 | 154 | 'App' => 'Illuminate\Support\Facades\App', 155 | 'Artisan' => 'Illuminate\Support\Facades\Artisan', 156 | 'Auth' => 'Illuminate\Support\Facades\Auth', 157 | 'Blade' => 'Illuminate\Support\Facades\Blade', 158 | 'Cache' => 'Illuminate\Support\Facades\Cache', 159 | 'ClassLoader' => 'Illuminate\Support\ClassLoader', 160 | 'Config' => 'Illuminate\Support\Facades\Config', 161 | 'Controller' => 'Illuminate\Routing\Controller', 162 | 'Cookie' => 'Illuminate\Support\Facades\Cookie', 163 | 'Crypt' => 'Illuminate\Support\Facades\Crypt', 164 | 'DB' => 'Illuminate\Support\Facades\DB', 165 | 'Eloquent' => 'Illuminate\Database\Eloquent\Model', 166 | 'Event' => 'Illuminate\Support\Facades\Event', 167 | 'File' => 'Illuminate\Support\Facades\File', 168 | 'Form' => 'Illuminate\Support\Facades\Form', 169 | 'Hash' => 'Illuminate\Support\Facades\Hash', 170 | 'HTML' => 'Illuminate\Support\Facades\HTML', 171 | 'Input' => 'Illuminate\Support\Facades\Input', 172 | 'Lang' => 'Illuminate\Support\Facades\Lang', 173 | 'Log' => 'Illuminate\Support\Facades\Log', 174 | 'Mail' => 'Illuminate\Support\Facades\Mail', 175 | 'Paginator' => 'Illuminate\Support\Facades\Paginator', 176 | 'Password' => 'Illuminate\Support\Facades\Password', 177 | 'Queue' => 'Illuminate\Support\Facades\Queue', 178 | 'Redirect' => 'Illuminate\Support\Facades\Redirect', 179 | 'Redis' => 'Illuminate\Support\Facades\Redis', 180 | 'Request' => 'Illuminate\Support\Facades\Request', 181 | 'Response' => 'Illuminate\Support\Facades\Response', 182 | 'Route' => 'Illuminate\Support\Facades\Route', 183 | 'Schema' => 'Illuminate\Support\Facades\Schema', 184 | 'Seeder' => 'Illuminate\Database\Seeder', 185 | 'Session' => 'Illuminate\Support\Facades\Session', 186 | 'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait', 187 | 'SSH' => 'Illuminate\Support\Facades\SSH', 188 | 'Str' => 'Illuminate\Support\Str', 189 | 'URL' => 'Illuminate\Support\Facades\URL', 190 | 'Validator' => 'Illuminate\Support\Facades\Validator', 191 | 'View' => 'Illuminate\Support\Facades\View', 192 | 193 | ), 194 | 195 | ); 196 | -------------------------------------------------------------------------------- /app/config/auth.php: -------------------------------------------------------------------------------- 1 | 'eloquent', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Authentication Model 23 | |-------------------------------------------------------------------------- 24 | | 25 | | When using the "Eloquent" authentication driver, we need to know which 26 | | Eloquent model should be used to retrieve your users. Of course, it 27 | | is often just the "User" model but you may use whatever you like. 28 | | 29 | */ 30 | 31 | 'model' => 'User', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Authentication Table 36 | |-------------------------------------------------------------------------- 37 | | 38 | | When using the "Database" authentication driver, we need to know which 39 | | table should be used to retrieve your users. We have chosen a basic 40 | | default value but you may easily change it to any table you like. 41 | | 42 | */ 43 | 44 | 'table' => 'users', 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Password Reminder Settings 49 | |-------------------------------------------------------------------------- 50 | | 51 | | Here you may set the settings for password reminders, including a view 52 | | that should be used as your password reminder e-mail. You will also 53 | | be able to set the name of the table that holds the reset tokens. 54 | | 55 | | The "expire" time is the number of minutes that the reminder should be 56 | | considered valid. This security feature keeps tokens short-lived so 57 | | they have less time to be guessed. You may change this as needed. 58 | | 59 | */ 60 | 61 | 'reminder' => array( 62 | 63 | 'email' => 'emails.auth.reminder', 64 | 65 | 'table' => 'password_reminders', 66 | 67 | 'expire' => 60, 68 | 69 | ), 70 | 71 | ); 72 | -------------------------------------------------------------------------------- /app/config/cache.php: -------------------------------------------------------------------------------- 1 | 'file', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | File Cache Location 23 | |-------------------------------------------------------------------------- 24 | | 25 | | When using the "file" cache driver, we need a location where the cache 26 | | files may be stored. A sensible default has been specified, but you 27 | | are free to change it to any other place on disk that you desire. 28 | | 29 | */ 30 | 31 | 'path' => storage_path().'/cache', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Database Cache Connection 36 | |-------------------------------------------------------------------------- 37 | | 38 | | When using the "database" cache driver you may specify the connection 39 | | that should be used to store the cached items. When this option is 40 | | null the default database connection will be utilized for cache. 41 | | 42 | */ 43 | 44 | 'connection' => null, 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Database Cache Table 49 | |-------------------------------------------------------------------------- 50 | | 51 | | When using the "database" cache driver we need to know the table that 52 | | should be used to store the cached items. A default table name has 53 | | been provided but you're free to change it however you deem fit. 54 | | 55 | */ 56 | 57 | 'table' => 'cache', 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Memcached Servers 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Now you may specify an array of your Memcached servers that should be 65 | | used when utilizing the Memcached cache driver. All of the servers 66 | | should contain a value for "host", "port", and "weight" options. 67 | | 68 | */ 69 | 70 | 'memcached' => array( 71 | 72 | array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100), 73 | 74 | ), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Cache Key Prefix 79 | |-------------------------------------------------------------------------- 80 | | 81 | | When utilizing a RAM based store such as APC or Memcached, there might 82 | | be other applications utilizing the same cache. So, we'll specify a 83 | | value to get prefixed to all our keys so we can avoid collisions. 84 | | 85 | */ 86 | 87 | 'prefix' => 'laravel', 88 | 89 | ); 90 | -------------------------------------------------------------------------------- /app/config/compile.php: -------------------------------------------------------------------------------- 1 | PDO::FETCH_CLASS, 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Database Connection Name 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may specify which of the database connections below you wish 24 | | to use as your default connection for all database work. Of course 25 | | you may use many connections at once using the Database library. 26 | | 27 | */ 28 | 29 | 'default' => 'mysql', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Database Connections 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here are each of the database connections setup for your application. 37 | | Of course, examples of configuring each database platform that is 38 | | supported by Laravel is shown below to make development simple. 39 | | 40 | | 41 | | All database work in Laravel is done through the PHP PDO facilities 42 | | so make sure you have the driver for your particular database of 43 | | choice installed on your machine before you begin development. 44 | | 45 | */ 46 | 47 | 'connections' => array( 48 | 49 | 'sqlite' => array( 50 | 'driver' => 'sqlite', 51 | 'database' => __DIR__.'/../database/production.sqlite', 52 | 'prefix' => '', 53 | ), 54 | 55 | 'mysql' => array( 56 | 'driver' => 'mysql', 57 | 'host' => 'localhost', 58 | 'database' => 'laravelapi', 59 | 'username' => 'vagrant', 60 | 'password' => 'vagrant', 61 | 'charset' => 'utf8', 62 | 'collation' => 'utf8_unicode_ci', 63 | 'prefix' => '', 64 | ), 65 | 66 | 'pgsql' => array( 67 | 'driver' => 'pgsql', 68 | 'host' => 'localhost', 69 | 'database' => 'forge', 70 | 'username' => 'forge', 71 | 'password' => '', 72 | 'charset' => 'utf8', 73 | 'prefix' => '', 74 | 'schema' => 'public', 75 | ), 76 | 77 | 'sqlsrv' => array( 78 | 'driver' => 'sqlsrv', 79 | 'host' => 'localhost', 80 | 'database' => 'database', 81 | 'username' => 'root', 82 | 'password' => '', 83 | 'prefix' => '', 84 | ), 85 | 86 | ), 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Migration Repository Table 91 | |-------------------------------------------------------------------------- 92 | | 93 | | This table keeps track of all the migrations that have already run for 94 | | your application. Using this information, we can determine which of 95 | | the migrations on disk haven't actually been run in the database. 96 | | 97 | */ 98 | 99 | 'migrations' => 'migrations', 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Redis Databases 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Redis is an open source, fast, and advanced key-value store that also 107 | | provides a richer set of commands than a typical key-value systems 108 | | such as APC or Memcached. Laravel makes it easy to dig right in. 109 | | 110 | */ 111 | 112 | 'redis' => array( 113 | 114 | 'cluster' => false, 115 | 116 | 'default' => array( 117 | 'host' => '127.0.0.1', 118 | 'port' => 6379, 119 | 'database' => 0, 120 | ), 121 | 122 | ), 123 | 124 | ); 125 | -------------------------------------------------------------------------------- /app/config/local/app.php: -------------------------------------------------------------------------------- 1 | true, 17 | 18 | ); 19 | -------------------------------------------------------------------------------- /app/config/local/database.php: -------------------------------------------------------------------------------- 1 | array( 22 | 23 | 'mysql' => array( 24 | 'driver' => 'mysql', 25 | 'host' => 'localhost', 26 | 'database' => 'homestead', 27 | 'username' => 'homestead', 28 | 'password' => 'secret', 29 | 'charset' => 'utf8', 30 | 'collation' => 'utf8_unicode_ci', 31 | 'prefix' => '', 32 | ), 33 | 34 | 'pgsql' => array( 35 | 'driver' => 'pgsql', 36 | 'host' => 'localhost', 37 | 'database' => 'homestead', 38 | 'username' => 'homestead', 39 | 'password' => 'secret', 40 | 'charset' => 'utf8', 41 | 'prefix' => '', 42 | 'schema' => 'public', 43 | ), 44 | 45 | ), 46 | 47 | ); 48 | -------------------------------------------------------------------------------- /app/config/mail.php: -------------------------------------------------------------------------------- 1 | 'smtp', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | SMTP Host Address 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may provide the host address of the SMTP server used by your 26 | | applications. A default option is provided that is compatible with 27 | | the Mailgun mail service which will provide reliable deliveries. 28 | | 29 | */ 30 | 31 | 'host' => 'smtp.mailgun.org', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | SMTP Host Port 36 | |-------------------------------------------------------------------------- 37 | | 38 | | This is the SMTP port used by your application to deliver e-mails to 39 | | users of the application. Like the host we have set this value to 40 | | stay compatible with the Mailgun e-mail application by default. 41 | | 42 | */ 43 | 44 | 'port' => 587, 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Global "From" Address 49 | |-------------------------------------------------------------------------- 50 | | 51 | | You may wish for all e-mails sent by your application to be sent from 52 | | the same address. Here, you may specify a name and address that is 53 | | used globally for all e-mails that are sent by your application. 54 | | 55 | */ 56 | 57 | 'from' => array('address' => null, 'name' => null), 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | E-Mail Encryption Protocol 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Here you may specify the encryption protocol that should be used when 65 | | the application send e-mail messages. A sensible default using the 66 | | transport layer security protocol should provide great security. 67 | | 68 | */ 69 | 70 | 'encryption' => 'tls', 71 | 72 | /* 73 | |-------------------------------------------------------------------------- 74 | | SMTP Server Username 75 | |-------------------------------------------------------------------------- 76 | | 77 | | If your SMTP server requires a username for authentication, you should 78 | | set it here. This will get used to authenticate with your server on 79 | | connection. You may also set the "password" value below this one. 80 | | 81 | */ 82 | 83 | 'username' => null, 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | SMTP Server Password 88 | |-------------------------------------------------------------------------- 89 | | 90 | | Here you may set the password required by your SMTP server to send out 91 | | messages from your application. This will be given to the server on 92 | | connection so that the application will be able to send messages. 93 | | 94 | */ 95 | 96 | 'password' => null, 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Sendmail System Path 101 | |-------------------------------------------------------------------------- 102 | | 103 | | When using the "sendmail" driver to send e-mails, we will need to know 104 | | the path to where Sendmail lives on this server. A default path has 105 | | been provided here, which will work well on most of your systems. 106 | | 107 | */ 108 | 109 | 'sendmail' => '/usr/sbin/sendmail -bs', 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Mail "Pretend" 114 | |-------------------------------------------------------------------------- 115 | | 116 | | When this option is enabled, e-mail will not actually be sent over the 117 | | web and will instead be written to your application's logs files so 118 | | you may inspect the message. This is great for local development. 119 | | 120 | */ 121 | 122 | 'pretend' => false, 123 | 124 | ); 125 | -------------------------------------------------------------------------------- /app/config/packages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rattfieldnz/laravel-incremental-api/30d4460f04c524c07572658c22dce5f7d658ea36/app/config/packages/.gitkeep -------------------------------------------------------------------------------- /app/config/queue.php: -------------------------------------------------------------------------------- 1 | 'sync', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => array( 32 | 33 | 'sync' => array( 34 | 'driver' => 'sync', 35 | ), 36 | 37 | 'beanstalkd' => array( 38 | 'driver' => 'beanstalkd', 39 | 'host' => 'localhost', 40 | 'queue' => 'default', 41 | 'ttr' => 60, 42 | ), 43 | 44 | 'sqs' => array( 45 | 'driver' => 'sqs', 46 | 'key' => 'your-public-key', 47 | 'secret' => 'your-secret-key', 48 | 'queue' => 'your-queue-url', 49 | 'region' => 'us-east-1', 50 | ), 51 | 52 | 'iron' => array( 53 | 'driver' => 'iron', 54 | 'host' => 'mq-aws-us-east-1.iron.io', 55 | 'token' => 'your-token', 56 | 'project' => 'your-project-id', 57 | 'queue' => 'your-queue-name', 58 | 'encrypt' => true, 59 | ), 60 | 61 | 'redis' => array( 62 | 'driver' => 'redis', 63 | 'queue' => 'default', 64 | ), 65 | 66 | ), 67 | 68 | /* 69 | |-------------------------------------------------------------------------- 70 | | Failed Queue Jobs 71 | |-------------------------------------------------------------------------- 72 | | 73 | | These options configure the behavior of failed queue job logging so you 74 | | can control which database and table are used to store the jobs that 75 | | have failed. You may change them to any database / table you wish. 76 | | 77 | */ 78 | 79 | 'failed' => array( 80 | 81 | 'database' => 'mysql', 'table' => 'failed_jobs', 82 | 83 | ), 84 | 85 | ); 86 | -------------------------------------------------------------------------------- /app/config/remote.php: -------------------------------------------------------------------------------- 1 | 'production', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Remote Server Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | These are the servers that will be accessible via the SSH task runner 24 | | facilities of Laravel. This feature radically simplifies executing 25 | | tasks on your servers, such as deploying out these applications. 26 | | 27 | */ 28 | 29 | 'connections' => array( 30 | 31 | 'production' => array( 32 | 'host' => '', 33 | 'username' => '', 34 | 'password' => '', 35 | 'key' => '', 36 | 'keyphrase' => '', 37 | 'root' => '/var/www', 38 | ), 39 | 40 | ), 41 | 42 | /* 43 | |-------------------------------------------------------------------------- 44 | | Remote Server Groups 45 | |-------------------------------------------------------------------------- 46 | | 47 | | Here you may list connections under a single group name, which allows 48 | | you to easily access all of the servers at once using a short name 49 | | that is extremely easy to remember, such as "web" or "database". 50 | | 51 | */ 52 | 53 | 'groups' => array( 54 | 55 | 'web' => array('production') 56 | 57 | ), 58 | 59 | ); 60 | -------------------------------------------------------------------------------- /app/config/services.php: -------------------------------------------------------------------------------- 1 | array( 18 | 'domain' => '', 19 | 'secret' => '', 20 | ), 21 | 22 | 'mandrill' => array( 23 | 'secret' => '', 24 | ), 25 | 26 | 'stripe' => array( 27 | 'model' => 'User', 28 | 'secret' => '', 29 | ), 30 | 31 | ); 32 | -------------------------------------------------------------------------------- /app/config/session.php: -------------------------------------------------------------------------------- 1 | 'file', 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session File Location 39 | |-------------------------------------------------------------------------- 40 | | 41 | | When using the native session driver, we need a location where session 42 | | files may be stored. A default has been set for you but a different 43 | | location may be specified. This is only needed for file sessions. 44 | | 45 | */ 46 | 47 | 'files' => storage_path().'/sessions', 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session Database Connection 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the "database" or "redis" session drivers, you may specify a 55 | | connection that should be used to manage these sessions. This should 56 | | correspond to a connection in your database configuration options. 57 | | 58 | */ 59 | 60 | 'connection' => null, 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Table 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" session driver, you may specify the table we 68 | | should use to manage the sessions. Of course, a sensible default is 69 | | provided for you; however, you are free to change this as needed. 70 | | 71 | */ 72 | 73 | 'table' => 'sessions', 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Sweeping Lottery 78 | |-------------------------------------------------------------------------- 79 | | 80 | | Some session drivers must manually sweep their storage location to get 81 | | rid of old sessions from storage. Here are the chances that it will 82 | | happen on a given request. By default, the odds are 2 out of 100. 83 | | 84 | */ 85 | 86 | 'lottery' => array(2, 100), 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Cookie Name 91 | |-------------------------------------------------------------------------- 92 | | 93 | | Here you may change the name of the cookie used to identify a session 94 | | instance by ID. The name specified here will get used every time a 95 | | new session cookie is created by the framework for every driver. 96 | | 97 | */ 98 | 99 | 'cookie' => 'laravel_session', 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Cookie Path 104 | |-------------------------------------------------------------------------- 105 | | 106 | | The session cookie path determines the path for which the cookie will 107 | | be regarded as available. Typically, this will be the root path of 108 | | your application but you are free to change this when necessary. 109 | | 110 | */ 111 | 112 | 'path' => '/', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Domain 117 | |-------------------------------------------------------------------------- 118 | | 119 | | Here you may change the domain of the cookie used to identify a session 120 | | in your application. This will determine which domains the cookie is 121 | | available to in your application. A sensible default has been set. 122 | | 123 | */ 124 | 125 | 'domain' => null, 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | HTTPS Only Cookies 130 | |-------------------------------------------------------------------------- 131 | | 132 | | By setting this option to true, session cookies will only be sent back 133 | | to the server if the browser has a HTTPS connection. This will keep 134 | | the cookie from being sent to you if it can not be done securely. 135 | | 136 | */ 137 | 138 | 'secure' => false, 139 | 140 | ); 141 | -------------------------------------------------------------------------------- /app/config/testing/cache.php: -------------------------------------------------------------------------------- 1 | 'array', 19 | 20 | ); 21 | -------------------------------------------------------------------------------- /app/config/testing/database.php: -------------------------------------------------------------------------------- 1 | PDO::FETCH_CLASS, 6 | 7 | 'default' => 'sqlite', 8 | 9 | 'connections' => array( 10 | 11 | 'sqlite' => array( 12 | 'driver' => 'sqlite', 13 | 'database' => ':memory:', 14 | 'prefix' => '', 15 | ) 16 | ) 17 | 18 | ); 19 | -------------------------------------------------------------------------------- /app/config/testing/session.php: -------------------------------------------------------------------------------- 1 | 'array', 20 | 21 | ); 22 | -------------------------------------------------------------------------------- /app/config/view.php: -------------------------------------------------------------------------------- 1 | array(__DIR__.'/../views'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Pagination View 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This view will be used to render the pagination link output, and can 24 | | be easily customized here to show any view you like. A clean view 25 | | compatible with Twitter's Bootstrap is given to you by default. 26 | | 27 | */ 28 | 29 | 'pagination' => 'pagination::slider-3', 30 | 31 | ); 32 | -------------------------------------------------------------------------------- /app/config/workbench.php: -------------------------------------------------------------------------------- 1 | '', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Workbench Author E-Mail Address 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Like the option above, your e-mail address is used when generating new 24 | | workbench packages. The e-mail is placed in your composer.json file 25 | | automatically after the package is created by the workbench tool. 26 | | 27 | */ 28 | 29 | 'email' => '', 30 | 31 | ); 32 | -------------------------------------------------------------------------------- /app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rattfieldnz/laravel-incremental-api/30d4460f04c524c07572658c22dce5f7d658ea36/app/controllers/.gitkeep -------------------------------------------------------------------------------- /app/controllers/ApiController.php: -------------------------------------------------------------------------------- 1 | statusCode; 30 | } 31 | 32 | /** 33 | * Setter method to set status code. 34 | * It is returning current object 35 | * for chaining purposes. 36 | * 37 | * @param mixed $statusCode 38 | * @return current object. 39 | */ 40 | public function setStatusCode($statusCode) 41 | { 42 | $this->statusCode = $statusCode; 43 | 44 | return $this; 45 | } 46 | 47 | /** 48 | * Function to return an unauthorized response. 49 | * 50 | * @param string $message 51 | * @return mixed 52 | */ 53 | public function respondUnauthorizedError($message = 'Unauthorized!') 54 | { 55 | return $this->setStatusCode(IlluminateResponse::HTTP_UNAUTHORIZED)->respondWithError($message); 56 | } 57 | 58 | /** 59 | * Function to return forbidden error response. 60 | * @param string $message 61 | * @return mixed 62 | */ 63 | public function respondForbiddenError($message = 'Forbidden!') 64 | { 65 | return $this->setStatusCode(IlluminateResponse::HTTP_FORBIDDEN)->respondWithError($message); 66 | } 67 | 68 | /** 69 | * Function to return a Not Found response. 70 | * 71 | * @param string $message 72 | * @return mixed 73 | */ 74 | public function respondNotFound($message = 'Not Found') 75 | { 76 | return $this->setStatusCode(IlluminateResponse::HTTP_NOT_FOUND)->respondWithError($message); 77 | } 78 | 79 | /** 80 | * Function to return an internal error response. 81 | * 82 | * @param string $message 83 | * @return mixed 84 | */ 85 | public function respondInternalError($message = 'Internal Error!') 86 | { 87 | return $this->setStatusCode(IlluminateResponse::HTTP_INTERNAL_SERVER_ERROR)->respondWithError($message); 88 | } 89 | 90 | 91 | /** 92 | * Function to return a service unavailable response. 93 | * 94 | * @param string $message 95 | * @return mixed 96 | */ 97 | public function respondServiceUnavailable($message = "Service Unavailable!") 98 | { 99 | return $this->setStatusCode(IlluminateResponse::HTTP_SERVICE_UNAVAILABLE)->respondWithError($message); 100 | } 101 | 102 | 103 | /** 104 | * Function to return a generic response. 105 | * 106 | * @param $data Data to be used in response. 107 | * @param array $headers Headers to b used in response. 108 | * @return mixed Return the response. 109 | */ 110 | public function respond($data, $headers = []) 111 | { 112 | return Response::json($data, $this->getStatusCode(), $headers); 113 | } 114 | 115 | 116 | /** 117 | * Function to return an error response. 118 | * 119 | * @param $message 120 | * @return mixed 121 | */ 122 | public function respondWithError($message) 123 | { 124 | return $this->respond([ 125 | 'error' => [ 126 | 'message' => $message, 127 | 'status_code' => $this->getStatusCode() 128 | ] 129 | ]); 130 | } 131 | 132 | 133 | /** 134 | * @param $message 135 | * @return mixed 136 | */ 137 | protected function respondCreated($message) 138 | { 139 | return $this->setStatusCode(IlluminateResponse::HTTP_CREATED) 140 | ->respond([ 141 | 'message' => $message 142 | ]); 143 | } 144 | 145 | 146 | /** 147 | * @param $message 148 | * @return mixed 149 | */ 150 | protected function respondUnprocessableEntity($message) 151 | { 152 | return $this->setStatusCode(IlluminateResponse::HTTP_UNPROCESSABLE_ENTITY) 153 | ->respond([ 154 | 'message' => $message 155 | ]); 156 | } 157 | 158 | /** 159 | * @param Paginator $lessons 160 | * @param $data 161 | * @return mixed 162 | */ 163 | protected function respondWithPagination(Paginator $lessons, $data) 164 | { 165 | 166 | $data = array_merge($data, [ 167 | 'paginator' => [ 168 | 'total_count' => $lessons->getTotal(), 169 | 'total_pages' => ceil($lessons->getTotal() / $lessons->getPerPage()), 170 | 'current_page' => $lessons->getCurrentPage(), 171 | 'limit' => $lessons->getPerPage() 172 | ] 173 | ]); 174 | 175 | return $this->respond($data); 176 | } 177 | } -------------------------------------------------------------------------------- /app/controllers/BaseController.php: -------------------------------------------------------------------------------- 1 | layout)) 13 | { 14 | $this->layout = View::make($this->layout); 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | lessonTransformer = $lessonTransformer; 15 | 16 | $this->beforeFilter('auth.basic', ['on' => 'post']); 17 | } 18 | 19 | 20 | /** 21 | * Display a listing of the resource. 22 | * 23 | * @return Response 24 | */ 25 | public function index() 26 | { 27 | $limit = Input::get('limit') ?: 3; 28 | $lessons = Lesson::paginate($limit); 29 | 30 | return $this->respondWithPagination($lessons, [ 31 | 'data' => $this->lessonTransformer->transformCollection($lessons->all()) 32 | ]); 33 | } 34 | 35 | 36 | /** 37 | * Show the form for creating a new resource. 38 | * 39 | * @return Response 40 | */ 41 | public function create() 42 | { 43 | // 44 | } 45 | 46 | 47 | /** 48 | * Store a newly created resource in storage. 49 | * 50 | * @return Response 51 | */ 52 | public function store() 53 | { 54 | if(!Input::get('title') or !Input::get('body')) 55 | { 56 | return $this->respondUnprocessableEntity('Parameters failed validation for a lesson.'); 57 | } 58 | 59 | Lesson::create(Input::all()); 60 | 61 | return $this->respondCreated('Lesson successfully created.'); 62 | } 63 | 64 | 65 | /** 66 | * Display the specified resource. 67 | * 68 | * @param int $id 69 | * @return Response 70 | */ 71 | public function show($id) 72 | { 73 | $lesson = Lesson::find($id); 74 | 75 | if(!$lesson) 76 | { 77 | return $this->respondNotFound('Lesson does not exist.'); 78 | } 79 | 80 | return $this->respond([ 81 | 'data' => $this->lessonTransformer->transform($lesson) 82 | ]); 83 | } 84 | 85 | 86 | /** 87 | * Show the form for editing the specified resource. 88 | * 89 | * @param int $id 90 | * @return Response 91 | */ 92 | public function edit($id) 93 | { 94 | // 95 | } 96 | 97 | 98 | /** 99 | * Update the specified resource in storage. 100 | * 101 | * @param int $id 102 | * @return Response 103 | */ 104 | public function update($id) 105 | { 106 | // 107 | } 108 | 109 | 110 | /** 111 | * Remove the specified resource from storage. 112 | * 113 | * @param int $id 114 | * @return Response 115 | */ 116 | public function destroy($id) 117 | { 118 | // 119 | } 120 | 121 | 122 | } 123 | -------------------------------------------------------------------------------- /app/controllers/TagsController.php: -------------------------------------------------------------------------------- 1 | tagTransformer = $tagTransformer; 12 | } 13 | 14 | /** 15 | * Display a listing of the resource. 16 | * 17 | * @param $lessonId 18 | * @return mixed 19 | */ 20 | public function index($lessonId = null) 21 | { 22 | return $this->getTags($lessonId); 23 | } 24 | 25 | /** 26 | * @param $lessonId 27 | * @return mixed 28 | */ 29 | public function getTags($lessonId) 30 | { 31 | $tags = $lessonId ? Lesson::findOrFail($lessonId)->tags : Tag::all(); 32 | 33 | return $this->respond([ 34 | 'data' => $this->tagTransformer->transformCollection($tags->all()) 35 | ]); 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /app/database/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rattfieldnz/laravel-incremental-api/30d4460f04c524c07572658c22dce5f7d658ea36/app/database/migrations/.gitkeep -------------------------------------------------------------------------------- /app/database/migrations/2015_02_08_233056_create_lessons_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('title'); 19 | $table->text('body'); 20 | $table->boolean('some_bool'); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::drop('lessons'); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/database/migrations/2015_02_11_072054_create_tags_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::drop('tags'); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/database/migrations/2015_02_11_073107_create_lesson_tag_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('lesson_id')->unsigned()->index(); 19 | $table->foreign('lesson_id')->references('id')->on('lessons')->onDelete('cascade'); 20 | $table->integer('tag_id')->unsigned()->index(); 21 | $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); 22 | }); 23 | } 24 | 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::drop('lesson_tag'); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/database/migrations/2015_02_11_105105_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('email'); 19 | $table->text('password'); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('users'); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/database/production.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rattfieldnz/laravel-incremental-api/30d4460f04c524c07572658c22dce5f7d658ea36/app/database/production.sqlite -------------------------------------------------------------------------------- /app/database/seeds/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rattfieldnz/laravel-incremental-api/30d4460f04c524c07572658c22dce5f7d658ea36/app/database/seeds/.gitkeep -------------------------------------------------------------------------------- /app/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | cleanDatabase(); 23 | 24 | Eloquent::unguard(); 25 | 26 | $this->call('LessonsTableSeeder'); 27 | $this->call('TagsTableSeeder'); 28 | $this->call('LessonTagTableSeeder'); 29 | $this->call('UsersTableSeeder'); 30 | } 31 | 32 | private function cleanDatabase() 33 | { 34 | DB::statement('SET FOREIGN_KEY_CHECKS=0'); 35 | 36 | foreach($this->tables as $tableName) 37 | { 38 | DB::table($tableName)->truncate(); 39 | } 40 | DB::statement('SET FOREIGN_KEY_CHECKS=1'); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/database/seeds/LessonTagTableSeeder.php: -------------------------------------------------------------------------------- 1 | insert([ 18 | 'lesson_id' => $faker->randomElement($lessonIds), 19 | 'tag_id' => $faker->randomElement($tagIds) 20 | 21 | ]); 22 | } 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /app/database/seeds/LessonsTableSeeder.php: -------------------------------------------------------------------------------- 1 | $faker->sentence(5), 16 | 'body' => $faker->paragraph(4), 17 | 'some_bool' => $faker->boolean() 18 | 19 | ]); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/database/seeds/TagsTableSeeder.php: -------------------------------------------------------------------------------- 1 | insert([ 21 | 'name' => $faker->word 22 | 23 | ]); 24 | } 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /app/database/seeds/UsersTableSeeder.php: -------------------------------------------------------------------------------- 1 | 'example@laravelapi.dev', 16 | 'password' => Hash::make('vagrant') 17 | 18 | ]); 19 | //} 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/filters.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 18 | 'next' => 'Next »', 19 | 20 | ); 21 | -------------------------------------------------------------------------------- /app/lang/en/reminders.php: -------------------------------------------------------------------------------- 1 | "Passwords must be at least six characters and match the confirmation.", 17 | 18 | "user" => "We can't find a user with that e-mail address.", 19 | 20 | "token" => "This password reset token is invalid.", 21 | 22 | "sent" => "Password reminder sent!", 23 | 24 | ); 25 | -------------------------------------------------------------------------------- /app/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | "The :attribute must be accepted.", 17 | "active_url" => "The :attribute is not a valid URL.", 18 | "after" => "The :attribute must be a date after :date.", 19 | "alpha" => "The :attribute may only contain letters.", 20 | "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.", 21 | "alpha_num" => "The :attribute may only contain letters and numbers.", 22 | "array" => "The :attribute must be an array.", 23 | "before" => "The :attribute must be a date before :date.", 24 | "between" => array( 25 | "numeric" => "The :attribute must be between :min and :max.", 26 | "file" => "The :attribute must be between :min and :max kilobytes.", 27 | "string" => "The :attribute must be between :min and :max characters.", 28 | "array" => "The :attribute must have between :min and :max items.", 29 | ), 30 | "confirmed" => "The :attribute confirmation does not match.", 31 | "date" => "The :attribute is not a valid date.", 32 | "date_format" => "The :attribute does not match the format :format.", 33 | "different" => "The :attribute and :other must be different.", 34 | "digits" => "The :attribute must be :digits digits.", 35 | "digits_between" => "The :attribute must be between :min and :max digits.", 36 | "email" => "The :attribute must be a valid email address.", 37 | "exists" => "The selected :attribute is invalid.", 38 | "image" => "The :attribute must be an image.", 39 | "in" => "The selected :attribute is invalid.", 40 | "integer" => "The :attribute must be an integer.", 41 | "ip" => "The :attribute must be a valid IP address.", 42 | "max" => array( 43 | "numeric" => "The :attribute may not be greater than :max.", 44 | "file" => "The :attribute may not be greater than :max kilobytes.", 45 | "string" => "The :attribute may not be greater than :max characters.", 46 | "array" => "The :attribute may not have more than :max items.", 47 | ), 48 | "mimes" => "The :attribute must be a file of type: :values.", 49 | "min" => array( 50 | "numeric" => "The :attribute must be at least :min.", 51 | "file" => "The :attribute must be at least :min kilobytes.", 52 | "string" => "The :attribute must be at least :min characters.", 53 | "array" => "The :attribute must have at least :min items.", 54 | ), 55 | "not_in" => "The selected :attribute is invalid.", 56 | "numeric" => "The :attribute must be a number.", 57 | "regex" => "The :attribute format is invalid.", 58 | "required" => "The :attribute field is required.", 59 | "required_if" => "The :attribute field is required when :other is :value.", 60 | "required_with" => "The :attribute field is required when :values is present.", 61 | "required_with_all" => "The :attribute field is required when :values is present.", 62 | "required_without" => "The :attribute field is required when :values is not present.", 63 | "required_without_all" => "The :attribute field is required when none of :values are present.", 64 | "same" => "The :attribute and :other must match.", 65 | "size" => array( 66 | "numeric" => "The :attribute must be :size.", 67 | "file" => "The :attribute must be :size kilobytes.", 68 | "string" => "The :attribute must be :size characters.", 69 | "array" => "The :attribute must contain :size items.", 70 | ), 71 | "unique" => "The :attribute has already been taken.", 72 | "url" => "The :attribute format is invalid.", 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Custom Validation Language Lines 77 | |-------------------------------------------------------------------------- 78 | | 79 | | Here you may specify custom validation messages for attributes using the 80 | | convention "attribute.rule" to name the lines. This makes it quick to 81 | | specify a specific custom language line for a given attribute rule. 82 | | 83 | */ 84 | 85 | 'custom' => array( 86 | 'attribute-name' => array( 87 | 'rule-name' => 'custom-message', 88 | ), 89 | ), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Custom Validation Attributes 94 | |-------------------------------------------------------------------------- 95 | | 96 | | The following language lines are used to swap attribute place-holders 97 | | with something more reader friendly such as E-Mail Address instead 98 | | of "email". This simply helps us make messages a little cleaner. 99 | | 100 | */ 101 | 102 | 'attributes' => array(), 103 | 104 | ); 105 | -------------------------------------------------------------------------------- /app/models/Lesson.php: -------------------------------------------------------------------------------- 1 | belongsToMany('Tag'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/models/Tag.php: -------------------------------------------------------------------------------- 1 | 'api/v1'], function() 14 | { 15 | Route::get('lessons/{id}/tags', 'TagsController@index'); 16 | Route::resource('lessons', 'LessonsController'); 17 | Route::resource('tags', 'TagsController', ['only' => ['index', 'show']]); 18 | }); 19 | -------------------------------------------------------------------------------- /app/start/artisan.php: -------------------------------------------------------------------------------- 1 | ['message' => 'Resource not found']], 404); 57 | }); 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Maintenance Mode Handler 62 | |-------------------------------------------------------------------------- 63 | | 64 | | The "down" Artisan command gives you the ability to put an application 65 | | into maintenance mode. Here, you will define what is displayed back 66 | | to the user if maintenance mode is in effect for the application. 67 | | 68 | */ 69 | 70 | App::down(function() 71 | { 72 | return Response::make("Be right back!", 503); 73 | }); 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Require The Filters File 78 | |-------------------------------------------------------------------------- 79 | | 80 | | Next we will load the filters file for the application. This gives us 81 | | a nice separate location to store our route and application filter 82 | | definitions instead of putting them all in the main routes file. 83 | | 84 | */ 85 | 86 | require app_path().'/filters.php'; 87 | -------------------------------------------------------------------------------- /app/start/local.php: -------------------------------------------------------------------------------- 1 | fake = Faker::create(); 26 | } 27 | 28 | 29 | /** 30 | * 31 | */ 32 | public function setUp() 33 | { 34 | parent::setUp(); 35 | 36 | $this->app['artisan']->call('migrate'); 37 | } 38 | 39 | /** 40 | * @param array $lessonFields 41 | */ 42 | protected function makeLesson($lessonFields = []) 43 | { 44 | $lesson = array_merge([ 45 | 'title' => $this->fake->sentence, 46 | 'body' => $this->fake->paragraph, 47 | 'some_bool' => $this->fake->boolean 48 | ], $lessonFields); 49 | 50 | while ($this->times--) { 51 | Lesson::create($lesson); 52 | } 53 | } 54 | 55 | /** 56 | * @param $count 57 | * @return $this 58 | */ 59 | protected function times($count) 60 | { 61 | $this->times = $count; 62 | 63 | return $this; 64 | } 65 | 66 | /** 67 | * @param $uri 68 | * @return mixed 69 | */ 70 | protected function getJson($uri) 71 | { 72 | return json_decode($this->call('GET', $uri)->getContent()); 73 | } 74 | 75 | /** 76 | * 77 | */ 78 | protected function assertObjectHasAttributes() 79 | { 80 | $args = func_get_args(); 81 | $object = array_shift($args); 82 | 83 | foreach ($args as $attribute) { 84 | $this->assertObjectHasAttribute($attribute, $object); 85 | } 86 | } 87 | 88 | /** 89 | * @param $type 90 | * @param array $fields 91 | */ 92 | protected function make($type, array $fields = []) 93 | { 94 | while($this->times--) 95 | { 96 | $stub = array_merge($this->getStub(), $fields); 97 | $type::create($stub); 98 | } 99 | } 100 | 101 | 102 | /** 103 | * 104 | */ 105 | protected function getStub() 106 | { 107 | throw new BadMethodCallException('Create your own getStub method to declare your fields.'); 108 | } 109 | 110 | 111 | } -------------------------------------------------------------------------------- /app/tests/LessonsTest.php: -------------------------------------------------------------------------------- 1 | times(5)->make('Lesson'); 18 | 19 | //act 20 | $this->getJson('api/v1/lessons/'); 21 | 22 | //assert 23 | $this->assertResponseOk(); 24 | 25 | } 26 | 27 | /** 28 | * @test 29 | */ 30 | public function it_fetches_a_single_lesson() 31 | { 32 | $this->make('Lesson'); 33 | 34 | $lesson = $this->getJson('api/v1/lessons/1')->data; 35 | 36 | $this->assertResponseOk(); 37 | 38 | $this->assertObjectHasAttributes($lesson, 'title', 'body', 'active'); 39 | 40 | 41 | } 42 | 43 | /** 44 | * @test 45 | */ 46 | public function it_404s_if_a_lesson_is_not_found() 47 | { 48 | $this->getJson('api/v1/lessons/x'); 49 | 50 | $this->assertResponseStatus(404); 51 | } 52 | 53 | /** 54 | * @test 55 | */ 56 | public function it_creates_a_new_lesson_given_valid_parameters() 57 | { 58 | $this->getJson('api/v1/lessons', 'POST', $this->getStub()); 59 | 60 | $this->assertResponseStatus(201); 61 | } 62 | 63 | /** 64 | * @test 65 | */ 66 | public function it_throws_a_422_if_a_new_lesson_request_fails_validation() 67 | { 68 | $this->getJson('api/v1/lessons', 'POST'); 69 | 70 | $this->assertResponseStatus(422); 71 | } 72 | 73 | public function getStub() 74 | { 75 | return [ 76 | 'title' => $this->fake->sentence, 77 | 'body' => $this->fake->paragraph, 78 | 'some_bool' => $this->fake->boolean 79 | ]; 80 | } 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /app/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | fake = Faker::create(); 21 | } 22 | 23 | 24 | /** 25 | * 26 | */ 27 | public function setUp() 28 | { 29 | parent::setUp(); 30 | 31 | $this->app['artisan']->call('migrate'); 32 | } 33 | 34 | /** 35 | * @param array $lessonFields 36 | */ 37 | protected function makeLesson($lessonFields = []) 38 | { 39 | $lesson = array_merge([ 40 | 'title' => $this->fake->sentence, 41 | 'body' => $this->fake->paragraph, 42 | 'some_bool' => $this->fake->boolean 43 | ], $lessonFields); 44 | 45 | while ($this->times--) { 46 | Lesson::create($lesson); 47 | } 48 | } 49 | 50 | 51 | /** 52 | * @param $uri 53 | * @param string $method 54 | * @param array $parameters 55 | * @return mixed 56 | */ 57 | protected function getJson($uri, $method = 'GET', $parameters = []) 58 | { 59 | return json_decode($this->call($method, $uri, $parameters)->getContent()); 60 | } 61 | 62 | /** 63 | * 64 | */ 65 | protected function assertObjectHasAttributes() 66 | { 67 | $args = func_get_args(); 68 | $object = array_shift($args); 69 | 70 | foreach ($args as $attribute) { 71 | $this->assertObjectHasAttribute($attribute, $object); 72 | } 73 | } 74 | 75 | 76 | } -------------------------------------------------------------------------------- /app/tests/helpers/Factory.php: -------------------------------------------------------------------------------- 1 | times = $count; 23 | 24 | return $this; 25 | } 26 | 27 | /** 28 | * @param $type 29 | * @param array $fields 30 | */ 31 | protected function make($type, array $fields = []) 32 | { 33 | while($this->times--) 34 | { 35 | $stub = array_merge($this->getStub(), $fields); 36 | $type::create($stub); 37 | } 38 | } 39 | 40 | /** 41 | * 42 | */ 43 | protected function getStub() 44 | { 45 | throw new BadMethodCallException('Create your own getStub method to declare your fields.'); 46 | } 47 | } -------------------------------------------------------------------------------- /app/views/emails/auth/reminder.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Password Reset

8 | 9 |
10 | To reset your password, complete this form: {{ URL::to('password/reset', array($token)) }}.
11 | This link will expire in {{ Config::get('auth.reminder.expire', 60) }} minutes. 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /app/views/hello.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Laravel PHP Framework 6 | 35 | 36 | 37 |
38 | Laravel PHP Framework 39 |

You have arrived.

40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | setRequestForConsoleEnvironment(); 45 | 46 | $artisan = Illuminate\Console\Application::start($app); 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Run The Artisan Application 51 | |-------------------------------------------------------------------------- 52 | | 53 | | When we run the console application, the current CLI command will be 54 | | executed in this console and the response sent back to a terminal 55 | | or another output device for the developers. Here goes nothing! 56 | | 57 | */ 58 | 59 | $status = $artisan->run(); 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Shutdown The Application 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Once Artisan has finished running. We will fire off the shutdown events 67 | | so that any final work may be done by the application before we shut 68 | | down the process. This is the last thing to happen to the request. 69 | | 70 | */ 71 | 72 | $app->shutdown(); 73 | 74 | exit($status); 75 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | __DIR__.'/../app', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Public Path 21 | |-------------------------------------------------------------------------- 22 | | 23 | | The public path contains the assets for your web application, such as 24 | | your JavaScript and CSS files, and also contains the primary entry 25 | | point for web requests into these applications from the outside. 26 | | 27 | */ 28 | 29 | 'public' => __DIR__.'/../public', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Base Path 34 | |-------------------------------------------------------------------------- 35 | | 36 | | The base path is the root of the Laravel installation. Most likely you 37 | | will not need to change this value. But, if for some wild reason it 38 | | is necessary you will do so here, just proceed with some caution. 39 | | 40 | */ 41 | 42 | 'base' => __DIR__.'/..', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Storage Path 47 | |-------------------------------------------------------------------------- 48 | | 49 | | The storage path is used by Laravel to store cached Blade views, logs 50 | | and other pieces of information. You may modify the path here when 51 | | you want to change the location of this directory for your apps. 52 | | 53 | */ 54 | 55 | 'storage' => __DIR__.'/../app/storage', 56 | 57 | ); 58 | -------------------------------------------------------------------------------- /bootstrap/start.php: -------------------------------------------------------------------------------- 1 | detectEnvironment(array( 28 | 29 | 'local' => array('homestead'), 30 | 31 | )); 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Bind Paths 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here we are binding the paths configured in paths.php to the app. You 39 | | should not be changing these here. If you need to change these you 40 | | may do so within the paths.php file and they will be bound here. 41 | | 42 | */ 43 | 44 | $app->bindInstallPaths(require __DIR__.'/paths.php'); 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Load The Application 49 | |-------------------------------------------------------------------------- 50 | | 51 | | Here we will load this Illuminate application. We will keep this in a 52 | | separate location so we can isolate the creation of an application 53 | | from the actual running of the application with a given request. 54 | | 55 | */ 56 | 57 | $framework = $app['path.base']. 58 | '/vendor/laravel/framework/src'; 59 | 60 | require $framework.'/Illuminate/Foundation/start.php'; 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Return The Application 65 | |-------------------------------------------------------------------------- 66 | | 67 | | This script returns the application instance. The instance is given to 68 | | the calling script so we can separate the building of the instances 69 | | from the actual running of the application and sending responses. 70 | | 71 | */ 72 | 73 | return $app; 74 | -------------------------------------------------------------------------------- /chgrp_chmod_app_storage_dir: -------------------------------------------------------------------------------- 1 | chgrp -R www-data app/storage 2 | chmod -R 775 app/storage 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "require": { 7 | "laravel/framework": "4.2.*", 8 | "way/generators": "2.*" 9 | }, 10 | "autoload": { 11 | "classmap": [ 12 | "app/commands", 13 | "app/controllers", 14 | "app/models", 15 | "app/database/migrations", 16 | "app/database/seeds", 17 | "app/tests/TestCase.php", 18 | "app/tests/helpers" 19 | ], 20 | "psr-4": { 21 | "Acme\\": "app/Acme" 22 | } 23 | }, 24 | "scripts": { 25 | "post-install-cmd": [ 26 | "php artisan clear-compiled", 27 | "php artisan optimize" 28 | ], 29 | "post-update-cmd": [ 30 | "php artisan clear-compiled", 31 | "php artisan optimize" 32 | ], 33 | "post-create-project-cmd": [ 34 | "php artisan key:generate" 35 | ] 36 | }, 37 | "config": { 38 | "preferred-install": "dist" 39 | }, 40 | "minimum-stability": "stable", 41 | "require-dev": { 42 | "fzaninotto/faker": "~1.4", 43 | "phpunit/phpunit": "4.5.*" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /laravelapi.dev: -------------------------------------------------------------------------------- 1 | 2 | ServerName laravelapi.dev 3 | ServerAdmin webmaster@localhost 4 | 5 | DocumentRoot /var/www/laravelapi/public 6 | 7 | Options Indexes FollowSymLinks MultiViews 8 | AllowOverride All 9 | Order allow,deny 10 | allow from all 11 | 12 | 13 | ErrorLog ${APACHE_LOG_DIR}/error.log 14 | 15 | # Possible values include: debug, info, notice, warn, error, crit, 16 | # alert, emerg. 17 | LogLevel warn 18 | 19 | CustomLog ${APACHE_LOG_DIR}/access.log combined 20 | 21 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./app/tests/ 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes... 9 | RewriteRule ^(.*)/$ /$1 [L,R=301] 10 | 11 | # Handle Front Controller... 12 | RewriteCond %{REQUEST_FILENAME} !-d 13 | RewriteCond %{REQUEST_FILENAME} !-f 14 | RewriteRule ^ index.php [L] 15 | 16 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rattfieldnz/laravel-incremental-api/30d4460f04c524c07572658c22dce5f7d658ea36/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | /* 10 | |-------------------------------------------------------------------------- 11 | | Register The Auto Loader 12 | |-------------------------------------------------------------------------- 13 | | 14 | | Composer provides a convenient, automatically generated class loader 15 | | for our application. We just need to utilize it! We'll require it 16 | | into the script here so that we do not have to worry about the 17 | | loading of any our classes "manually". Feels great to relax. 18 | | 19 | */ 20 | 21 | require __DIR__.'/../bootstrap/autoload.php'; 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Turn On The Lights 26 | |-------------------------------------------------------------------------- 27 | | 28 | | We need to illuminate PHP development, so let's turn on the lights. 29 | | This bootstraps the framework and gets it ready for use, then it 30 | | will load up this application so that we can run it and send 31 | | the responses back to the browser and delight these users. 32 | | 33 | */ 34 | 35 | $app = require_once __DIR__.'/../bootstrap/start.php'; 36 | 37 | /* 38 | |-------------------------------------------------------------------------- 39 | | Run The Application 40 | |-------------------------------------------------------------------------- 41 | | 42 | | Once we have the application, we can simply call the run method, 43 | | which will execute the request and send the response back to 44 | | the client's browser allowing them to enjoy the creative 45 | | and wonderful application we have whipped up for them. 46 | | 47 | */ 48 | 49 | $app->run(); 50 | -------------------------------------------------------------------------------- /public/packages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rattfieldnz/laravel-incremental-api/30d4460f04c524c07572658c22dce5f7d658ea36/public/packages/.gitkeep -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # laravel-incremental-api 2 | This is my repository for the Laracasts series @ https://laracasts.com/series/incremental-api-development. 3 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 |