Skip to content

MehdiElMellali/laraflat-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LaraFlat

Advanced laravel system to build admin panel

Requirements

PHP >= 5.6.4 , PHP Curl extension

Download The Files

download all files

Install The Dependencies

now type this line on your console

composer install
php artisan key:generate

Or Install Form Composer

  composer create-project --prefer-dist laraflat/laraflat

Migrate

  php artisan migrate

Seed Database

  php artisan db:seed

Start Server

  php artisan serve

Login

  email : [email protected]
  pass : admin

Go To Admin Path

  http://127.0.0.1:8000/admin/home

Add New Model

    php artisan make:admin_model NameOfModel

Feature

create langauge files
Add Item to AdminAPanel Menu
Create model with update , add validation
create Datatable class and html
Create Controller with add,edit,delete,store,update actions
Create View for add , edit, show
Generate Admin route
Create Api class with view,view by id ,delete,store,update
Generate Api route
Create transform file for each api calss
Create Migration file
Acl permission system
setting system
multi theme for admin panel
support multi language
Ů‹ we generate two request file one for store data other for update data

Requests

We Generate two Requests file one for update and other for add

  app\Application\Requests\Admin\ModelRequestName\AddRequestModelname
  app\Application\Requests\Admin\ModelRequestName\UpdateRequestModelname

the first one will use in store function on the controller
the secound one will use in the update function in the controller

Model

app/Application/Model/Nameofmodel.php

this will be the model of the module it will contain the following

Table name make sure this is the table name

  public $table = "Nameofmodel";

Fillable column make sure you add all column on your table

    protected $fillable = [
           'name'
    ]; 

Datatable

app/Application/Datatables/NameofmodelDatatable.php

this is class to handel datatable .... every table in laraflat have his own class on this path so you must

configure this class to show your data

this method will handel the add,view,update action 
 ```php
    public function ajax()
         {
             return $this->datatables
                  ->eloquent($this->query())
                  ->addColumn('edit', 'admin.nameofmodel.buttons.edit')
                  ->addColumn('delete', 'admin.nameofmodel.buttons.delete')
                  ->addColumn('view', 'admin.nameofmodel.buttons.view')
                 ->addColumn('name', 'admin.nameofmodel.buttons.langcol')
                  ->make(true);
         }
 ```

you can add or delete or customize any of this feilds

this method you can show or delete the tds from the table

 ```php
     protected function getColumns()
        {
            return [
                [
                    'name' => "id",
                    'data' => 'id',
                    'title' => adminTrans('curd' , 'id'),
                ],
                [
                    'name' => "name",
                    'data' => 'name',
                ],
                 [
                      'name' => "view",
                      'data' => 'view',
                      'title' => adminTrans('curd' , 'view'),
                      'exportable' => false,
                      'printable' => false,
                      'searchable' => false,
                      'orderable' => false,
                 ],
                 [
                      'name' => 'edit',
                      'data' => 'edit',
                      'title' => adminTrans('curd' , 'edit'),
                      'exportable' => false,
                      'printable' => false,
                      'searchable' => false,
                      'orderable' => false,
                 ],
                 [
                       'name' => 'delete',
                       'data' => 'delete',
                       'title' => adminTrans('curd' , 'delete'),
                       'exportable' => false,
                       'printable' => false,
                       'searchable' => false,
                       'orderable' => false,
                 ],
    
            ];
        }
```

you can see more about this from datatable documentation

Controller

app/Application/Controllers/NameofmodelControllers.php

all controller extends this class AbstractController this where the magic happen
this class have all logic to get store update add methods on Laraflat

constructor function

  public function __construct(Nameofmodel $model)
    {
        parent::__construct($model);
    }

here we add the model that we add , edit , update , store , delete Don not worry laralflat write this to you
to make ot easy to make this action

index Method

here we build the datatable and render it do not worry about this all this work don by laraflat

 public function index(NameofmodelDataTable $dataTable){
        return $dataTable->render('admin.nameofmodel.index');
    }

show Method

