├── .gitattributes ├── .gitignore ├── CONTRIBUTING.md ├── app ├── commands │ └── .gitkeep ├── config │ ├── app.php │ ├── auth.php │ ├── cache.php │ ├── compile.php │ ├── database.php │ ├── local │ │ ├── app.php │ │ └── database.php │ ├── mail.php │ ├── packages │ │ ├── .gitkeep │ │ └── cartalyst │ │ │ └── sentinel │ │ │ └── config.php │ ├── queue.php │ ├── remote.php │ ├── services.php │ ├── session.php │ ├── testing │ │ ├── cache.php │ │ └── session.php │ ├── view.php │ └── workbench.php ├── controllers │ ├── .gitkeep │ ├── ApiController.php │ ├── AuthController.php │ ├── BaseController.php │ ├── HomeController.php │ ├── PlacesAdminController.php │ └── PlacesApiController.php ├── database │ ├── migrations │ │ ├── .gitkeep │ │ ├── 2014_01_04_221638_MigrationInstallPlaces.php │ │ └── 2014_01_04_223547_MigrationInstallCheckins.php │ ├── production.sqlite │ └── seeds │ │ ├── .gitkeep │ │ ├── CheckinTableSeeder.php │ │ ├── DatabaseSeeder.php │ │ ├── PlaceTableSeeder.php │ │ ├── RoleTableSeeder.php │ │ └── UserTableSeeder.php ├── filters.php ├── lang │ └── en │ │ ├── pagination.php │ │ ├── reminders.php │ │ └── validation.php ├── models │ ├── Checkin.php │ ├── Place.php │ ├── Role.php │ └── User.php ├── routes.php ├── src │ └── App │ │ └── Transformers │ │ ├── CheckinTransformer.php │ │ ├── PlaceTransformer.php │ │ └── UserTransformer.php ├── start │ ├── artisan.php │ ├── global.php │ └── local.php ├── storage │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── logs │ │ └── .gitignore │ ├── meta │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── views │ │ └── .gitignore ├── tests │ ├── ExampleTest.php │ └── TestCase.php └── views │ ├── auth │ └── login.blade.php │ ├── cheatsheet.blade.php │ ├── emails │ └── auth │ │ └── reminder.blade.php │ ├── partials │ └── notifications.blade.php │ ├── places │ ├── edit.blade.php │ └── index.blade.php │ ├── template.blade.php │ └── welcome.blade.php ├── artisan ├── bootstrap ├── autoload.php ├── paths.php └── start.php ├── composer.json ├── composer.lock ├── license.txt ├── phpunit.xml ├── public ├── .htaccess ├── assets │ ├── css │ │ └── bootstrap.min.css │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ └── js │ │ ├── bootstrap.min.js │ │ └── jquery.min.js ├── 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 | .env.*.php 5 | .env.php 6 | .DS_Store 7 | Thumbs.db 8 | -------------------------------------------------------------------------------- /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/commands/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/app/commands/.gitkeep -------------------------------------------------------------------------------- /app/config/app.php: -------------------------------------------------------------------------------- 1 | false, 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://localhost', 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' => 'YourSecretKey!!!', 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 | 125 | 'Cartalyst\Sentinel\Laravel\SentinelServiceProvider', 126 | 'Cartalyst\Api\Laravel\ApiServiceProvider', 127 | 128 | ), 129 | 130 | /* 131 | |-------------------------------------------------------------------------- 132 | | Service Provider Manifest 133 | |-------------------------------------------------------------------------- 134 | | 135 | | The service provider manifest is used by Laravel to lazy load service 136 | | providers which are not needed for each request, as well to keep a 137 | | list of all of the services. Here, you may set its storage spot. 138 | | 139 | */ 140 | 141 | 'manifest' => storage_path().'/meta', 142 | 143 | /* 144 | |-------------------------------------------------------------------------- 145 | | Class Aliases 146 | |-------------------------------------------------------------------------- 147 | | 148 | | This array of class aliases will be registered when this application 149 | | is started. However, feel free to register as many as you wish as 150 | | the aliases are "lazy" loaded so they don't hinder performance. 151 | | 152 | */ 153 | 154 | 'aliases' => array( 155 | 156 | 'App' => 'Illuminate\Support\Facades\App', 157 | 'Artisan' => 'Illuminate\Support\Facades\Artisan', 158 | 'Auth' => 'Illuminate\Support\Facades\Auth', 159 | 'Blade' => 'Illuminate\Support\Facades\Blade', 160 | 'Cache' => 'Illuminate\Support\Facades\Cache', 161 | 'ClassLoader' => 'Illuminate\Support\ClassLoader', 162 | 'Config' => 'Illuminate\Support\Facades\Config', 163 | 'Controller' => 'Illuminate\Routing\Controller', 164 | 'Cookie' => 'Illuminate\Support\Facades\Cookie', 165 | 'Crypt' => 'Illuminate\Support\Facades\Crypt', 166 | 'DB' => 'Illuminate\Support\Facades\DB', 167 | 'Eloquent' => 'Illuminate\Database\Eloquent\Model', 168 | 'Event' => 'Illuminate\Support\Facades\Event', 169 | 'File' => 'Illuminate\Support\Facades\File', 170 | 'Form' => 'Illuminate\Support\Facades\Form', 171 | 'Hash' => 'Illuminate\Support\Facades\Hash', 172 | 'HTML' => 'Illuminate\Support\Facades\HTML', 173 | 'Input' => 'Illuminate\Support\Facades\Input', 174 | 'Lang' => 'Illuminate\Support\Facades\Lang', 175 | 'Log' => 'Illuminate\Support\Facades\Log', 176 | 'Mail' => 'Illuminate\Support\Facades\Mail', 177 | 'Paginator' => 'Illuminate\Support\Facades\Paginator', 178 | 'Password' => 'Illuminate\Support\Facades\Password', 179 | 'Queue' => 'Illuminate\Support\Facades\Queue', 180 | 'Redirect' => 'Illuminate\Support\Facades\Redirect', 181 | 'Redis' => 'Illuminate\Support\Facades\Redis', 182 | 'Request' => 'Illuminate\Support\Facades\Request', 183 | 'Response' => 'Illuminate\Support\Facades\Response', 184 | 'Route' => 'Illuminate\Support\Facades\Route', 185 | 'Schema' => 'Illuminate\Support\Facades\Schema', 186 | 'Seeder' => 'Illuminate\Database\Seeder', 187 | 'Session' => 'Illuminate\Support\Facades\Session', 188 | 'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait', 189 | 'SSH' => 'Illuminate\Support\Facades\SSH', 190 | 'Str' => 'Illuminate\Support\Str', 191 | 'URL' => 'Illuminate\Support\Facades\URL', 192 | 'Validator' => 'Illuminate\Support\Facades\Validator', 193 | 'View' => 'Illuminate\Support\Facades\View', 194 | 195 | 'Activation' => 'Cartalyst\Sentinel\Laravel\Facades\Activation', 196 | 'Auth' => 'Cartalyst\Sentinel\Laravel\Facades\Sentinel', 197 | 'Reminder' => 'Cartalyst\Sentinel\Laravel\Facades\Reminder', 198 | 'Sentinel' => 'Cartalyst\Sentinel\Laravel\Facades\Sentinel', 199 | 200 | 'API' => 'Cartalyst\Api\Laravel\Facades\API', 201 | 'ApiResponse' => 'Cartalyst\Api\Response', 202 | 203 | ), 204 | 205 | ); 206 | -------------------------------------------------------------------------------- /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' => 'forge', 59 | 'username' => 'forge', 60 | 'password' => '', 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/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/app/config/packages/.gitkeep -------------------------------------------------------------------------------- /app/config/packages/cartalyst/sentinel/config.php: -------------------------------------------------------------------------------- 1 | 'cartalyst_sentinel', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Cookie Key 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Please provide your cookie key for Sentinel. 39 | | 40 | */ 41 | 42 | 'cookie' => 'cartalyst_sentinel', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Users 47 | |-------------------------------------------------------------------------- 48 | | 49 | | Please provide the user model used in Sentinel. 50 | | 51 | */ 52 | 53 | 'users' => [ 54 | 55 | 'model' => 'User', 56 | 57 | ], 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Roles 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Please provide the role model used in Sentinel. 65 | | 66 | */ 67 | 68 | 'roles' => [ 69 | 70 | 'model' => 'Role', 71 | 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Permissions 77 | |-------------------------------------------------------------------------- 78 | | 79 | | Here you may specify the permissions class. Sentinel ships with two 80 | | permission types. 81 | | 82 | | 'Cartalyst\Sentinel\Permissions\StrictPermissions' 83 | | 'Cartalyst\Sentinel\Permissions\StandardPermissions' 84 | | 85 | | "StandardPermissions" will assign a higher priority to the user 86 | | permissions over role permissions, once a user is allowed or denied 87 | | a specific permission, it will be used regardless of the 88 | | permissions set on the role. 89 | | 90 | | "StrictPermissions" will deny any permission as soon as it finds it 91 | | rejected on either the user or any of the assigned roles. 92 | | 93 | */ 94 | 95 | 'permissions' => [ 96 | 97 | 'class' => 'Cartalyst\Sentinel\Permissions\StandardPermissions', 98 | 99 | ], 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Persistences 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Here you may specify the persistences model used and weather to use the 107 | | single persistence mode. 108 | | 109 | */ 110 | 111 | 'persistences' => [ 112 | 113 | 'model' => 'Cartalyst\Sentinel\Persistences\EloquentPersistence', 114 | 115 | 'single' => false, 116 | 117 | ], 118 | 119 | /* 120 | |-------------------------------------------------------------------------- 121 | | Checkpoints 122 | |-------------------------------------------------------------------------- 123 | | 124 | | When logging in, checking for existing sessions and failed logins occur, 125 | | you may configure an indefinite number of "checkpoints". These are 126 | | classes which may respond to each event and handle accordingly. 127 | | We ship with two, a throttling checkpoint and an activation 128 | | checkpoint. Feel free to add, remove or re-order 129 | | these. 130 | | 131 | */ 132 | 133 | 'checkpoints' => [ 134 | 135 | 'throttle', 136 | 'activation', 137 | 138 | ], 139 | 140 | /* 141 | |-------------------------------------------------------------------------- 142 | | Activations 143 | |-------------------------------------------------------------------------- 144 | | 145 | | Here you may specify the activations model used and the time (in seconds) 146 | | which activation codes expire. By default, activation codes expire after 147 | | three days. The lottery is used for garbage collection, expired 148 | | codes will be cleared automatically based on the provided odds. 149 | | 150 | */ 151 | 152 | 'activations' => [ 153 | 154 | 'model' => 'Cartalyst\Sentinel\Activations\EloquentActivation', 155 | 156 | 'expires' => 259200, 157 | 158 | 'lottery' => [2, 100], 159 | 160 | ], 161 | 162 | /* 163 | |-------------------------------------------------------------------------- 164 | | Reminders 165 | |-------------------------------------------------------------------------- 166 | | 167 | | Here you may specify the reminders model used and the time (in seconds) 168 | | which reminder codes expire. By default, reminder codes expire 169 | | after four hours. The lottery is used for garbage collection, expired 170 | | codes will be cleared automatically based on the provided odds. 171 | | 172 | */ 173 | 174 | 'reminders' => [ 175 | 176 | 'model' => 'Cartalyst\Sentinel\Reminders\EloquentReminder', 177 | 178 | 'expires' => 14400, 179 | 180 | 'lottery' => [2, 100], 181 | 182 | ], 183 | 184 | /* 185 | |-------------------------------------------------------------------------- 186 | | Throttling 187 | |-------------------------------------------------------------------------- 188 | | 189 | | Here, you may configure your site's throttling settings. There are three 190 | | types of throttling. 191 | | 192 | | The first type is "global". Global throttling will monitor the overall 193 | | failed login attempts across your site and can limit the effects of an 194 | | attempted DDoS attack. 195 | | 196 | | The second type is "ip". This allows you to throttle the failed login 197 | | attempts (across any account) of a given IP address. 198 | | 199 | | The third type is "user". This allows you to throttle the login attempts 200 | | on an individual user account. 201 | | 202 | | Each type of throttling has the same options. The first is the interval. 203 | | This is the time (in seconds) for which we check for failed logins. Any 204 | | logins outside this time are no longer assessed when throttling. 205 | | 206 | | The second option is thresholds. This may be approached one of two ways. 207 | | the first way, is by providing an key/value array. The key is the number 208 | | of failed login attempts, and the value is the delay, in seconds, before 209 | | the next attempt can occur. 210 | | 211 | | The second way is by providing an integer. If the number of failed login 212 | | attempts outweigh the thresholds integer, that throttle is locked until 213 | | there are no more failed login attempts within the specified interval. 214 | | 215 | | On this premise, we encourage you to use array thresholds for global 216 | | throttling (and perhaps IP throttling as well), so as to not lock your 217 | | whole site out for minutes on end because it's being DDoS'd. However, 218 | | for user throttling, locking a single account out because somebody is 219 | | attempting to breach it could be an appropriate response. 220 | | 221 | | You may use any type of throttling for any scenario, and the specific 222 | | configurations are designed to be customized as your site grows. 223 | | 224 | */ 225 | 226 | 'throttling' => [ 227 | 228 | 'model' => 'Cartalyst\Sentinel\Throttling\EloquentThrottle', 229 | 230 | 'global' => [ 231 | 232 | 'interval' => 900, 233 | 234 | 'thresholds' => [ 235 | 10 => 1, 236 | 20 => 2, 237 | 30 => 4, 238 | 40 => 8, 239 | 50 => 16, 240 | 60 => 12 241 | ], 242 | 243 | ], 244 | 245 | 'ip' => [ 246 | 247 | 'interval' => 900, 248 | 249 | 'thresholds' => 5, 250 | 251 | ], 252 | 253 | 'user' => [ 254 | 255 | 'interval' => 900, 256 | 257 | 'thresholds' => 5, 258 | 259 | ], 260 | 261 | ], 262 | 263 | ]; 264 | -------------------------------------------------------------------------------- /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' => 'demo_api_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/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/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/app/controllers/.gitkeep -------------------------------------------------------------------------------- /app/controllers/ApiController.php: -------------------------------------------------------------------------------- 1 | fractal = $fractal; 16 | 17 | // Are we going to try and include embedded data? 18 | $this->fractal->parseIncludes(Input::get('include', [])); 19 | } 20 | 21 | /** 22 | * Getter for statusCode 23 | * 24 | * @return mixed 25 | */ 26 | public function getStatusCode() 27 | { 28 | return $this->statusCode; 29 | } 30 | 31 | /** 32 | * Setter for statusCode 33 | * 34 | * @param int $statusCode Value to set 35 | * 36 | * @return self 37 | */ 38 | public function setStatusCode($statusCode) 39 | { 40 | $this->statusCode = $statusCode; 41 | return $this; 42 | } 43 | 44 | /** 45 | * Returns the given item. 46 | * 47 | * @param mixed $item 48 | * @param mixed $callback 49 | * @return \Cartalyst\Api\Response 50 | */ 51 | protected function respondWithItem($item, $callback) 52 | { 53 | $resource = new Item($item, $callback); 54 | 55 | $rootScope = $this->fractal->createData($resource); 56 | 57 | return $this->respondWithArray($rootScope->toArray()); 58 | } 59 | 60 | /** 61 | * Returns the given collection. 62 | * 63 | * @param mixed $collection 64 | * @param mixed $callback 65 | * @return \Cartalyst\Api\Response 66 | */ 67 | protected function respondWithCollection($collection, $callback) 68 | { 69 | $resource = new Collection($collection, $callback); 70 | 71 | $rootScope = $this->fractal->createData($resource); 72 | 73 | return $this->respondWithArray($rootScope->toArray()); 74 | } 75 | 76 | /** 77 | * Returns the given data. 78 | * 79 | * @param array $data 80 | * @param array $headers 81 | * @return \Cartalyst\Api\Response 82 | */ 83 | protected function respondWithArray(array $array, array $headers = []) 84 | { 85 | return new Response($array, $this->statusCode, $headers); 86 | 87 | } 88 | 89 | /** 90 | * Returns a response with an error response code. 91 | * 92 | * @param array $item 93 | * @param int $code 94 | * @return \Cartalyst\Api\Response 95 | */ 96 | protected function responseWithErrors($errors, $code) 97 | { 98 | $errors = (array) $errors; 99 | 100 | return new Response(compact('errors'), $code); 101 | } 102 | 103 | /** 104 | * Returns a response with the no content response code. 105 | * 106 | * @return \Cartalyst\Api\Response 107 | */ 108 | protected function responseWithNoContent() 109 | { 110 | return new Response('', 204); 111 | } 112 | 113 | protected function checkAccess($permission) 114 | { 115 | // On sub-requests (internal requests), we don't want to enforce access to 116 | // edit resources at runtime when accessing an API resource. This should be 117 | // done on the UI side. It doesn't matter where you call API methods from, 118 | // be it a controller or a CLI command, we only care about checking access 119 | // when we're being hit directly from a HTTP request. 120 | if (API::isSubRequest()) 121 | { 122 | return true; 123 | } 124 | 125 | return (Sentinel::check() && Sentinel::hasAccess($permission)); 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /app/controllers/AuthController.php: -------------------------------------------------------------------------------- 1 | 'required|email', 16 | 'password' => 'required', 17 | ]; 18 | 19 | $errors = Validator::make(Input::get(), $rules)->errors(); 20 | 21 | if (count($errors) > 0) 22 | { 23 | return Redirect::back() 24 | ->withInput() 25 | ->withErrors($errors); 26 | } 27 | 28 | try 29 | { 30 | $user = Sentinel::authenticate(Input::get()); 31 | } 32 | catch (ThrottlingException $e) 33 | { 34 | return Redirect::back() 35 | ->withErrors($e->getMessage()); 36 | } 37 | 38 | if ($user) 39 | { 40 | return Redirect::intended() 41 | ->withSuccess('Welcome, you have successfully logged in.'); 42 | } 43 | else 44 | { 45 | return Redirect::back() 46 | ->withErrors('Invalid username or password.'); 47 | } 48 | } 49 | 50 | public function logout() 51 | { 52 | Sentinel::logout(); 53 | 54 | return Redirect::route('login') 55 | ->withSuccess('You have successfully logged out.'); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /app/controllers/BaseController.php: -------------------------------------------------------------------------------- 1 | api = $api; 14 | } 15 | 16 | protected function api() 17 | { 18 | $args = func_get_args(); 19 | 20 | $method = strtoupper(array_shift($args)); 21 | 22 | $response = call_user_func_array(array($this->api, $method), $args); 23 | 24 | if ( ! $response->isSuccessful()) 25 | { 26 | $uri = array_shift($args); 27 | $statusCode = $response->getStatusCode(); 28 | 29 | $message = sprintf( 30 | 'API: "%s /%s" returned a %d status.', 31 | $method, 32 | $uri, 33 | $statusCode 34 | ); 35 | 36 | $data = $response->getData(); 37 | 38 | if (is_array($data) and isset($data['errors'])) 39 | { 40 | foreach ($data['errors'] as $error) 41 | { 42 | $message .= "\n$error"; 43 | } 44 | } 45 | 46 | throw new HttpException($statusCode, $message); 47 | } 48 | 49 | return $response->getData()['data']; 50 | } 51 | 52 | protected function checkAccess($permission) 53 | { 54 | return (Sentinel::check() && Sentinel::hasAccess($permission)); 55 | } 56 | 57 | /** 58 | * Setup the layout used by the controller. 59 | * 60 | * @return void 61 | */ 62 | protected function setupLayout() 63 | { 64 | if ( ! is_null($this->layout)) 65 | { 66 | $this->layout = View::make($this->layout); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /app/controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | checkAccess('checkins.list')) 21 | { 22 | App::abort(404, 'Sorry, but you are not even assigned to the standard group. Something went wrong and the world will probably end tonight.'); 23 | } 24 | 25 | $checkins = Checkin::with(['place', 'user'])->orderBy('created_at', 'desc')->get(); 26 | 27 | return View::make('welcome')->withCheckins($checkins); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /app/controllers/PlacesAdminController.php: -------------------------------------------------------------------------------- 1 | checkAccess('places.list')) 10 | { 11 | return Redirect::to('/')->withErrors('You don\'t have access to list.'); 12 | } 13 | 14 | $places = $this->api('get', 'api/v1/places'); 15 | 16 | return View::make('places.index', compact('places')); 17 | } 18 | 19 | public function edit($id) 20 | { 21 | if ( ! $this->checkAccess('places.edit')) 22 | { 23 | return Redirect::to('admin/places')->withErrors('You aren\'t allowed to edit places.'); 24 | } 25 | 26 | try 27 | { 28 | $place = $this->api('get', "api/v1/places/$id"); 29 | } 30 | catch (HttpException $e) 31 | { 32 | return Redirect::to('admin/places') 33 | ->withErrors($e->getMessage()); 34 | } 35 | 36 | return View::make('places.edit', compact('place')); 37 | } 38 | 39 | public function update($id) 40 | { 41 | if ( ! $this->checkAccess('places.update')) 42 | { 43 | return Redirect::back()->withErrors('You aren\'t allowed to edit places.'); 44 | } 45 | 46 | $validator = Validator::make(Input::get(), [ 47 | 'name' => 'required', 48 | 'address' => 'required', 49 | ]); 50 | 51 | if ($validator->fails()) 52 | { 53 | return Redirect::back() 54 | ->withErrors($validator->errors()); 55 | } 56 | 57 | $place = $this->api('put', "api/v1/places/$id", Input::get()); 58 | 59 | return Redirect::to('admin/places') 60 | ->withSuccess("Place [{$place['name']}] has successfully been updated."); 61 | } 62 | 63 | public function delete($id) 64 | { 65 | if ( ! $this->checkAccess('places.delete')) 66 | { 67 | return Redirect::back()->withErrors('You aren\'t allowed to delete places.'); 68 | } 69 | 70 | try 71 | { 72 | $place = $this->api('delete', "api/v1/places/$id"); 73 | } 74 | catch (HttpException $e) 75 | { 76 | return Redirect::to('admin/places') 77 | ->withErrors($e->getMessage()); 78 | } 79 | 80 | return Redirect::to('admin/places') 81 | ->withSuccess("Place has successfully been deleted."); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/controllers/PlacesApiController.php: -------------------------------------------------------------------------------- 1 | checkAccess('places.list')) 15 | { 16 | return $this->responseWithErrors('Sorry, you are not allowed to list places.', 403); 17 | } 18 | 19 | $places = Place::all(); 20 | 21 | return $this->respondWithCollection($places, new PlaceTransformer); 22 | } 23 | 24 | /** 25 | * Display the specified resource. 26 | * 27 | * @param int $id 28 | * @return Response 29 | */ 30 | public function show($id) 31 | { 32 | if ( ! $this->checkAccess('places.show')) 33 | { 34 | return $this->responseWithErrors('Sorry, you are not allowed to show places.', 403); 35 | } 36 | 37 | $place = Place::find($id); 38 | 39 | if ( ! $place) 40 | { 41 | return $this->responseWithErrors("The requested place [$id] does not exist.", 404); 42 | } 43 | 44 | return $this->respondWithItem($place, new PlaceTransformer); 45 | } 46 | 47 | /** 48 | * Update the specified resource in storage. 49 | * 50 | * @param int $id 51 | * @return Response 52 | */ 53 | public function update($id) 54 | { 55 | if ( ! $this->checkAccess('places.update')) 56 | { 57 | return $this->responseWithErrors('Sorry, you are not allowed to edit places.', 403); 58 | } 59 | 60 | $validator = Validator::make(Input::json()->all(), [ 61 | 'name' => 'required', 62 | 'address' => 'required', 63 | ]); 64 | 65 | if ($validator->fails()) 66 | { 67 | return $this->responseWithErrors($validator->errors()->all(), 422); 68 | } 69 | 70 | $place = Place::find($id); 71 | $place->fill(Input::json()->all()); 72 | $place->save(); 73 | 74 | return $this->respondWithItem($place, new PlaceTransformer); 75 | } 76 | 77 | /** 78 | * Remove the specified resource from storage. 79 | * 80 | * @param int $id 81 | * @return Response 82 | */ 83 | public function destroy($id) 84 | { 85 | if ( ! $this->checkAccess('places.delete')) 86 | { 87 | return $this->responseWithErrors('Sorry, you are not allowed to delete places.', 403); 88 | } 89 | 90 | $place = Place::find($id); 91 | 92 | if ( ! $place) 93 | { 94 | return $this->responseWithErrors("The requested place [$id] does not exist.", 404); 95 | } 96 | 97 | $place->delete(); 98 | 99 | return $this->responseWithNoContent(); 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /app/database/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/app/database/migrations/.gitkeep -------------------------------------------------------------------------------- /app/database/migrations/2014_01_04_221638_MigrationInstallPlaces.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->text('address'); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::drop('places'); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/database/migrations/2014_01_04_223547_MigrationInstallCheckins.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('place_id'); 19 | $table->integer('user_id'); 20 | $table->string('snapshot'); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('checkins'); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/database/production.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/app/database/production.sqlite -------------------------------------------------------------------------------- /app/database/seeds/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/app/database/seeds/.gitkeep -------------------------------------------------------------------------------- /app/database/seeds/CheckinTableSeeder.php: -------------------------------------------------------------------------------- 1 | whereHas('roles', function($query) 15 | { 16 | $query->whereSlug('standard'); 17 | })->get(); 18 | $usersList = $users->lists('id'); 19 | 20 | $places = Place::all(); 21 | $placesList = $places->lists('id'); 22 | 23 | for ($i = 0; $i < 50; $i++) 24 | { 25 | $user = $users->find($usersList[array_rand($usersList)]); 26 | $place = $places->find($placesList[array_rand($placesList)]); 27 | 28 | $checkin = new Checkin([ 29 | 'snapshot' => 'http://placehold.it/500/'.substr($faker->hexcolor, 1).'&text='.str_replace(' ', '+', $faker->catchPhrase), 30 | ]); 31 | $checkin->user()->associate($user); 32 | $checkin->place()->associate($place); 33 | $checkin->save(); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | truncate(); 23 | } 24 | 25 | $this->call('RoleTableSeeder'); 26 | $this->call('UserTableSeeder'); 27 | $this->call('PlaceTableSeeder'); 28 | $this->call('CheckinTableSeeder'); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/database/seeds/PlaceTableSeeder.php: -------------------------------------------------------------------------------- 1 | $faker->company, 18 | 'address' => $faker->address, 19 | ]); 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /app/database/seeds/RoleTableSeeder.php: -------------------------------------------------------------------------------- 1 | 'admin', 14 | 'name' => 'Admin', 15 | 'permissions' => [ 16 | 'checkins.*' => true, 17 | 'places.*' => true, 18 | ], 19 | ]); 20 | 21 | Role::create([ 22 | 'slug' => 'privileged', 23 | 'name' => 'Privileged', 24 | 'permissions' => [ 25 | 'checkins.*' => true, 26 | 'places.list' => true, 27 | 'places.edit' => true, 28 | ], 29 | ]); 30 | 31 | Role::create([ 32 | 'slug' => 'standard', 33 | 'name' => 'Standard', 34 | 'permissions' => [ 35 | 'checkins.list' => true, 36 | ], 37 | ]); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/database/seeds/UserTableSeeder.php: -------------------------------------------------------------------------------- 1 | first(); 13 | $user = Sentinel::registerAndActivate([ 14 | 'email' => 'admin@example.com', 15 | 'password' => 'password', 16 | 'first_name' => 'Dan', 17 | 'last_name' => 'Syme', 18 | ]); 19 | $user->roles()->attach($admin); 20 | 21 | $privileged = Role::whereSlug('privileged')->first(); 22 | $user = Sentinel::registerAndActivate([ 23 | 'email' => 'privileged@example.com', 24 | 'password' => 'password', 25 | 'first_name' => 'Ben', 26 | 'last_name' => 'Corlett', 27 | ]); 28 | $user->roles()->attach($privileged); 29 | 30 | $standard = Role::whereSlug('standard')->first(); 31 | 32 | $faker = Faker\Factory::create(); 33 | 34 | for ($i = 0; $i < 10; $i++) 35 | { 36 | $user = Sentinel::registerAndActivate([ 37 | 'email' => $faker->email, 38 | 'password' => 'password', 39 | 'first_name' => $faker->firstName, 40 | 'last_name' => $faker->lastName, 41 | ]); 42 | $user->roles()->attach($standard); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /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 | "boolean" => "The :attribute field must be true or false", 31 | "confirmed" => "The :attribute confirmation does not match.", 32 | "date" => "The :attribute is not a valid date.", 33 | "date_format" => "The :attribute does not match the format :format.", 34 | "different" => "The :attribute and :other must be different.", 35 | "digits" => "The :attribute must be :digits digits.", 36 | "digits_between" => "The :attribute must be between :min and :max digits.", 37 | "email" => "The :attribute must be a valid email address.", 38 | "exists" => "The selected :attribute is invalid.", 39 | "image" => "The :attribute must be an image.", 40 | "in" => "The selected :attribute is invalid.", 41 | "integer" => "The :attribute must be an integer.", 42 | "ip" => "The :attribute must be a valid IP address.", 43 | "max" => array( 44 | "numeric" => "The :attribute may not be greater than :max.", 45 | "file" => "The :attribute may not be greater than :max kilobytes.", 46 | "string" => "The :attribute may not be greater than :max characters.", 47 | "array" => "The :attribute may not have more than :max items.", 48 | ), 49 | "mimes" => "The :attribute must be a file of type: :values.", 50 | "min" => array( 51 | "numeric" => "The :attribute must be at least :min.", 52 | "file" => "The :attribute must be at least :min kilobytes.", 53 | "string" => "The :attribute must be at least :min characters.", 54 | "array" => "The :attribute must have at least :min items.", 55 | ), 56 | "not_in" => "The selected :attribute is invalid.", 57 | "numeric" => "The :attribute must be a number.", 58 | "regex" => "The :attribute format is invalid.", 59 | "required" => "The :attribute field is required.", 60 | "required_if" => "The :attribute field is required when :other is :value.", 61 | "required_with" => "The :attribute field is required when :values is present.", 62 | "required_with_all" => "The :attribute field is required when :values is present.", 63 | "required_without" => "The :attribute field is required when :values is not present.", 64 | "required_without_all" => "The :attribute field is required when none of :values are present.", 65 | "same" => "The :attribute and :other must match.", 66 | "size" => array( 67 | "numeric" => "The :attribute must be :size.", 68 | "file" => "The :attribute must be :size kilobytes.", 69 | "string" => "The :attribute must be :size characters.", 70 | "array" => "The :attribute must contain :size items.", 71 | ), 72 | "unique" => "The :attribute has already been taken.", 73 | "url" => "The :attribute format is invalid.", 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Custom Validation Language Lines 78 | |-------------------------------------------------------------------------- 79 | | 80 | | Here you may specify custom validation messages for attributes using the 81 | | convention "attribute.rule" to name the lines. This makes it quick to 82 | | specify a specific custom language line for a given attribute rule. 83 | | 84 | */ 85 | 86 | 'custom' => array( 87 | 'attribute-name' => array( 88 | 'rule-name' => 'custom-message', 89 | ), 90 | ), 91 | 92 | /* 93 | |-------------------------------------------------------------------------- 94 | | Custom Validation Attributes 95 | |-------------------------------------------------------------------------- 96 | | 97 | | The following language lines are used to swap attribute place-holders 98 | | with something more reader friendly such as E-Mail Address instead 99 | | of "email". This simply helps us make messages a little cleaner. 100 | | 101 | */ 102 | 103 | 'attributes' => array(), 104 | 105 | ); 106 | -------------------------------------------------------------------------------- /app/models/Checkin.php: -------------------------------------------------------------------------------- 1 | belongsTo('Place'); 13 | } 14 | 15 | public function user() 16 | { 17 | return $this->belongsTo('User'); 18 | } 19 | 20 | public function getIdAttribute($id) 21 | { 22 | return (int) $id; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/models/Place.php: -------------------------------------------------------------------------------- 1 | checkins as $checkin) 25 | { 26 | $checkin->delete(); 27 | } 28 | }); 29 | } 30 | 31 | public function checkins() 32 | { 33 | return $this->hasMany('Checkin'); 34 | } 35 | 36 | public function getIdAttribute($id) 37 | { 38 | return (int) $id; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/models/Role.php: -------------------------------------------------------------------------------- 1 | 'HomeController@showWelcome', 'before' => 'auth']); 15 | 16 | Route::get('login', ['uses' => 'AuthController@showLogin', 'as' => 'login']); 17 | Route::post('login', 'AuthController@processLogin'); 18 | Route::get('logout', 'AuthController@logout'); 19 | 20 | Route::group(['prefix' => 'admin', 'before' => 'auth'], function() 21 | { 22 | Route::get('places', 'PlacesAdminController@index'); 23 | Route::get('places/{id}/edit', 'PlacesAdminController@edit'); 24 | Route::post('places/{id}/edit', 'PlacesAdminController@update'); 25 | Route::get('places/{id}/delete', 'PlacesAdminController@delete'); 26 | }); 27 | 28 | Route::group(['prefix' => 'api/v1', 'before' => 'auth.basic'], function() 29 | { 30 | Route::get('places', ['uses' => 'PlacesApiController@index', 'as' => 'places.index']); 31 | Route::get('places/{id}', ['uses' => 'PlacesApiController@show', 'as' => 'places.show']); 32 | Route::put('places/{id}', ['uses' => 'PlacesApiController@update', 'as' => 'places.update']); 33 | Route::delete('places/{id}', ['uses' => 'PlacesApiController@destroy', 'as' => 'places.destroy']); 34 | }); 35 | 36 | Route::get('cheatsheet', function() 37 | { 38 | $users = User::with('groups')->get(); 39 | $places = Place::get(); 40 | 41 | return View::make('cheatsheet') 42 | ->withUsers($users) 43 | ->withPlaces($places); 44 | }); 45 | -------------------------------------------------------------------------------- /app/src/App/Transformers/CheckinTransformer.php: -------------------------------------------------------------------------------- 1 | $checkin->id, 27 | 'created_at' => (string) $checkin->created_at, 28 | ]; 29 | } 30 | 31 | /** 32 | * Embed Place 33 | * 34 | * @return League\Fractal\Resource\Item 35 | */ 36 | public function includePlace(Checkin $checkin) 37 | { 38 | $place = $checkin->place; 39 | 40 | return $this->item($place, new PlaceTransformer); 41 | } 42 | 43 | /** 44 | * Embed User 45 | * 46 | * @return League\Fractal\Resource\Item 47 | */ 48 | public function includeUser(Checkin $checkin) 49 | { 50 | $user = $checkin->user; 51 | 52 | return $this->item($user, new UserTransformer); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /app/src/App/Transformers/PlaceTransformer.php: -------------------------------------------------------------------------------- 1 | $place->id, 19 | 'name' => $place->name, 20 | 'address' => $place->address, 21 | 'created_at' => (string) $place->created_at, 22 | ]; 23 | } 24 | 25 | /** 26 | * {@inheritDoc} 27 | */ 28 | public function includeCheckins(Place $place) 29 | { 30 | $checkins = $place->checkins; 31 | 32 | return $this->collection($checkins, new CheckinTransformer); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/App/Transformers/UserTransformer.php: -------------------------------------------------------------------------------- 1 | $user->id, 21 | 'email' => $user->email, 22 | 'first_name' => $user->first_name, 23 | 'first_name' => $user->first_name, 24 | 'created_at' => (string) $user->created_at, 25 | ]; 26 | } 27 | 28 | /** 29 | * Embed Checkins 30 | * 31 | * @return League\Fractal\Resource\Collection 32 | */ 33 | public function includeCheckins(User $user) 34 | { 35 | $checkins = $user->checkins; 36 | 37 | return $this->collection($checkins, new CheckinTransformer); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/start/artisan.php: -------------------------------------------------------------------------------- 1 | client->request('GET', '/'); 13 | 14 | $this->assertTrue($this->client->getResponse()->isOk()); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /app/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | 11 | {{ Form::open(['class' => 'form-horizontal']) }} 12 | 13 |
14 | 15 |
16 | {{ Form::text('email', null, ['class' => 'form-control']) }} 17 | @if ($errors->has('email')) 18 | {{{ $errors->first('email') }}} 19 | @endif 20 |
21 |
22 | 23 |
24 | 25 |
26 | {{ Form::password('password', ['class' => 'form-control']) }} 27 | @if ($errors->has('password')) 28 | {{{ $errors->first('password') }}} 29 | @endif 30 |
31 |
32 | 33 |
34 |
35 | {{ Form::submit('Login', ['class' => 'btn btn-primary btn-lg']) }} 36 |
37 |
38 | 39 | {{ Form::close() }} 40 | 41 | 42 | @stop 43 | -------------------------------------------------------------------------------- /app/views/cheatsheet.blade.php: -------------------------------------------------------------------------------- 1 | @extends('template') 2 | 3 | @section('content') 4 | 5 | @foreach ($users as $user) 6 |
7 |
8 | {{{ $user->first_name }}} {{{ $user->last_name }}} 9 |
10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 57 | 58 |
Email
{{{ $user->email }}}
Password
password
Group(s) 23 | {{{ implode(', ', $user->groups->lists('name')) }}} 24 |
Permissions 29 | 56 |
59 |
60 |
61 | @endforeach 62 | 63 | @stop 64 | -------------------------------------------------------------------------------- /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/partials/notifications.blade.php: -------------------------------------------------------------------------------- 1 | @if (Session::has('success')) 2 |
3 |
4 | 5 | {{{ Session::get('success') }}} 6 |
7 |
8 | @endif 9 | 10 | @if ($errors->any()) 11 |
12 |
13 | 14 | @if ($errors->has(0)) 15 | {{{ $errors->first(0) }}} 16 | @else 17 | Please check below for errors. 18 | @endif 19 |
20 |
21 | @endif 22 | -------------------------------------------------------------------------------- /app/views/places/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('template') 2 | 3 | @section('content') 4 | 5 | 8 | 9 | @if ( ! Sentinel::hasAccess('places.delete')) 10 |
11 | You don't have permission to delete places. Don't believe me? Bypass the button and go straight to {{ URL::to("admin/places/{$place['id']}/delete") }} 12 |
13 | @endif 14 | 15 | {{ Form::open(['class' => 'form-horizontal']) }} 16 |
17 | 18 |
19 | {{ Form::text('name', Input::old('name', $place['name']), ['class' => 'form-control', 'id' => 'name']) }} 20 | @if ($errors->has('name')) 21 | {{{ $errors->first('name') }}} 22 | @endif 23 |
24 |
25 |
26 | 27 |
28 | {{ Form::textarea('address', Input::old('address', $place['address']), ['class' => 'form-control', 'id' => 'address']) }} 29 | @if ($errors->has('address')) 30 | {{{ $errors->first('address') }}} 31 | @endif 32 |
33 |
34 |
35 |
36 | {{ Form::submit('Save', ['class' => 'btn btn-primary btn-lg', ( ! Sentinel::hasAccess('places.update') ? 'disabled' : '')]) }} 37 | {{ Form::reset('Reset', ['class' => 'btn btn-default', ( ! Sentinel::hasAccess('places.update') ? 'disabled' : '')]) }} 38 | Delete 39 |
40 |
41 | {{ Form::close () }} 42 | @stop 43 | -------------------------------------------------------------------------------- /app/views/places/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('template') 2 | 3 | @section('content') 4 | 5 | 8 | 9 |
10 | You have permission to list places! 11 |
12 | @if ( ! Sentinel::hasAccess('places.delete')) 13 |
14 | You don't have permission to delete places. 15 |
16 | @endif 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | @foreach ($places as $place) 28 | 29 | 30 | 31 | 35 | 36 | @endforeach 37 | 38 |
NameCreated At
{{{ $place['name'] }}}{{{ $place['created_at'] }}} 32 | Edit 33 | Delete 34 |
39 | 40 | @stop 41 | -------------------------------------------------------------------------------- /app/views/template.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | @if (Sentinel::check()) 19 |
20 | 21 | @if (Sentinel::hasAccess('places.*')) 22 | Manage Places 23 | @endif 24 | 25 | Logout 26 |
27 | @endif 28 | 29 | @include('partials.notifications') 30 | 31 |
32 | @yield('content') 33 |
34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | @extends('template') 2 | 3 | @section('content') 4 | 5 | 8 | 9 | @if (count($checkins) > 0) 10 | 19 | @else 20 |
21 |

