Download the PHP package muratsplat/multilang without Composer
On this page you can find all versions of the php package muratsplat/multilang. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download muratsplat/multilang
More information about muratsplat/multilang
Files in muratsplat/multilang
Package multilang
Short Description A Laravel package is make be easy to CRUD ORM proccess for multi languages contents.
License GPL-3.0+
Informations about the package multilang
MultiLang Package For Laravel 4.2
A Laravel extension is make be easy to CRUD ORM proccess for multi languages contents.
!! The development of this project is discontinued !!
Requiretments
- PHP >=5.4 or HHVM lastest
- Composer
- Laravel 4.2.x
Installing
Add muratsplat/multilang
as a requirement to composer.json
Update your packages with composer update
or install with composer install
.
You can also add the package using composer require muratsplat/multilang
on your terminal.
This package only supports Composer to instaling.
Configuration
Firstly you should add the package's service provider to your laravel app
Also you can add the package's alias
Finally install to the package's configuration via artisan like this
in your project's main folder:
Now you can change the package's configuration by editing ..app/config/packages/muratsplat/multilang/config.php
How to use in Example
Let's imagine simple Laravel App. We want to have multi language pages. In this case common way is creating two models firstly. For them let's create tables via Laravel Migration.
take a look at:
Pages will be our main model's table. Only common attributes should be in the table. It likes this migrate:
Second step is creating other table for just multi language contents..
Let's edit created migrate again..
It can be useful to have Language model. For every web app I create an struct to manage languages. In basic you can create Languge model like this:
If you decide to create Language model don't forget make reference as like
You can create default data for language models by using seeder class
Tables are ready. It is the turn of creating models.
Main model will be Page model in example. Main model must be implement 'Muratsplat\Multilang\Interfaces\MainInterface' and it must be used 'Muratsplat\Multilang\Traits\MainTrait'.
Page Model
For pageLangs table we are creating PageLang Model. PageLang must be implement 'Muratsplat\Multilang\Interfaces\LangInterface' and must be used 'Muratsplat\Multilang\Traits\LangTrait' trait in it. That's like this:
Multilang gets with new rule. 'RequiredForDefaultLang' rule validates elements for default language id. If default language is Turkish, and if Turkish element is empty, validation is failed.
RequiredForDefaultLang accepts tree parameters. First of these prefix for picking elements up and second parameter is default language id and also last parameter is replacer in error message.
You can add a message for the rule by editing '..app/lang/en/validation.php'.
example:
Validation rules can be in models. But it is not required. You can add rules in your controller. It is recommended that rules is in models. This make keep clean on your controller.
Dynamic Form Example
You can create form as down on view layer.
This form sends post data to a controller...
You can use MultiLang on your controller..
let's create a wrapper to access two models at one point
You can force to show wanted language model like this
Events
Event Name | Event Parameter | Statement |
---|---|---|
multilang.wrapper.creating | Muratsplat\Multilag\MultiLang Object |
When new Wrapper is creating, this event is fired. |
multilang.crud.creating | Muratsplat\Multilag\MultiLang Object |
When new models is creating, this event is fired. |
multilang.crud.updating | Muratsplat\Multilag\MultiLang Object |
When models is updating, this event is fired. |
multilang.crud.deleting | Muratsplat\Multilag\MultiLang Object |
When models is deleting, this event is fired. |
You can set wanted language by using MultiLang Event
Todos
- Partial Caching Support(without main model) :+1:
- Supports PHP7
- To plan all language attributes stores in one table on database :point_left:
- Full Caching Support
- Clean and Simple Documentation
- Fixing major bugs
- Releasing Stable version for L4 and L5
License
Copyright (C) 2014 Murat ÖDÜNÇ GPLv3
All versions of multilang with dependencies
illuminate/support Version 4.2.*
illuminate/database Version 4.2.*
illuminate/config Version 4.2.*
illuminate/validation Version 4.2.*
illuminate/events Version 4.2.*