Coding Rules and Standerds

GitHub Rules

Pull request rules ( do not close your task without doing the below points )

  1. On each task you must create a new branch, branch name must be the Exact name of your task Example "sm-022-adding-students".
  2. Pull request description
    1. Please include a summary of the change or which issue is fixed.
    2. Mark what type of changes you have done, you will find a form to fill once you create the pull request
  3. add the pull request to your task
  4. check and resolve if there is any conflict.
  5. each task you are handling must be in a separate branch.
  6. if the task moved to bugs and fixes check the comments and must be resolved.
  7. Must add commands (npm, composer or artisan) that needs to be run after code deployment on the server. must add it in the PR description and Your Task on CRM
  8. Check what you are going to push to your branch before pushing never push useless and garbage data.

NOTE

Pull requests title must contain the task name and developer name Example ( SM069 David V )

Multi-Language Rule

all the static strings must be written in  {{__("static string")}}  for multilanguage

Coding Rules:

General:

  1. Never do any work in main branch
  2. Always create a branch for your task
  3. Branch names must be related to your task
  4. Always Check git status before commiting your changes.
  5. Your commits must be descriptive.

Front end rules:

  1. For Blade  Must use livewire
  2. try to avoid vanila js
  3. try to create component for common elements
  4. include common js and css files in layout file
  5. for inline js or on demand scripts use @push('below_script') //scripts @endpus
  6. for inline css or on demand style sheets use @push('above-style') // styles @endpush
  7. Try to avoid local assets and always use cloud assets we our assets paths live logos and images are defined in  App/Helpers/Interfaces/Paths You can add Your. Ask Manager to upload your assets to cloud and give you link
  8. for links and navigation always use Route  Method and call route by name. dont use direct links like url().'/route' or ./route

Back end Rules:

  1. Always use route model binding where possible
  2. Always group related routes
  3. Always use Middleware for inspecting and filtering HTTP requests
  4. Always create named routes.try to use prefix for groped routed i.e 
    //This is an exmple how you must define the groued routes
    
    Route::name('elite.')->prefix('elite')->group(function () {
                Route::controller(EliteUniversityController::class)->group(function () {
                    Route::get("", 'show')->name('show');
                    Route::post("", 'import')->name('import');
                    Route::post("create", 'create')->name('create');
                    Route::post("update/{elite_university}", 'update')->name('update');
                    Route::delete("delete/{elite_university}", 'delete')->name('delete');
                });
    
                Route::name('packages.')->prefix('packages')
                    ->controller(ElitePackageController::class)->group(function () {
                        Route::get("", 'show')->name('show');
                        Route::get("list", 'list')->name('list');
                        Route::post("create", 'create')->name('create');
                        Route::post("update/{package}", 'update')->name('update');
                        Route::delete("delete/{package}", 'delete')->name('delete');
                    });
            });​
  5. Always create FormValidation Request for validation
  6. For mass assignment always use validated data i.e ...->create($request->validated())
  7. Always check the file  types and input type in validation
  8. You must avoid the N+1 query problem. Read Here
  9. Relation counts must always be loaded in Eager loading read more about it here
  10. Simple records counts also be done on query. i.e Model::count() not count(Model::get()) read more about it here
  11. Always use well descriptive CONSTANTS for raw value like, status = 1 or where('status',0).
  12. Always Define Contents in App/Helpers/Interface/.../ and implement on app/Helpers/AppContents class
  13. for model always add fillables
  14. always cast your attributes that need to change. like json to array, 1 or 0 bool, etc
  15. always append asste_url in model data for related assets. like for logo always append logo_url attribute for full url.
  16. same above rule for image and other assets
  17. always create relations
  18. for longer methods or function try to create Laravel Actions. Action Names Must be descriptive
  19. Your methods or function arguments must always have type i.e count(Int i) or countWords(string $str) or doSomething(mixed $arg) or  use union types for two type  doSomething(?mixed $args,?int args, int|string $args )
  20. Your methods must always have a return type
  21. Your method names must be descriptive.
  22. Never use raw query for insertion. and avoid raw as much as you can for getting data from DB
  23. Always Use Model to handle database operations
  24. Always upload profile photos, logos and files to cloud.
  25. If You create any new Env variables you must add it example.env file
  26. Env variable must not be accessed directly. always access using config file

 

Task Communication

  1. Check your new Next day tasks at once, understand them and if there is anything that you need to clear some points try to add it to the task it self not by slack.

Tabs Rules

Did you find this article useful?