No checkins available yet. Have you seeded your database?

22 |
23 | @endif 24 | 25 | @stop 26 | -------------------------------------------------------------------------------- /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( 30 | 31 | 'local' => array('homestead'), 32 | 33 | )); 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Bind Paths 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here we are binding the paths configured in paths.php to the app. You 41 | | should not be changing these here. If you need to change these you 42 | | may do so within the paths.php file and they will be bound here. 43 | | 44 | */ 45 | 46 | $app->bindInstallPaths(require __DIR__.'/paths.php'); 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Load The Application 51 | |-------------------------------------------------------------------------- 52 | | 53 | | Here we will load this Illuminate application. We will keep this in a 54 | | separate location so we can isolate the creation of an application 55 | | from the actual running of the application with a given request. 56 | | 57 | */ 58 | 59 | $framework = $app['path.base']. 60 | '/vendor/laravel/framework/src'; 61 | 62 | require $framework.'/Illuminate/Foundation/start.php'; 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Return The Application 67 | |-------------------------------------------------------------------------- 68 | | 69 | | This script returns the application instance. The instance is given to 70 | | the calling script so we can separate the building of the instances 71 | | from the actual running of the application and sending responses. 72 | | 73 | */ 74 | 75 | return $app; 76 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "repositories": [ 7 | { 8 | "type": "composer", 9 | "url": "http://packages.cartalyst.com" 10 | } 11 | ], 12 | "require": { 13 | "laravel/framework": "4.2.*", 14 | "cartalyst/sentinel": "1.0.*", 15 | "cartalyst/api": "2.0.*", 16 | "league/fractal": "~0.9" 17 | }, 18 | "require-dev": { 19 | "fzaninotto/faker": "1.3.*" 20 | }, 21 | "autoload": { 22 | "classmap": [ 23 | "app/commands", 24 | "app/controllers", 25 | "app/models", 26 | "app/database/migrations", 27 | "app/database/seeds", 28 | "app/tests/TestCase.php" 29 | ], 30 | "psr-0": { 31 | "App": "app/src/" 32 | } 33 | }, 34 | "scripts": { 35 | "post-install-cmd": [ 36 | "php artisan clear-compiled", 37 | "php artisan optimize" 38 | ], 39 | "post-update-cmd": [ 40 | "php artisan clear-compiled", 41 | "php artisan optimize" 42 | ], 43 | "post-create-project-cmd": [ 44 | "php artisan key:generate" 45 | ] 46 | }, 47 | "config": { 48 | "preferred-install": "dist" 49 | }, 50 | "minimum-stability": "dev", 51 | "prefer-stable": true 52 | } 53 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Cartalyst PSL 2 | Copyright (c) 2011-2014, Cartalyst LLC, 3 | All rights reserved. 4 | 5 | This license is a legal agreement between you and Cartalyst LLC for the use of 6 | any package (all versions) Software (the "Software"). By downloading any version 7 | of the Software you agree to be bound by the terms and conditions of this 8 | license. Cartalyst LLC reserves the right to alter this agreement at any time, 9 | for any reason, without notice. 10 | 11 | You may alter, modify, or extend the Software for your own use or for use in an 12 | integral part of your product or service, or commission a third-party to perform 13 | modifications for you, but you may not sub license, resell, share, transfer, or 14 | otherwise redistribute the modified or derivative version of the Software as a 15 | sole product without prior written consent from Cartalyst LLC. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 25 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /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/assets/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/public/assets/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /public/assets/fonts/glyphicons-halflings-regular.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /public/assets/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/public/assets/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /public/assets/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/public/assets/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /public/assets/js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.0.3 (http://getbootstrap.com) 3 | * Copyright 2013 Twitter, Inc. 4 | * Licensed under http://www.apache.org/licenses/LICENSE-2.0 5 | */ 6 | 7 | if("undefined"==typeof jQuery)throw new Error("Bootstrap requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]}}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one(a.support.transition.end,function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b()})}(jQuery),+function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function c(){f.trigger("closed.bs.alert").remove()}var d=a(this),e=d.attr("data-target");e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,""));var f=a(e);b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one(a.support.transition.end,c).emulateTransitionEnd(150):c())};var d=a.fn.alert;a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("bs.alert");e||d.data("bs.alert",e=new c(this)),"string"==typeof b&&e[b].call(d)})},a.fn.alert.Constructor=c,a.fn.alert.noConflict=function(){return a.fn.alert=d,this},a(document).on("click.bs.alert.data-api",b,c.prototype.close)}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d)};b.DEFAULTS={loadingText:"loading..."},b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.is("input")?"val":"html",e=c.data();a+="Text",e.resetText||c.data("resetText",c[d]()),c[d](e[a]||this.options[a]),setTimeout(function(){"loadingText"==a?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.closest('[data-toggle="buttons"]'),b=!0;if(a.length){var c=this.$element.find("input");"radio"===c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?b=!1:a.find(".active").removeClass("active")),b&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}b&&this.$element.toggleClass("active")};var c=a.fn.button;a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof c&&c;e||d.data("bs.button",e=new b(this,f)),"toggle"==c?e.toggle():c&&e.setState(c)})},a.fn.button.Constructor=b,a.fn.button.noConflict=function(){return a.fn.button=c,this},a(document).on("click.bs.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle"),b.preventDefault()})}(jQuery),+function(a){"use strict";var b=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter",a.proxy(this.pause,this)).on("mouseleave",a.proxy(this.cycle,this))};b.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},b.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},b.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},b.prototype.to=function(b){var c=this,d=this.getActiveIndex();return b>this.$items.length-1||0>b?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){c.to(b)}):d==b?this.pause().cycle():this.slide(b>d?"next":"prev",a(this.$items[b]))},b.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition.end&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},b.prototype.next=function(){return this.sliding?void 0:this.slide("next")},b.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},b.prototype.slide=function(b,c){var d=this.$element.find(".item.active"),e=c||d[b](),f=this.interval,g="next"==b?"left":"right",h="next"==b?"first":"last",i=this;if(!e.length){if(!this.options.wrap)return;e=this.$element.find(".item")[h]()}this.sliding=!0,f&&this.pause();var j=a.Event("slide.bs.carousel",{relatedTarget:e[0],direction:g});if(!e.hasClass("active")){if(this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid.bs.carousel",function(){var b=a(i.$indicators.children()[i.getActiveIndex()]);b&&b.addClass("active")})),a.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(j),j.isDefaultPrevented())return;e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),d.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid.bs.carousel")},0)}).emulateTransitionEnd(600)}else{if(this.$element.trigger(j),j.isDefaultPrevented())return;d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid.bs.carousel")}return f&&this.cycle(),this}};var c=a.fn.carousel;a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c),g="string"==typeof c?c:f.slide;e||d.data("bs.carousel",e=new b(this,f)),"number"==typeof c?e.to(c):g?e[g]():f.interval&&e.pause().cycle()})},a.fn.carousel.Constructor=b,a.fn.carousel.noConflict=function(){return a.fn.carousel=c,this},a(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(b){var c,d=a(this),e=a(d.attr("data-target")||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"")),f=a.extend({},e.data(),d.data()),g=d.attr("data-slide-to");g&&(f.interval=!1),e.carousel(f),(g=d.attr("data-slide-to"))&&e.data("bs.carousel").to(g),b.preventDefault()}),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var b=a(this);b.carousel(b.data())})})}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.transitioning=null,this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.DEFAULTS={toggle:!0},b.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},b.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b=a.Event("show.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.$parent&&this.$parent.find("> .panel > .in");if(c&&c.length){var d=c.data("bs.collapse");if(d&&d.transitioning)return;c.collapse("hide"),d||c.data("bs.collapse",null)}var e=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[e](0),this.transitioning=1;var f=function(){this.$element.removeClass("collapsing").addClass("in")[e]("auto"),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return f.call(this);var g=a.camelCase(["scroll",e].join("-"));this.$element.one(a.support.transition.end,a.proxy(f,this)).emulateTransitionEnd(350)[e](this.$element[0][g])}}},b.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var d=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};return a.support.transition?(this.$element[c](0).one(a.support.transition.end,a.proxy(d,this)).emulateTransitionEnd(350),void 0):d.call(this)}}},b.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var c=a.fn.collapse;a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("bs.collapse"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c);e||d.data("bs.collapse",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.collapse.Constructor=b,a.fn.collapse.noConflict=function(){return a.fn.collapse=c,this},a(document).on("click.bs.collapse.data-api","[data-toggle=collapse]",function(b){var c,d=a(this),e=d.attr("data-target")||b.preventDefault()||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,""),f=a(e),g=f.data("bs.collapse"),h=g?"toggle":d.data(),i=d.attr("data-parent"),j=i&&a(i);g&&g.transitioning||(j&&j.find('[data-toggle=collapse][data-parent="'+i+'"]').not(d).addClass("collapsed"),d[f.hasClass("in")?"addClass":"removeClass"]("collapsed")),f.collapse(h)})}(jQuery),+function(a){"use strict";function b(){a(d).remove(),a(e).each(function(b){var d=c(a(this));d.hasClass("open")&&(d.trigger(b=a.Event("hide.bs.dropdown")),b.isDefaultPrevented()||d.removeClass("open").trigger("hidden.bs.dropdown"))})}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}var d=".dropdown-backdrop",e="[data-toggle=dropdown]",f=function(b){a(b).on("click.bs.dropdown",this.toggle)};f.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){if("ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(''}),b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),b.prototype.constructor=b,b.prototype.getDefaults=function(){return b.DEFAULTS},b.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content")[this.options.html?"html":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},b.prototype.hasContent=function(){return this.getTitle()||this.getContent()},b.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},b.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},b.prototype.tip=function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip};var c=a.fn.popover;a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof c&&c;e||d.data("bs.popover",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.noConflict=function(){return a.fn.popover=c,this}}(jQuery),+function(a){"use strict";function b(c,d){var e,f=a.proxy(this.process,this);this.$element=a(c).is("body")?a(window):a(c),this.$body=a("body"),this.$scrollElement=this.$element.on("scroll.bs.scroll-spy.data-api",f),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||(e=a(c).attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.offsets=a([]),this.targets=a([]),this.activeTarget=null,this.refresh(),this.process()}b.DEFAULTS={offset:10},b.prototype.refresh=function(){var b=this.$element[0]==window?"offset":"position";this.offsets=a([]),this.targets=a([]);var c=this;this.$body.find(this.selector).map(function(){var d=a(this),e=d.data("target")||d.attr("href"),f=/^#\w/.test(e)&&a(e);return f&&f.length&&[[f[b]().top+(!a.isWindow(c.$scrollElement.get(0))&&c.$scrollElement.scrollTop()),e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){c.offsets.push(this[0]),c.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,d=c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(b>=d)return g!=(a=f.last()[0])&&this.activate(a);for(a=e.length;a--;)g!=f[a]&&b>=e[a]&&(!e[a+1]||b<=e[a+1])&&this.activate(f[a])},b.prototype.activate=function(b){this.activeTarget=b,a(this.selector).parents(".active").removeClass("active");var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate.bs.scrollspy")};var c=a.fn.scrollspy;a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=c,this},a(window).on("load",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(jQuery),+function(a){"use strict";var b=function(b){this.element=a(b)};b.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a")[0],f=a.Event("show.bs.tab",{relatedTarget:e});if(b.trigger(f),!f.isDefaultPrevented()){var g=a(d);this.activate(b.parent("li"),c),this.activate(g,g.parent(),function(){b.trigger({type:"shown.bs.tab",relatedTarget:e})})}}},b.prototype.activate=function(b,c,d){function e(){f.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),g?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var f=c.find("> .active"),g=d&&a.support.transition&&f.hasClass("fade");g?f.one(a.support.transition.end,e).emulateTransitionEnd(150):e(),f.removeClass("in")};var c=a.fn.tab;a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new b(this)),"string"==typeof c&&e[c]()})},a.fn.tab.Constructor=b,a.fn.tab.noConflict=function(){return a.fn.tab=c,this},a(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})}(jQuery),+function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,d),this.$window=a(window).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(c),this.affixed=this.unpin=null,this.checkPosition()};b.RESET="affix affix-top affix-bottom",b.DEFAULTS={offset:0},b.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},b.prototype.checkPosition=function(){if(this.$element.is(":visible")){var c=a(document).height(),d=this.$window.scrollTop(),e=this.$element.offset(),f=this.options.offset,g=f.top,h=f.bottom;"object"!=typeof f&&(h=g=f),"function"==typeof g&&(g=f.top()),"function"==typeof h&&(h=f.bottom());var i=null!=this.unpin&&d+this.unpin<=e.top?!1:null!=h&&e.top+this.$element.height()>=c-h?"bottom":null!=g&&g>=d?"top":!1;this.affixed!==i&&(this.unpin&&this.$element.css("top",""),this.affixed=i,this.unpin="bottom"==i?e.top-d:null,this.$element.removeClass(b.RESET).addClass("affix"+(i?"-"+i:"")),"bottom"==i&&this.$element.offset({top:document.body.offsetHeight-h-this.$element.height()}))}};var c=a.fn.affix;a.fn.affix=function(c){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof c&&c;e||d.data("bs.affix",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.affix.Constructor=b,a.fn.affix.noConflict=function(){return a.fn.affix=c,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var b=a(this),c=b.data();c.offset=c.offset||{},c.offsetBottom&&(c.offset.bottom=c.offsetBottom),c.offsetTop&&(c.offset.top=c.offsetTop),b.affix(c)})})}(jQuery); -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/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/cartalyst/demo-api/cfc41ce2df11c12959e3d13662cd8a706240553e/public/packages/.gitkeep -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # API Demo 2 | 3 | This demo works to serve as a real-life demo of Cartalyst's API V2 for Laravel 4.1. The package is a work-in-progress and therefore this demo is as well. 4 | 5 | This demo is a mockup of Foursqure and the following entities: 6 | 7 | 1. Places 8 | 2. Users 9 | 3. Checkins 10 | 11 | Data is seeded to the database by Laravel's seeding. We utilise our API package for internal API requests - allowing you to build API-first applications (an abstraction where your application's controllers talk [in runtime] directly to your RESTful API). 12 | 13 | This demo is following [Phil Sturgeon's](https://github.com/philsturgeon) recommendations for [building a decent RESTful API](http://philsturgeon.co.uk/blog/2013/07/building-a-decent-api). 14 | 15 | We are also utilising [The League of Extraordinary Packages'](http://thephpleague.com) REST API helper package, [Fractal](https://github.com/php-loep/fractal). 16 | 17 | For more information on using Fractal to build awesome REST APIs, see [Build APIs You Won't Hate](https://leanpub.com/build-apis-you-wont-hate). 18 | 19 | 20 | ## Installation 21 | 22 | To install this demo, firstly you must be a subscriber of Cartalyst's [Arsenal](http://cartalyst.com/arsenal). 23 | 24 | Installation: 25 | 26 | 1. Clone this repo: 27 | 28 | ``` 29 | git clone git@github.com:cartalyst/api-demo.git 30 | ``` 31 | 32 | 2. Setup your virtual host. 33 | 34 | 3. Go into the directory in your terminal app and install composer dependencies: 35 | 36 | ``` 37 | composer install 38 | ``` 39 | 40 | 4. Configure your database connection. 41 | 42 | 5. Run migrations for Sentinel and the main application 43 | 44 | ``` 45 | php artisan migrate --package=cartalyst/sentinel 46 | php artisan migrate 47 | ``` 48 | 49 | 6. Seed your database (you can do this as many times as you want, it will reset the database each time). 50 | 51 | ``` 52 | php artisan db:seed 53 | ``` 54 | 55 | ## API Usage 56 | 57 | We have fulfilled the basic ~~C~~RUD processed for a "place" entity. Begin by hitting the following endpoint on your app: 58 | 59 | ``` 60 | GET /api/v1/places HTTP/1.1 61 | Host: api.dev 62 | ``` 63 | 64 | Excerpt From: Phil Sturgeon. “Build APIs You Won't Hate.” iBooks. 65 | 66 | This will return a nicely formatted array of available places. You may also nest in checkins for each place and associated users (which was populated through the seeding process above). To have a play with this, get your favorite HTTP client (I like the [Postman REST Client](https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en) for Chrome): 67 | 68 | ``` 69 | GET /api/v1/places?include=checkins HTTP/1.1 70 | Host: api.dev 71 | ``` 72 | 73 | ``` 74 | GET /api/v1/places?include=checkins.user HTTP/1.1 75 | Host: api.dev 76 | ``` 77 | 78 | Take a look at `app/routes.php` for the endpoints we've implemented in this basic demo. 79 | 80 | You may also perform a `PUT` request following URI to update a place, for example (note, our API demo is expecting JSON-encoded data, and so should your API, ditch that form-url-encoded junk): 81 | 82 | ``` 83 | PUT /api/v1/places/1 HTTP/1.1 84 | Host: api.dev 85 | ``` 86 | 87 | ``` 88 | {"name":"New Name","address","123 Fake Street\nFake City"} 89 | ``` 90 | 91 | And of course, you may `DELETE` a place: 92 | 93 | ``` 94 | DELETE /api/v1/places/1 HTTP/1.1 95 | Host: api.dev 96 | ``` 97 | 98 | At this stage, we've not built endpoints for creating places, because that can happen through database seeding. This is a demo only, not a full app :) 99 | 100 | ## Admin Usage 101 | 102 | Once again, being a demo, there's no admin filters, nothing too fancy, just routes to simulate an admin interface. 103 | 104 | To begin, navigate your browser to `http://api.dev/admin/places` (substituting your HTTP host in). The rest is obvious, you may edit/delete places. The code is where you want to look though, to see the interactions between the admin controllers and the API controllers, to see how requests are created at runtime and objects are returned. 105 | 106 | > *Note:* This demo is not a fully-fledged app. It's a demo, so we're not covering every possible scenario or completed every endpoint. 107 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 |