From 00edb1db8c039ad9a7ac8badd5a32b399b3a7864 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 3 Oct 2012 12:19:11 +0200 Subject: [PATCH 1/6] clarified table naming conventions --- laravel/documentation/database/eloquent.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/laravel/documentation/database/eloquent.md b/laravel/documentation/database/eloquent.md index 09493db0..5c36e292 100644 --- a/laravel/documentation/database/eloquent.md +++ b/laravel/documentation/database/eloquent.md @@ -245,22 +245,24 @@ ### Many-To-Many Many-to-many relationships are the most complicated of the three relationships. But don't worry, you can do this. For example, assume a User has many Roles, but a Role can also belong to many Users. Three database tables must be created to accomplish this relationship: a **users** table, a **roles** table, and a **role_user** table. The structure for each table looks like this: -**Users:** +**users:** id - INTEGER email - VARCHAR -**Roles:** +**roles:** id - INTEGER name - VARCHAR -**Role_User:** +**role_user:** id - INTEGER user_id - INTEGER role_id - INTEGER +Tables contain many records and are consequently plural. Pivot tables used in **has\_many\_and\_belongs\_to** relationships are named by combining the singular names of the two related models arranged alphabetically and concatenated them with an underscore. + Now you're ready to define the relationship on your models using the **has\_many\_and\_belongs\_to** method: class User extends Eloquent { @@ -280,7 +282,7 @@ ### Many-To-Many $roles = User::find(1)->roles; -As you may have noticed, the default name of the intermediate table is the singular names of the two related models arranged alphabetically and concatenated by an underscore. However, you are free to specify your own table name. Simply pass the table name in the second parameter to the **has\_and\_belongs\_to\_many** method: +If your table names don't follow conventions, simply pass the table name in the second parameter to the **has\_and\_belongs\_to\_many** method: class User extends Eloquent { From f53f07df4a59a3a35ed8fc07711b6d440d433ef9 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Wed, 3 Oct 2012 13:24:05 +0300 Subject: [PATCH 2/6] Update laravel/documentation/database/eloquent.md minor grammar update in docs --- laravel/documentation/database/eloquent.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/database/eloquent.md b/laravel/documentation/database/eloquent.md index 5c36e292..f1643717 100644 --- a/laravel/documentation/database/eloquent.md +++ b/laravel/documentation/database/eloquent.md @@ -261,7 +261,7 @@ ### Many-To-Many user_id - INTEGER role_id - INTEGER -Tables contain many records and are consequently plural. Pivot tables used in **has\_many\_and\_belongs\_to** relationships are named by combining the singular names of the two related models arranged alphabetically and concatenated them with an underscore. +Tables contain many records and are consequently plural. Pivot tables used in **has\_many\_and\_belongs\_to** relationships are named by combining the singular names of the two related models arranged alphabetically and concatenating them with an underscore. Now you're ready to define the relationship on your models using the **has\_many\_and\_belongs\_to** method: From 97013cd816af5c18f8022a466a777204a7ad3060 Mon Sep 17 00:00:00 2001 From: matz3 Date: Sun, 14 Oct 2012 18:29:13 +0200 Subject: [PATCH 3/6] Spelling mistake correction in documentation Added missing 's' in the word 'is' (Laravel Overview). Signed-off-by: matz3 --- laravel/documentation/home.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/home.md b/laravel/documentation/home.md index 5545a492..695526cc 100644 --- a/laravel/documentation/home.md +++ b/laravel/documentation/home.md @@ -29,7 +29,7 @@ ## What Makes Laravel Different? - **Reverse Routing** allows you to create links to named routes. When creating links just use the route's name and Laravel will automatically insert the correct URI. This allows you to change your routes at a later time and Laravel will update all of the relevant links site-wide. - **Restful Controllers** are an optional way to separate your GET and POST request logic. In a login example your controller's get_login() action would serve up the form and your controller's post_login() action would accept the posted form, validate, and either redirect to the login form with an error message or redirect your user to their dashboard. - **Class Auto Loading** keeps you from having to maintain an autoloader configuration and from loading unnecessary components when they won't be used. Want to use a library or model? Don't bother loading it, just use it. Laravel will handle the rest. -- **View Composers** are blocks of code that can be run when a view is loaded. A good example of this would be a blog side-navigation view that contains a list of random blog posts. Your composer would contain the logic to load the blog posts so that all you have to do i load the view and it's all ready for you. This keeps you from having to make sure that your controllers load the a bunch of data from your models for views that are unrelated to that method's page content. +- **View Composers** are blocks of code that can be run when a view is loaded. A good example of this would be a blog side-navigation view that contains a list of random blog posts. Your composer would contain the logic to load the blog posts so that all you have to do is load the view and it's all ready for you. This keeps you from having to make sure that your controllers load the a bunch of data from your models for views that are unrelated to that method's page content. - **The IoC container** (Inversion of Control) gives you a method for generating new objects and optionally instantiating and referencing singletons. IoC means that you'll rarely ever need to bootstrap any external libraries. It also means that you can access these objects from anywhere in your code without needing to deal with an inflexible monolithic structure. - **Migrations** are version control for your database schemas and they are directly integrated into Laravel. You can both generate and run migrations using the "Artisan" command-line utility. Once another member makes schema changes you can update your local copy from the repository and run migrations. Now you're up to date, too! - **Unit-Testing** is an important part of Laravel. Laravel itself sports hundreds of tests to help ensure that new changes don't unexpectedly break anything. This is one of the reasons why Laravel is widely considered to have some of the most stable releases in the industry. Laravel also makes it easy for you to write unit-tests for your own code. You can then run tests with the "Artisan" command-line utility. From 9b63f65408567c0c5df9c8e1f296c4a12713a892 Mon Sep 17 00:00:00 2001 From: everclear Date: Mon, 15 Oct 2012 15:50:10 +0200 Subject: [PATCH 4/6] link_to_route requires 3 parameters if wildcard values are required --- laravel/documentation/views/html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/documentation/views/html.md b/laravel/documentation/views/html.md index aabe244d..e94e9e14 100644 --- a/laravel/documentation/views/html.md +++ b/laravel/documentation/views/html.md @@ -70,7 +70,7 @@ #### Generating a link to a named route: #### Generating a link to a named route with wildcard values: - $url = HTML::link_to_route('profile', array($username)); + $url = HTML::link_to_route('profile', 'User Profile', array($username)); *Further Reading:* From 7eb5be794cc935ad6a32a46ad392acc74aee7c00 Mon Sep 17 00:00:00 2001 From: aebersold Date: Tue, 16 Oct 2012 17:55:50 +0200 Subject: [PATCH 5/6] documentation error, wrong date format --- laravel/documentation/validation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/laravel/documentation/validation.md b/laravel/documentation/validation.md index 0f17dec0..eacb6625 100644 --- a/laravel/documentation/validation.md +++ b/laravel/documentation/validation.md @@ -196,11 +196,11 @@ ### Dates #### Validate that a date attribute is before a given date: - 'birthdate' => 'before:1986-28-05'; + 'birthdate' => 'before:1986-05-28'; #### Validate that a date attribute is after a given date: - 'birthdate' => 'after:1986-28-05'; + 'birthdate' => 'after:1986-05-28'; > **Note:** The **before** and **after** validation rules use the **strtotime** PHP function to convert your date to something the rule can understand. @@ -450,4 +450,4 @@ #### Adding a custom validation rule: Notice that the method is named using the **validate_rule** naming convention. The rule is named "awesome" so the method must be named "validate_awesome". This is one way in which registering your custom rules and extending the Validator class are different. Validator classes simply need to return true or false. That's it! -Keep in mind that you'll still need to create a custom message for any validation rules that you create. The method for doing so is the same no matter how you define your rule! \ No newline at end of file +Keep in mind that you'll still need to create a custom message for any validation rules that you create. The method for doing so is the same no matter how you define your rule! From a7ea27d0a08286a495830c6acbaf96fa772597be Mon Sep 17 00:00:00 2001 From: Zander Baldwin Date: Sat, 27 Oct 2012 01:09:54 +0000 Subject: [PATCH 6/6] Update "docs/views/html.md", parse error in example code. The example code for the `HTML::entities()` method in the documentation had unescaped apostrophes (single quotes) in the string passed as the first parameter. A parse error would have resulted should someone try to use that code. --- laravel/documentation/views/html.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/documentation/views/html.md b/laravel/documentation/views/html.md index e94e9e14..629387c8 100644 --- a/laravel/documentation/views/html.md +++ b/laravel/documentation/views/html.md @@ -21,11 +21,11 @@ ## Entities #### Converting a string to its entity representation: - echo HTML::entities(''); + echo HTML::entities(''); #### Using the "e" global helper: - echo e(''); + echo e(''); ## Scripts And Style Sheets