├── .gitattributes ├── .gitignore ├── CONTRIBUTING.md ├── README.md ├── app ├── commands │ └── .gitkeep ├── config │ ├── app.php │ ├── auth.php │ ├── cache.php │ ├── compile.php │ ├── database.php │ ├── mail.php │ ├── packages │ │ └── .gitkeep │ ├── queue.php │ ├── remote.php │ ├── session.php │ ├── testing │ │ ├── cache.php │ │ └── session.php │ ├── view.php │ └── workbench.php ├── controllers │ ├── .gitkeep │ ├── BaseController.php │ └── HomeController.php ├── database │ ├── migrations │ │ ├── .gitkeep │ │ ├── 2014_02_27_225818_create_bears_table.php │ │ ├── 2014_02_27_230558_create_fish_table.php │ │ ├── 2014_02_27_230634_create_picnics_table.php │ │ ├── 2014_02_27_231158_create_bears_picnics_table.php │ │ └── 2014_03_02_222619_create_trees_table.php │ ├── production.sqlite │ └── seeds │ │ ├── .gitkeep │ │ └── DatabaseSeeder.php ├── filters.php ├── lang │ └── en │ │ ├── pagination.php │ │ ├── reminders.php │ │ └── validation.php ├── models │ ├── Bear.php │ ├── Fish.php │ ├── Picnic.php │ ├── Tree.php │ └── User.php ├── routes.php ├── start │ ├── artisan.php │ ├── global.php │ └── local.php ├── storage │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── logs │ │ └── .gitignore │ ├── meta │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── views │ │ └── .gitignore ├── tests │ ├── ExampleTest.php │ └── TestCase.php └── views │ ├── eloquent.blade.php │ ├── emails │ └── auth │ │ └── reminder.blade.php │ └── hello.php ├── artisan ├── bootstrap ├── autoload.php ├── paths.php └── start.php ├── composer.json ├── phpunit.xml ├── public ├── .htaccess ├── favicon.ico ├── index.php ├── packages │ └── .gitkeep └── robots.txt └── server.php /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bootstrap/compiled.php 2 | /vendor 3 | composer.phar 4 | composer.lock 5 | .env.local.php 6 | .env.php 7 | .DS_Store 8 | Thumbs.db -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Please submit all issues and pull requests to the [laravel/framework](http://github.com/laravel/framework) repository! -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A Guide to Using Laravel Eloquent 2 | 3 | View the [scotch.io tutorial](http://scotch.io/tutorials/php/a-guide-to-using-eloquent-orm-in-laravel) 4 | 5 | ## Usage 6 | 7 | 1. Install Laravel: `composer install --prefer-dist` 8 | 2. Change your database settings in `app/config/database.php` 9 | 3. Migrate your database: `php artisan migrate` 10 | 4. Seed your database: `php artisan db:seed` 11 | 5. View your app at: `http://example.com/eloquent` 12 | -------------------------------------------------------------------------------- /app/commands/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotch-io/laravel-eloquent-guide/bf7c4d8f2c0ee6f53ded7ff0d228d0740b184316/app/commands/.gitkeep -------------------------------------------------------------------------------- /app/config/app.php: -------------------------------------------------------------------------------- 1 | true, 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application URL 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This URL is used by the console to properly generate URLs when using 24 | | the Artisan command line tool. You should set this to the root of 25 | | your application so that it is used when running Artisan tasks. 26 | | 27 | */ 28 | 29 | 'url' => 'http://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 | | Encryption Key 60 | |-------------------------------------------------------------------------- 61 | | 62 | | This key is used by the Illuminate encrypter service and should be set 63 | | to a random, 32 character string, otherwise these encrypted strings 64 | | will not be safe. Please do this before deploying an application! 65 | | 66 | */ 67 | 68 | 'key' => 'YourSecretKey!!!', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Autoloaded Service Providers 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The service providers listed here will be automatically loaded on the 76 | | request to your application. Feel free to add your own services to 77 | | this array to grant expanded functionality to your applications. 78 | | 79 | */ 80 | 81 | 'providers' => array( 82 | 83 | 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 84 | 'Illuminate\Auth\AuthServiceProvider', 85 | 'Illuminate\Cache\CacheServiceProvider', 86 | 'Illuminate\Session\CommandsServiceProvider', 87 | 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 88 | 'Illuminate\Routing\ControllerServiceProvider', 89 | 'Illuminate\Cookie\CookieServiceProvider', 90 | 'Illuminate\Database\DatabaseServiceProvider', 91 | 'Illuminate\Encryption\EncryptionServiceProvider', 92 | 'Illuminate\Filesystem\FilesystemServiceProvider', 93 | 'Illuminate\Hashing\HashServiceProvider', 94 | 'Illuminate\Html\HtmlServiceProvider', 95 | 'Illuminate\Log\LogServiceProvider', 96 | 'Illuminate\Mail\MailServiceProvider', 97 | 'Illuminate\Database\MigrationServiceProvider', 98 | 'Illuminate\Pagination\PaginationServiceProvider', 99 | 'Illuminate\Queue\QueueServiceProvider', 100 | 'Illuminate\Redis\RedisServiceProvider', 101 | 'Illuminate\Remote\RemoteServiceProvider', 102 | 'Illuminate\Auth\Reminders\ReminderServiceProvider', 103 | 'Illuminate\Database\SeedServiceProvider', 104 | 'Illuminate\Session\SessionServiceProvider', 105 | 'Illuminate\Translation\TranslationServiceProvider', 106 | 'Illuminate\Validation\ValidationServiceProvider', 107 | 'Illuminate\View\ViewServiceProvider', 108 | 'Illuminate\Workbench\WorkbenchServiceProvider', 109 | 110 | ), 111 | 112 | /* 113 | |-------------------------------------------------------------------------- 114 | | Service Provider Manifest 115 | |-------------------------------------------------------------------------- 116 | | 117 | | The service provider manifest is used by Laravel to lazy load service 118 | | providers which are not needed for each request, as well to keep a 119 | | list of all of the services. Here, you may set its storage spot. 120 | | 121 | */ 122 | 123 | 'manifest' => storage_path().'/meta', 124 | 125 | /* 126 | |-------------------------------------------------------------------------- 127 | | Class Aliases 128 | |-------------------------------------------------------------------------- 129 | | 130 | | This array of class aliases will be registered when this application 131 | | is started. However, feel free to register as many as you wish as 132 | | the aliases are "lazy" loaded so they don't hinder performance. 133 | | 134 | */ 135 | 136 | 'aliases' => array( 137 | 138 | 'App' => 'Illuminate\Support\Facades\App', 139 | 'Artisan' => 'Illuminate\Support\Facades\Artisan', 140 | 'Auth' => 'Illuminate\Support\Facades\Auth', 141 | 'Blade' => 'Illuminate\Support\Facades\Blade', 142 | 'Cache' => 'Illuminate\Support\Facades\Cache', 143 | 'ClassLoader' => 'Illuminate\Support\ClassLoader', 144 | 'Config' => 'Illuminate\Support\Facades\Config', 145 | 'Controller' => 'Illuminate\Routing\Controller', 146 | 'Cookie' => 'Illuminate\Support\Facades\Cookie', 147 | 'Crypt' => 'Illuminate\Support\Facades\Crypt', 148 | 'DB' => 'Illuminate\Support\Facades\DB', 149 | 'Eloquent' => 'Illuminate\Database\Eloquent\Model', 150 | 'Event' => 'Illuminate\Support\Facades\Event', 151 | 'File' => 'Illuminate\Support\Facades\File', 152 | 'Form' => 'Illuminate\Support\Facades\Form', 153 | 'Hash' => 'Illuminate\Support\Facades\Hash', 154 | 'HTML' => 'Illuminate\Support\Facades\HTML', 155 | 'Input' => 'Illuminate\Support\Facades\Input', 156 | 'Lang' => 'Illuminate\Support\Facades\Lang', 157 | 'Log' => 'Illuminate\Support\Facades\Log', 158 | 'Mail' => 'Illuminate\Support\Facades\Mail', 159 | 'Paginator' => 'Illuminate\Support\Facades\Paginator', 160 | 'Password' => 'Illuminate\Support\Facades\Password', 161 | 'Queue' => 'Illuminate\Support\Facades\Queue', 162 | 'Redirect' => 'Illuminate\Support\Facades\Redirect', 163 | 'Redis' => 'Illuminate\Support\Facades\Redis', 164 | 'Request' => 'Illuminate\Support\Facades\Request', 165 | 'Response' => 'Illuminate\Support\Facades\Response', 166 | 'Route' => 'Illuminate\Support\Facades\Route', 167 | 'Schema' => 'Illuminate\Support\Facades\Schema', 168 | 'Seeder' => 'Illuminate\Database\Seeder', 169 | 'Session' => 'Illuminate\Support\Facades\Session', 170 | 'SSH' => 'Illuminate\Support\Facades\SSH', 171 | 'Str' => 'Illuminate\Support\Str', 172 | 'URL' => 'Illuminate\Support\Facades\URL', 173 | 'Validator' => 'Illuminate\Support\Facades\Validator', 174 | 'View' => 'Illuminate\Support\Facades\View', 175 | 176 | ), 177 | 178 | ); 179 | -------------------------------------------------------------------------------- /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' => 'appdb', 59 | 'username' => 'root', 60 | 'password' => 'password', 61 | 'charset' => 'utf8', 62 | 'collation' => 'utf8_unicode_ci', 63 | 'prefix' => '', 64 | ), 65 | 66 | 'pgsql' => array( 67 | 'driver' => 'pgsql', 68 | 'host' => 'localhost', 69 | 'database' => 'database', 70 | 'username' => 'root', 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/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 Postmark mail service, which will provide reliable delivery. 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 delivery e-mails to 39 | | users of your application. Like the host we have set this value to 40 | | stay compatible with the Postmark 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 | ); -------------------------------------------------------------------------------- /app/config/packages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotch-io/laravel-eloquent-guide/bf7c4d8f2c0ee6f53ded7ff0d228d0740b184316/app/config/packages/.gitkeep -------------------------------------------------------------------------------- /app/config/queue.php: -------------------------------------------------------------------------------- 1 | 'sync', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => array( 32 | 33 | 'sync' => array( 34 | 'driver' => 'sync', 35 | ), 36 | 37 | 'beanstalkd' => array( 38 | 'driver' => 'beanstalkd', 39 | 'host' => 'localhost', 40 | 'queue' => 'default', 41 | ), 42 | 43 | 'sqs' => array( 44 | 'driver' => 'sqs', 45 | 'key' => 'your-public-key', 46 | 'secret' => 'your-secret-key', 47 | 'queue' => 'your-queue-url', 48 | 'region' => 'us-east-1', 49 | ), 50 | 51 | 'iron' => array( 52 | 'driver' => 'iron', 53 | 'project' => 'your-project-id', 54 | 'token' => 'your-token', 55 | 'queue' => 'your-queue-name', 56 | ), 57 | 58 | 'redis' => array( 59 | 'driver' => 'redis', 60 | 'queue' => 'default', 61 | ), 62 | 63 | ), 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Failed Queue Jobs 68 | |-------------------------------------------------------------------------- 69 | | 70 | | These options configure the behavior of failed queue job logging so you 71 | | can control which database and table are used to store the jobs that 72 | | have failed. You may change them to any database / table you wish. 73 | | 74 | */ 75 | 76 | 'failed' => array( 77 | 78 | 'database' => 'mysql', 'table' => 'failed_jobs', 79 | 80 | ), 81 | 82 | ); 83 | -------------------------------------------------------------------------------- /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 | ); -------------------------------------------------------------------------------- /app/config/session.php: -------------------------------------------------------------------------------- 1 | 'file', 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session File Location 39 | |-------------------------------------------------------------------------- 40 | | 41 | | When using the native session driver, we need a location where session 42 | | files may be stored. A default has been set for you but a different 43 | | location may be specified. This is only needed for file sessions. 44 | | 45 | */ 46 | 47 | 'files' => storage_path().'/sessions', 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session Database Connection 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the "database" or "redis" session drivers, you may specify a 55 | | connection that should be used to manage these sessions. This should 56 | | correspond to a connection in your database configuration options. 57 | | 58 | */ 59 | 60 | 'connection' => null, 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Table 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" session driver, you may specify the table we 68 | | should use to manage the sessions. Of course, a sensible default is 69 | | provided for you; however, you are free to change this as needed. 70 | | 71 | */ 72 | 73 | 'table' => 'sessions', 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Sweeping Lottery 78 | |-------------------------------------------------------------------------- 79 | | 80 | | Some session drivers must manually sweep their storage location to get 81 | | rid of old sessions from storage. Here are the chances that it will 82 | | happen on a given request. By default, the odds are 2 out of 100. 83 | | 84 | */ 85 | 86 | 'lottery' => array(2, 100), 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Cookie Name 91 | |-------------------------------------------------------------------------- 92 | | 93 | | Here you may change the name of the cookie used to identify a session 94 | | instance by ID. The name specified here will get used every time a 95 | | new session cookie is created by the framework for every driver. 96 | | 97 | */ 98 | 99 | 'cookie' => 'laravel_session', 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Cookie Path 104 | |-------------------------------------------------------------------------- 105 | | 106 | | The session cookie path determines the path for which the cookie will 107 | | be regarded as available. Typically, this will be the root path of 108 | | your application but you are free to change this when necessary. 109 | | 110 | */ 111 | 112 | 'path' => '/', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Domain 117 | |-------------------------------------------------------------------------- 118 | | 119 | | Here you may change the domain of the cookie used to identify a session 120 | | in your application. This will determine which domains the cookie is 121 | | available to in your application. A sensible default has been set. 122 | | 123 | */ 124 | 125 | 'domain' => null, 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | HTTPS Only Cookies 130 | |-------------------------------------------------------------------------- 131 | | 132 | | By setting this option to true, session cookies will only be sent back 133 | | to the server if the browser has a HTTPS connection. This will keep 134 | | the cookie from being sent to you if it can not be done securely. 135 | | 136 | */ 137 | 138 | 'secure' => false, 139 | 140 | ); 141 | -------------------------------------------------------------------------------- /app/config/testing/cache.php: -------------------------------------------------------------------------------- 1 | 'array', 19 | 20 | ); -------------------------------------------------------------------------------- /app/config/testing/session.php: -------------------------------------------------------------------------------- 1 | 'array', 20 | 21 | ); -------------------------------------------------------------------------------- /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 | ); -------------------------------------------------------------------------------- /app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotch-io/laravel-eloquent-guide/bf7c4d8f2c0ee6f53ded7ff0d228d0740b184316/app/controllers/.gitkeep -------------------------------------------------------------------------------- /app/controllers/BaseController.php: -------------------------------------------------------------------------------- 1 | layout)) 13 | { 14 | $this->layout = View::make($this->layout); 15 | } 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /app/controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->string('name'); 20 | $table->string('type'); 21 | $table->integer('danger_level'); // this will be between 1-10 22 | 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::drop('bears'); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/database/migrations/2014_02_27_230558_create_fish_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->integer('weight'); // we'll use this to demonstrate searching by weight 20 | $table->integer('bear_id'); // this will contain our foreign key to the bears table 21 | 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::drop('fish'); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/database/migrations/2014_02_27_230634_create_picnics_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->string('name'); 20 | $table->integer('taste_level'); // just some random variable we wont need for this tutorial 21 | 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::drop('picnics'); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/database/migrations/2014_02_27_231158_create_bears_picnics_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->integer('bear_id'); // the id of the bear 20 | $table->integer('picnic_id'); // the id of the picnic that this bear is at 21 | 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::drop('bears_picnics'); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/database/migrations/2014_03_02_222619_create_trees_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->string('type'); 20 | $table->integer('age'); // how old is the tree 21 | $table->integer('bear_id'); // which bear climbs this tree 22 | 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::drop('trees'); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/database/production.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotch-io/laravel-eloquent-guide/bf7c4d8f2c0ee6f53ded7ff0d228d0740b184316/app/database/production.sqlite -------------------------------------------------------------------------------- /app/database/seeds/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotch-io/laravel-eloquent-guide/bf7c4d8f2c0ee6f53ded7ff0d228d0740b184316/app/database/seeds/.gitkeep -------------------------------------------------------------------------------- /app/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call('BearAppSeeder'); 16 | $this->command->info('Bear app seeds finished.'); // show information in the command line after everything is run 17 | } 18 | 19 | } 20 | 21 | // our own seeder class 22 | // usually this would be its own file 23 | class BearAppSeeder extends Seeder { 24 | 25 | public function run() { 26 | 27 | // clear our database ------------------------------------------ 28 | DB::table('bears')->delete(); 29 | DB::table('fish')->delete(); 30 | DB::table('picnics')->delete(); 31 | DB::table('trees')->delete(); 32 | DB::table('bears_picnics')->delete(); 33 | 34 | // seed our bears table ----------------------- 35 | // we'll create three different bears 36 | 37 | // bear 1 is named Lawly. She is extremely dangerous. Especially when hungry. 38 | $bearLawly = Bear::create(array( 39 | 'name' => 'Lawly', 40 | 'type' => 'Grizzly', 41 | 'danger_level' => 8 42 | )); 43 | 44 | // bear 2 is named Cerms. He has a loud growl but is pretty much harmless. 45 | $bearCerms = Bear::create(array( 46 | 'name' => 'Cerms', 47 | 'type' => 'Black', 48 | 'danger_level' => 4 49 | )); 50 | 51 | // bear 3 is named Adobot. He is a polar bear. He drinks vodka. 52 | $bearAdobot = Bear::create(array( 53 | 'name' => 'Adobot', 54 | 'type' => 'Polar', 55 | 'danger_level' => 3 56 | )); 57 | 58 | $this->command->info('The bears are alive!'); 59 | 60 | // seed our fish table ------------------------ 61 | // our fish wont have names... because theyre going to be eaten 62 | 63 | // we will use the variables we used to create the bears to get their id 64 | 65 | $fishOne = Fish::create(array( 66 | 'weight' => 5, 67 | 'bear_id' => $bearLawly->id 68 | )); 69 | $fishTwo = Fish::create(array( 70 | 'weight' => 12, 71 | 'bear_id' => $bearCerms->id 72 | )); 73 | $fishThree = Fish::create(array( 74 | 'weight' => 4, 75 | 'bear_id' => $bearAdobot->id 76 | )); 77 | 78 | $this->command->info('They are eating fish!'); 79 | 80 | // seed our trees table --------------------- 81 | // give two trees to lawly 82 | Tree::create(array( 83 | 'type' => 'Redwood', 84 | 'age' => 500, 85 | 'bear_id' => $bearLawly->id 86 | )); 87 | Tree::create(array( 88 | 'type' => 'Oak', 89 | 'age' => 400, 90 | 'bear_id' => $bearLawly->id 91 | )); 92 | 93 | $this->command->info('Climb bears! Be free!'); 94 | 95 | // seed our picnics table --------------------- 96 | 97 | // we will create one picnic and apply all bears to this one picnic 98 | $picnicYellowstone = Picnic::create(array( 99 | 'name' => 'Yellowstone', 100 | 'taste_level' => 6 101 | )); 102 | $picnicGrandCanyon = Picnic::create(array( 103 | 'name' => 'Grand Canyon', 104 | 'taste_level' => 5 105 | )); 106 | 107 | // link our bears to picnics --------------------- 108 | // for our purposes we'll just add all bears to both picnics for our many to many relationship 109 | $bearLawly->picnics()->attach($picnicYellowstone->id); 110 | $bearLawly->picnics()->attach($picnicGrandCanyon->id); 111 | 112 | $bearCerms->picnics()->attach($picnicYellowstone->id); 113 | $bearCerms->picnics()->attach($picnicGrandCanyon->id); 114 | 115 | $bearAdobot->picnics()->attach($picnicYellowstone->id); 116 | $bearAdobot->picnics()->attach($picnicGrandCanyon->id); 117 | 118 | $this->command->info('They are terrorizing picnics!'); 119 | 120 | } 121 | 122 | } -------------------------------------------------------------------------------- /app/filters.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 18 | 'next' => 'Next »', 19 | 20 | ); -------------------------------------------------------------------------------- /app/lang/en/reminders.php: -------------------------------------------------------------------------------- 1 | "Passwords must be at least six characters and match the confirmation.", 17 | 18 | "user" => "We can't find a user with that e-mail address.", 19 | 20 | "token" => "This password reset token is invalid.", 21 | 22 | "sent" => "Password reminder sent!", 23 | 24 | ); 25 | -------------------------------------------------------------------------------- /app/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | "The :attribute must be accepted.", 17 | "active_url" => "The :attribute is not a valid URL.", 18 | "after" => "The :attribute must be a date after :date.", 19 | "alpha" => "The :attribute may only contain letters.", 20 | "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.", 21 | "alpha_num" => "The :attribute may only contain letters and numbers.", 22 | "array" => "The :attribute must be an array.", 23 | "before" => "The :attribute must be a date before :date.", 24 | "between" => array( 25 | "numeric" => "The :attribute must be between :min and :max.", 26 | "file" => "The :attribute must be between :min and :max kilobytes.", 27 | "string" => "The :attribute must be between :min and :max characters.", 28 | "array" => "The :attribute must have between :min and :max items.", 29 | ), 30 | "confirmed" => "The :attribute confirmation does not match.", 31 | "date" => "The :attribute is not a valid date.", 32 | "date_format" => "The :attribute does not match the format :format.", 33 | "different" => "The :attribute and :other must be different.", 34 | "digits" => "The :attribute must be :digits digits.", 35 | "digits_between" => "The :attribute must be between :min and :max digits.", 36 | "email" => "The :attribute must be a valid email address.", 37 | "exists" => "The selected :attribute is invalid.", 38 | "image" => "The :attribute must be an image.", 39 | "in" => "The selected :attribute is invalid.", 40 | "integer" => "The :attribute must be an integer.", 41 | "ip" => "The :attribute must be a valid IP address.", 42 | "max" => array( 43 | "numeric" => "The :attribute may not be greater than :max.", 44 | "file" => "The :attribute may not be greater than :max kilobytes.", 45 | "string" => "The :attribute may not be greater than :max characters.", 46 | "array" => "The :attribute may not have more than :max items.", 47 | ), 48 | "mimes" => "The :attribute must be a file of type: :values.", 49 | "min" => array( 50 | "numeric" => "The :attribute must be at least :min.", 51 | "file" => "The :attribute must be at least :min kilobytes.", 52 | "string" => "The :attribute must be at least :min characters.", 53 | "array" => "The :attribute must have at least :min items.", 54 | ), 55 | "not_in" => "The selected :attribute is invalid.", 56 | "numeric" => "The :attribute must be a number.", 57 | "regex" => "The :attribute format is invalid.", 58 | "required" => "The :attribute field is required.", 59 | "required_if" => "The :attribute field is required when :other is :value.", 60 | "required_with" => "The :attribute field is required when :values is present.", 61 | "required_without" => "The :attribute field is required when :values is not present.", 62 | "required_without_all" => "The :attribute field is required when none of :values are present.", 63 | "same" => "The :attribute and :other must match.", 64 | "size" => array( 65 | "numeric" => "The :attribute must be :size.", 66 | "file" => "The :attribute must be :size kilobytes.", 67 | "string" => "The :attribute must be :size characters.", 68 | "array" => "The :attribute must contain :size items.", 69 | ), 70 | "unique" => "The :attribute has already been taken.", 71 | "url" => "The :attribute format is invalid.", 72 | 73 | /* 74 | |-------------------------------------------------------------------------- 75 | | Custom Validation Language Lines 76 | |-------------------------------------------------------------------------- 77 | | 78 | | Here you may specify custom validation messages for attributes using the 79 | | convention "attribute.rule" to name the lines. This makes it quick to 80 | | specify a specific custom language line for a given attribute rule. 81 | | 82 | */ 83 | 84 | 'custom' => array(), 85 | 86 | /* 87 | |-------------------------------------------------------------------------- 88 | | Custom Validation Attributes 89 | |-------------------------------------------------------------------------- 90 | | 91 | | The following language lines are used to swap attribute place-holders 92 | | with something more reader friendly such as E-Mail Address instead 93 | | of "email". This simply helps us make messages a little cleaner. 94 | | 95 | */ 96 | 97 | 'attributes' => array(), 98 | 99 | ); 100 | -------------------------------------------------------------------------------- /app/models/Bear.php: -------------------------------------------------------------------------------- 1 | hasOne('Fish'); // this matches the Eloquent model 14 | } 15 | 16 | // each bear climbs many trees 17 | public function trees() { 18 | return $this->hasMany('Tree'); 19 | } 20 | 21 | // each bear BELONGS to a picnic 22 | public function picnics() { 23 | return $this->belongsToMany('Picnic', 'bears_picnics', 'bear_id', 'picnic_id'); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /app/models/Fish.php: -------------------------------------------------------------------------------- 1 | belongsTo('Bear'); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /app/models/Picnic.php: -------------------------------------------------------------------------------- 1 | belongsToMany('Bear', 'bears_picnics', 'picnic_id', 'bear_id'); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /app/models/Tree.php: -------------------------------------------------------------------------------- 1 | belongsTo('Bear'); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /app/models/User.php: -------------------------------------------------------------------------------- 1 | getKey(); 30 | } 31 | 32 | /** 33 | * Get the password for the user. 34 | * 35 | * @return string 36 | */ 37 | public function getAuthPassword() 38 | { 39 | return $this->password; 40 | } 41 | 42 | /** 43 | * Get the e-mail address where password reminders are sent. 44 | * 45 | * @return string 46 | */ 47 | public function getReminderEmail() 48 | { 49 | return $this->email; 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /app/routes.php: -------------------------------------------------------------------------------- 1 | with('bears', Bear::all()); 29 | 30 | }); -------------------------------------------------------------------------------- /app/start/artisan.php: -------------------------------------------------------------------------------- 1 | client->request('GET', '/'); 13 | 14 | $this->assertTrue($this->client->getResponse()->isOk()); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /app/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Eloquent Bears 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | @foreach ($bears as $bear) 20 | 21 | 22 |

{{ $bear->name }} {{ $bear->type }}: Level {{ $bear->danger_level }}

23 | 24 | 25 |

Trees

26 | @foreach ($bear->trees as $tree) 27 |

{{ $tree->type }}

28 | @endforeach 29 | 30 | 31 |

Picnics

32 | @foreach ($bear->picnics as $picnic) 33 |

{{ $picnic->name }}: Taste Level {{ $picnic->taste_level }}

34 | @endforeach 35 | 36 | @endforeach 37 | 38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /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 |
12 | 13 | -------------------------------------------------------------------------------- /app/views/hello.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Laravel PHP Framework 6 | 35 | 36 | 37 |
38 | 39 |

You have arrived.

40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | setRequestForConsoleEnvironment(); 45 | 46 | $artisan = Illuminate\Console\Application::start($app); 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Run The Artisan Application 51 | |-------------------------------------------------------------------------- 52 | | 53 | | When we run the console application, the current CLI command will be 54 | | executed in this console and the response sent back to a terminal 55 | | or another output device for the developers. Here goes nothing! 56 | | 57 | */ 58 | 59 | $status = $artisan->run(); 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Shutdown The Application 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Once Artisan has finished running. We will fire off the shutdown events 67 | | so that any final work may be done by the application before we shut 68 | | down the process. This is the last thing to happen to the request. 69 | | 70 | */ 71 | 72 | $app->shutdown(); 73 | 74 | exit($status); -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | __DIR__.'/../app', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Public Path 21 | |-------------------------------------------------------------------------- 22 | | 23 | | The public path contains the assets for your web application, such as 24 | | your JavaScript and CSS files, and also contains the primary entry 25 | | point for web requests into these applications from the outside. 26 | | 27 | */ 28 | 29 | 'public' => __DIR__.'/../public', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Base Path 34 | |-------------------------------------------------------------------------- 35 | | 36 | | The base path is the root of the Laravel installation. Most likely you 37 | | will not need to change this value. But, if for some wild reason it 38 | | is necessary you will do so here, just proceed with some caution. 39 | | 40 | */ 41 | 42 | 'base' => __DIR__.'/..', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Storage Path 47 | |-------------------------------------------------------------------------- 48 | | 49 | | The storage path is used by Laravel to store cached Blade views, logs 50 | | and other pieces of information. You may modify the path here when 51 | | you want to change the location of this directory for your apps. 52 | | 53 | */ 54 | 55 | 'storage' => __DIR__.'/../app/storage', 56 | 57 | ); 58 | -------------------------------------------------------------------------------- /bootstrap/start.php: -------------------------------------------------------------------------------- 1 | detectEnvironment(array( 28 | 29 | 'local' => array('your-machine-name'), 30 | 31 | )); 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Bind Paths 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here we are binding the paths configured in paths.php to the app. You 39 | | should not be changing these here. If you need to change these you 40 | | may do so within the paths.php file and they will be bound here. 41 | | 42 | */ 43 | 44 | $app->bindInstallPaths(require __DIR__.'/paths.php'); 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Load The Application 49 | |-------------------------------------------------------------------------- 50 | | 51 | | Here we will load this Illuminate application. We will keep this in a 52 | | separate location so we can isolate the creation of an application 53 | | from the actual running of the application with a given request. 54 | | 55 | */ 56 | 57 | $framework = $app['path.base']. 58 | '/vendor/laravel/framework/src'; 59 | 60 | require $framework.'/Illuminate/Foundation/start.php'; 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Return The Application 65 | |-------------------------------------------------------------------------- 66 | | 67 | | This script returns the application instance. The instance is given to 68 | | the calling script so we can separate the building of the instances 69 | | from the actual running of the application and sending responses. 70 | | 71 | */ 72 | 73 | return $app; 74 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "require": { 7 | "laravel/framework": "4.1.*" 8 | }, 9 | "autoload": { 10 | "classmap": [ 11 | "app/commands", 12 | "app/controllers", 13 | "app/models", 14 | "app/database/migrations", 15 | "app/database/seeds", 16 | "app/tests/TestCase.php" 17 | ] 18 | }, 19 | "scripts": { 20 | "post-install-cmd": [ 21 | "php artisan clear-compiled", 22 | "php artisan optimize" 23 | ], 24 | "post-update-cmd": [ 25 | "php artisan clear-compiled", 26 | "php artisan optimize" 27 | ], 28 | "post-create-project-cmd": [ 29 | "php artisan key:generate" 30 | ] 31 | }, 32 | "config": { 33 | "preferred-install": "dist" 34 | }, 35 | "minimum-stability": "stable" 36 | } 37 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./app/tests/ 16 | 17 | 18 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes... 9 | RewriteRule ^(.*)/$ /$1 [L,R=301] 10 | 11 | # Handle Front Controller... 12 | RewriteCond %{REQUEST_FILENAME} !-d 13 | RewriteCond %{REQUEST_FILENAME} !-f 14 | RewriteRule ^ index.php [L] 15 | 16 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotch-io/laravel-eloquent-guide/bf7c4d8f2c0ee6f53ded7ff0d228d0740b184316/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/scotch-io/laravel-eloquent-guide/bf7c4d8f2c0ee6f53ded7ff0d228d0740b184316/public/packages/.gitkeep -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 |