Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching.
Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked.
Find the config file of MySQL server (usually, my.ini
or my.cnf
), and add two following lines in [mysqld]
section:
innodb_file_format=BARRACUDA
innodb_large_prefix=ON
Those lines help MySQL server work better with multi-language transaction database.
- Laravel Docs ~ Embed Framework.
- Mcamara/LaravelLocalization ~ Embed Solution for URL/System Runtime localizing
- Laravel/Socialite ~ Embed Solution for Social Login
- Zizaco/Entrust ~ Embed Solution for applying Roles/Permissions for users
- Dimsav/LaravelTranslatable ~ Embed Solution for Database-level localizing
- Mews/Purifier ~ Embed Solution for filtering HTML inputs
- Admin Template + Home Template ~ Embed Templates for Admin pages & Home/User pages
Steps by steps to build a module:
Commands:
-
Create file:
php artisan make:migration {file_name} --create={table_name}
-
Migrate:
php artisan migrate
Reference: Laravel/Database/Migrations
After created, file appears at folder root\database\migrations
Commands
-
Create file:
php artisan make:seeder {seeding_class}
-
Seed file:
php artisan db:seed --class={seeding)class
Reference: Laravel/Database/Migrations
After created, file appears at folder root\database\seeds
Commands: php artisan make:Model {model_name}
Reference: Laravel/Eloquent ORM
After created, file containing Class of Data Model appears at folder root\app
Open model file, insert those properties into the class:
// required, define the attached table
protected $table='{table_name_of_model}' // eg $table='users'
// required, define the assignable fields, without this defined, you can't save the edited fields of the model
protected $fillable={array of column names of tables that can be edited} // eg: $fillable=['name','email','password']
// optional, define the fields which include in json format of the model
protected $hidden={array of column names of tables that can be used in json format} // eg: $hidden=['name','email] => User::toJson() = {'name':'{name}','email'=>'{email}'}, the password field is not shown
For multi-language models, use Translatable model featured by Solutions/Resources > Dimsav/LaravelTranslatable
Routes defined in root\app\Http\routes.php
Eg: Route::post(LaravelLocalization::transRoute('routes.admin/questions/add'), 'Admin\QuestionController@store');
-
post : method for routes {get,post, ..}
-
LaravelLocalization::transRoute('routes.admin/questions/add') : the routes, can be translatable (use the transRoute method) or not
-
Admin\QuestionController@store : the method of controller will process the routes and return the response, format:
{folder_path}\{controller_name}@{method_name}
(see more at Step 4)
Reference: Laravel/Routing
Location to put routes based on types of routes:
- Non-localization Routes:
- for accessing without providing locale in uri path
- Non-localization Routes:
- for accessing without providing locale in uri path
Non-localization Routes
section
- Localization Routes:
- the route must be translatable
- user request must provide locale in the uri path, if not, the fall back locale will be automatically assigned
Localization Routes
section- return blade view
- Api Routes:
- non-localized routes
- for ajax requests, restful services
- return json(p) objects
- Anonymous Routes:
- localized routes
- accessed by everyone
Anonymous Routes
section
- Auth Routes:
- localized routes
- accessing users must be authenticated users
All User Role
section
- Admin Routes:
- auth routes
- for admin role/permission
Admin Role
section
- Supporter Routes:
- auth routes
- for Supporter role/permission
Supporter Role
section
- Teacher Routes:
- auth routes
- for Teacher role/permission
Teacher Role
section
- Student Routes:
- auth routes
- for Student role/permission
Student Role
section
For multi-language user requests, use translatable route featured by Solutions/Resources > Mcamara/LaravelLocalization
It means when add translatable routes in root\app\Http\routes.php
, you should add the translated route in localized routes files:
root\resources\lang\{locale}\routes.php
Create file:
- Command:
php artisan make:controller {folder_path}\{controller_name}
Reference Laravel\Controllesr
After created, file appears at folder 'root\app\Http\Controllers{folder_path}'
- {folder_path} :
- Admin : for admin routing controllers
- APIV1 : for api routing controllers
- Pages : for anonymouse/teacher/student/supporter routting controllers
Code Template:
public function {method_name}(Request $request (, (optional) $param_1, (optional) $param_2, ...)) {
// code
}
-
$request : hold all request info & params (GET, POST params ..)
-
$param_n : extra params defined in routing, (more at here)
Reference Laravel\Requests
You should validate the user inputs if they exists before any processing
Reference Laravel\Validation
You should filter the user inputs if they're HTML string to avoid attacks from bad guys, using Solutions/Resources > Mews/Purifier
To store uploaded files, see Laravel/Filesystem
-
Create specific folder in
root\storage\app\{specific_folder}
-
Create/Modify the gitignore files, see the eg of
root\storage\app\.gitignore
&profile_pictures
& his.gitignore
-
Create a local disk in
root\config\filesystems.php
(see the eg ofprofile_pictures
disk)
In a method of controllers, you should response the result of processing of the user requests (abort/redirection/json/blade template).
Reference Laravel\Responses
Reference Laravel/Blade Template
If not ajax request, you should return a blade view in a method of controllers.
Master templates (for admin & home frames) in folder root\resources\views\master
Admin pages template @ root\resources\views\admin
(will extends from admin & its own branches master)
Home pages template @ root\resources\views\admin
(will extends from layout & its own branches master)
Examples of HTML template should be taken from resources at Solutions/Resources > Admin Template + Home Template
To localize the UI, use function trans()
, see Laravel/Localization
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at [email protected]. All security vulnerabilities will be promptly addressed.
Licensed under the MIT license