├── .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 |
{{{ $user->email }}} |
15 | |
Password | 18 |password |
19 |
Group(s) | 22 |23 | {{{ implode(', ', $user->groups->lists('name')) }}} 24 | | 25 |
Permissions | 28 |
29 |
|
57 |
Name | 22 |Created At | 23 |24 | |
---|---|---|
{{{ $place['name'] }}} | 30 |{{{ $place['created_at'] }}} | 31 |32 | Edit 33 | Delete 34 | | 35 |
14 | {{{ $checkin->user->first_name }}} {{{ $checkin->user->last_name }}} checked in at {{{ $checkin->place->name }}}! {{{ $checkin->created_at->diffForHumans() }}} 15 |
16 |No checkins available yet. Have you seeded your database?
22 |