this function call when you show add , edit

         public function show($id = null){
                return $this->createOrEdit('admin.nameofmodel.edit' , $id);
            }

you can pass any data to view as array as third arg in createOrEdit

Store Method

this method will call on store , update action

  public function store($id = null , \Illuminate\Http\Request $request){
         return $this->storeOrUpdate($request , $id , 'admin/nameofmodel');
    }

you can here customize your request and can check if request store by if($id == null)

GetById Method

this method control the view action in datatable

   public function getById($id){
        $fields = $this->model->getConnection()->getSchemaBuilder()->getColumnListing($this->model->getTable());
        return $this->createOrEdit('admin.nameofmodel.show' , $id , ['fields' =>  $fields]);
    }

this Method get all table column and send it with the item to the view to show details

Destroy Method

this methods call when you try to delete the item

 public function destroy($id){
        return $this->deleteItem($id , 'admin/categorie')->with('sucess' , 'Done Delete categorie From system');
    }

Views

app/Application/views/admin/nameofmodel

we generate by default 7 view 3 the index , edit , show this is the common fiels
the other 4 controll the btns in datatable

Routes

app/Application/routes/admin/admin.php

laraflat append all routes for you when you excute the command php artisan make:admin_model
laraflat append all reoutes that make this actions add , edit , delete , store , update , view
int this Path app/Application/routes/admin/admin.php this path the admin group only will have access on it

Menu

Insert item in admin menu laraflat insert item for you when you excute the command php artisan make:admin_model
so it will appear in admin menu

Migration

database/migrations/Nameofmodel laraflat cearet migration file for you when excute the command php artisan make:admin_model

Lang Files

recources/lang/ar/nameofmodel laraflat cearet language files for you when excute the command php artisan make:admin_model
it will check available language in config\laravellocalization.php and will generate language files for you

Tinymce

how to use tinymce on any texteara

just put this id on any texteara tinymce
then at the end of the page put this code

 @section('script')
        @include('admin.layout.helpers.tynic')
 @endsection

Translade Fileds

add filed accept mluti language

laraflat loko to this file config\laravellocalization.php
to check the available language to use then you can un commnet any language form this file
now use this function to create your fileds laraflat will generate fields for each language

 {!! extractFiled('name' , isset($item->name) ? $item->name : null , 'text' , 'categorie') !!}
  • name => feild name
  • isset($item->name) ? $item->name : null => check if this is store action or edit action
  • text => type of feild
  • categorie => translate file must have key name of feild

Show By Lang

get value deppend on user language

you can use this two function getDefaultValueKey($filed)
this function will decet the user lang and show him value depend on this lang or use this
getLangValue($filed , 'ar') this function you must pass the language you want to show

save arrays

if you want to save arrays in database just make the filed name as array like the example

  <input type="text" name="title[]" />

laralflat will decet the array filed and contvert it as json

upload image

laralflat fo this file app\Application\Helpers\uploadFiles.php
check this getFileFieldsName() if the file name in this array laralflat will upload this image

  <input type="file" name="image" />

if you want to upload multi image just add array to name and laraflat will take care about this

  <input type="file" name="image[]" />

Trans Words

adminTrans('filename' , 'word')

Append lang to url

concatenateLangToUrl('admin/cat/item/1')

Get Languge

get all available language getAvLang()

transform array

some times you will have array with multi language value so you want to get just the current language
in this case use this function transformSelect()
it will return with array this value will be from the current user language

Get Setting

laraflat have setting table so if you want to get setting just call this function getSetting('siteTitle')

Menu

laraflat support menu system so if you want to show your menu use this function menu('menuName') this will build ul with li with menu itmes

Api

We Generate apicontroller for each module you add app\Application\Api\ModelNameApi.php and we also generate the api routes for you you can check this link to show how it work with angular 4 Api with angular

About

Advanced laravel system to build admin panel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 59.4%
  • CSS 26.0%
  • PHP 7.1%
  • HTML 6.9%
  • CoffeeScript 0.6%
  • Vue 0.0%