october cms: relations

Resources:

Example:

This is a (hopefully correct) working example of a 1 to n relation.

1toN

 

 

Forms with Laravel 5

Some components have been removed from Laravel core with version 5.

For example the Forms & HTML component.

Good to see them again here: https://laravelcollective.com

Example form:

 

Laravel Lumen: NotFoundHttpException after installation

After a fresh installation of Laravel Lumen, I got a NotFoundHttpException for the index route. I copied the .env.example  file to .env  and set up the APP_KEY. But I still got the NotFoundHttpException.

After searching the internet for some time I found out these steps:

In public/index.php change the last line to this:

And to make the .env  file working go to bootstrap/app.php  and uncomment the following line:

 

http://stackoverflow.com/questions/29728973/notfoundhttpexception-with-lumen

 

File upload by ajax with Laravel and jQuery

Some Controller method in Laravel 4.2, with some JSON responses:

Some jQuery code, which handles the form submit and the results of the upload. Additionally we have notifications for the user.

 

Call an Artisan Command from anywhere

Small note on how to call an Artisan Command from a Controller or somewhere else:

 

persistent language prefixing with laravel

Here I want to describe how to build up a persistent language prefixing for your URLs in Laravel.

This technique requires, that the routes are named! This is just a quick sketch, and not fully complete!

In the app::before filter I detect the language. If no language was detected I redirect to the default language.

The Routes are working with a locale pattern. Here is an example:

In my global.php (e.g.) I put a new route() function and the function to do a language switch. The language switch changes just the current language but keeps the current page displayed.

Line breaks in Blade sections and yields

How to avoid line breaks in Laravel blade sections or yields.

The problem

The solution

Using @parent or other blade specials:

Overriding an implementation inside the IoC

This example overrides a model with your custom implementation.

Example 2:

 

Laravel: resolve the logged in user from the IoC container

Behind the scenes, the Auth facade is bound to Illuminate\Auth\AuthManager. Means, you need to resolve the AuthManager.

This example resolve the currently logged in user from the IoC container:

Link to reference:

http://laravel.com/api/4.2/Illuminate/Auth/AuthManager.html