PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/public/docs/source/index.md

https://bitbucket.org/Mmagde/wireless
Markdown | 423 lines | 325 code | 98 blank | 0 comment | 0 complexity | c8ec155ec27ea314c1e9d49401b00301 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, MIT, LGPL-2.1, MPL-2.0-no-copyleft-exception
  1. ---
  2. title: LaraFlat
  3. includes:
  4. search: true
  5. toc_footers:
  6. - <a href='http://github.com/mpociot/documentarian'>LaralFalt made by love with By 5damt-web</a>
  7. ---
  8. <!-- install -->
  9. # Download The Files
  10. download all files
  11. # Requirements
  12. PHP >= 5.6.4 ,
  13. PHP Curl extension
  14. # Install The Dependencies
  15. now type this line on your console
  16. ```
  17. composer install
  18. ```
  19. ```
  20. php artisan key:generate
  21. ```
  22. # Migrate
  23. ```
  24. php artisan migrate
  25. ```
  26. # Seed Database
  27. ```
  28. php artisan db:seed
  29. ```
  30. # Start Server
  31. ```
  32. php artisan serve
  33. ```
  34. # Login
  35. ```
  36. email : admin@gmail.com
  37. pass : admin
  38. ```
  39. # Go To Admin Path
  40. ```
  41. http://127.0.0.1:8000/admin/home
  42. ```
  43. <!-- install -->
  44. <!-- generate new module -->
  45. # Generate New Admin Module
  46. ```
  47. php artisan make:admin_model Nameofmodel
  48. ```
  49. this command will genrate the following files
  50. <ol>
  51. <li>app/Application/Model/Nameofmodel.php</li>
  52. <li>app/Application/Datatables/NameofmodelDatatable.php</li>
  53. <li>app/Application/Controllers/NameofmodelControllers.php</li>
  54. <li>app/Application/views/admin/nameofmodel</li>
  55. <li>app/Application/routes/admin/admin.php</li>
  56. <li>Insert item in admin menu</li>
  57. <li>database/migrations/Nameofmodel</li>
  58. <li>recources/lang/ar/nameofmodel</li>
  59. </ol>
  60. <!-- generate new module -->
  61. <!-- model -->
  62. # Model
  63. ```app/Application/Model/Nameofmodel.php```
  64. this will be the model of the module
  65. it will contain the following
  66. ## Table name make sure this is the table name
  67. ```
  68. public $table = "Nameofmodel";
  69. ```
  70. ## Fillable column make sure you add all column on your table
  71. ```
  72. protected $fillable = [
  73. 'name'
  74. ];
  75. ```
  76. ## Validation method on store action make sure to add your only validation store action here
  77. ```
  78. public function validation($id){
  79. return [
  80. 'name.*' => 'required|max:90'
  81. ];
  82. }
  83. ```
  84. ## Validation method on update action make sure to add only your update validation here in this method
  85. ```
  86. public function updateValidation($id){
  87. return [
  88. 'name.*' => 'required|max:90'
  89. ];
  90. }
  91. ```
  92. <!-- model -->
  93. <!-- Datatable -->
  94. # Datatable
  95. ```app/Application/Datatables/NameofmodelDatatable.php```
  96. ## this is class to handel datatable .... every table in laraflat have his own class on this path so you must <br>
  97. configure this class to show your data <br>
  98. this method will handel the add,view,update action
  99. ```php
  100. public function ajax()
  101. {
  102. return $this->datatables
  103. ->eloquent($this->query())
  104. ->addColumn('edit', 'admin.nameofmodel.buttons.edit')
  105. ->addColumn('delete', 'admin.nameofmodel.buttons.delete')
  106. ->addColumn('view', 'admin.nameofmodel.buttons.view')
  107. ->addColumn('name', 'admin.nameofmodel.buttons.langcol')
  108. ->make(true);
  109. }
  110. ```
  111. you can add or delete or customize any of this feilds <br>
  112. ## this method you can show or delete the tds from the table
  113. ```php
  114. protected function getColumns()
  115. {
  116. return [
  117. [
  118. 'name' => "id",
  119. 'data' => 'id',
  120. 'title' => adminTrans('curd' , 'id'),
  121. ],
  122. [
  123. 'name' => "name",
  124. 'data' => 'name',
  125. ],
  126. [
  127. 'name' => "view",
  128. 'data' => 'view',
  129. 'title' => adminTrans('curd' , 'view'),
  130. 'exportable' => false,
  131. 'printable' => false,
  132. 'searchable' => false,
  133. 'orderable' => false,
  134. ],
  135. [
  136. 'name' => 'edit',
  137. 'data' => 'edit',
  138. 'title' => adminTrans('curd' , 'edit'),
  139. 'exportable' => false,
  140. 'printable' => false,
  141. 'searchable' => false,
  142. 'orderable' => false,
  143. ],
  144. [
  145. 'name' => 'delete',
  146. 'data' => 'delete',
  147. 'title' => adminTrans('curd' , 'delete'),
  148. 'exportable' => false,
  149. 'printable' => false,
  150. 'searchable' => false,
  151. 'orderable' => false,
  152. ],
  153. ];
  154. }
  155. ```
  156. you can see more about this from datatable <a href="https://yajrabox.com/docs/laravel-datatables/master">documentation</a>
  157. <!-- Datatable -->
  158. <!-- controller -->
  159. # Controller
  160. ```app/Application/Controllers/NameofmodelControllers.php```
  161. all controller extends this class AbstractController this where the magic happen <br>
  162. this class have all logic to get store update add methods on Laraflat <br>
  163. ## constructor function
  164. ```
  165. public function __construct(Nameofmodel $model)
  166. {
  167. parent::__construct($model);
  168. }
  169. ```
  170. here we add the model that we add , edit , update , store , delete Don not worry laralflat write this to you <br>
  171. to make ot easy to make this action
  172. ## index Method
  173. here we build the datatable and render it do not worry about this all this work don by laraflat
  174. ```
  175. public function index(NameofmodelDataTable $dataTable){
  176. return $dataTable->render('admin.nameofmodel.index');
  177. }
  178. ```
  179. ## show Method
  180. this function call when you show add , edit
  181. ```
  182. public function show($id = null){
  183. return $this->createOrEdit('admin.nameofmodel.edit' , $id);
  184. }
  185. ```
  186. you can pass any data to view as array as third arg in ```createOrEdit```
  187. ## Store Method
  188. this method will call on store , update action
  189. ```
  190. public function store($id = null , \Illuminate\Http\Request $request){
  191. return $this->storeOrUpdate($request , $id , 'admin/nameofmodel');
  192. }
  193. ```
  194. you can here customize your request and can check if request store by ``` if($id == null)```
  195. ## GetById Method
  196. this method control the view action in datatable
  197. ```
  198. public function getById($id){
  199. $fields = $this->model->getConnection()->getSchemaBuilder()->getColumnListing($this->model->getTable());
  200. return $this->createOrEdit('admin.nameofmodel.show' , $id , ['fields' => $fields]);
  201. }
  202. ```
  203. this Method get all table column and send it with the item to the view to show details
  204. ## Destroy Method
  205. this methods call when you try to delete the item
  206. ```
  207. public function destroy($id){
  208. return $this->deleteItem($id , 'admin/categorie')->with('sucess' , 'Done Delete categorie From system');
  209. }
  210. ```
  211. <!-- controller -->
  212. <!-- views -->
  213. # Views
  214. ```app/Application/views/admin/nameofmodel```
  215. we generate by default 7 view 3 the index , edit , show this is the common fiels <br>
  216. the other 4 controll the btns in datatable
  217. <!-- views -->
  218. <!-- routes -->
  219. # Routes
  220. ```app/Application/routes/admin/admin.php```
  221. laraflat append all routes for you when you excute the command ``` php artisan make:admin_model ``` <br>
  222. laraflat append all reoutes that make this actions ```add , edit , delete , store , update , view ```<br>
  223. int this Path ``` app/Application/routes/admin/admin.php ```
  224. this path the admin group only will have access on it
  225. <!-- routes -->
  226. <!-- menue -->
  227. # Menu
  228. ```Insert item in admin menu```
  229. laraflat insert item for you when you excute the command ``` php artisan make:admin_model ``` <br>
  230. so it will appear in admin menu
  231. <!-- menue -->
  232. <!-- migration -->
  233. # Migration
  234. ```database/migrations/Nameofmodel```
  235. laraflat cearet migration file for you when excute the command ``` php artisan make:admin_model ``` <br>
  236. <!-- migration -->
  237. <!-- Lang Files -->
  238. # Lang Files
  239. ```recources/lang/ar/nameofmodel```
  240. laraflat cearet language files for you when excute the command ``` php artisan make:admin_model ``` <br>
  241. it will check available language in ``` config\laravellocalization.php ``` and will generate language files for you
  242. <!-- Lang Files -->
  243. <!-- tinymce -->
  244. # Tinymce
  245. ```how to use tinymce on any texteara```
  246. just put this id on any texteara ``` tinymce ```<br>
  247. then at the end of the page put this code
  248. ```
  249. @section('script')
  250. @include('admin.layout.helpers.tynic')
  251. @endsection
  252. ```
  253. <!-- tinymce -->
  254. <!-- translate filed -->
  255. # Translade Fileds
  256. ```add filed accept mluti language```
  257. laraflat loko to this file ``` config\laravellocalization.php ``` <br>
  258. to check the available language to use then you can un commnet any language form this file <br>
  259. now use this function to create your fileds laraflat will generate fields for each language
  260. ```
  261. {!! extractFiled('name' , isset($item->name) ? $item->name : null , 'text' , 'categorie') !!}
  262. ```
  263. <ul>
  264. <li>name => feild name</li>
  265. <li>isset($item->name) ? $item->name : null => check if this is store action or edit action </li>
  266. <li>text => type of feild</li>
  267. <li>categorie => translate file must have key name of feild</li>
  268. </ul>
  269. <!-- translate filed -->
  270. <!-- get value from multi language col -->
  271. # Show By Lang
  272. ```get value deppend on user language```
  273. you can use this two function ``` getDefaultValueKey($filed) ```<br>
  274. this function will decet the user lang and show him value depend on this lang or use this <br>
  275. ``` getLangValue($filed , 'ar')``` this function you must pass the language you want to show <br>
  276. <!-- get value from multi language col -->
  277. <!-- save arrays-->
  278. # save arrays
  279. if you want to save arrays in database just make the filed name as array like the example
  280. ```
  281. <input type="text" name="title[]" />
  282. ```
  283. laralflat will decet the array filed and contvert it as json
  284. <!-- save arrays-->
  285. <!-- upload image-->
  286. # upload image
  287. laralflat fo this file ```app\Application\Helpers\uploadFiles.php```<br>
  288. check this ```getFileFieldsName()``` if the file name in this array laralflat will upload this image<br>
  289. ```
  290. <input type="file" name="image" />
  291. ```
  292. if you want to upload multi image just add array to name and laraflat will take care about this
  293. ```
  294. <input type="file" name="image[]" />
  295. ```
  296. <!-- save arrays-->
  297. <!-- trans words -->
  298. # Trans Words
  299. ``` adminTrans('filename' , 'word')```
  300. <!-- trans words -->
  301. <!-- add lang to url-->
  302. # Append lang to url
  303. ``` concatenateLangToUrl('admin/cat/item/1')```
  304. <!-- trans words -->
  305. <!-- get Av lan-->
  306. # Get Languge
  307. get all available language
  308. ``` getAvLang()```
  309. <!-- get Av lan -->
  310. <!-- transform select -->
  311. # transform array
  312. some times you will have array with multi language value so you want to get just the current language<br>
  313. in this case use this function ```transformSelect()``` <br>
  314. it will return with array this value will be from the current user language
  315. <!-- transform select -->
  316. <!-- Get Setting -->
  317. # Get Setting
  318. laraflat have setting table so if you want to get setting just call this function ```getSetting('siteTitle')```
  319. <!-- Get Setting -->
  320. <!-- menus -->
  321. # Menu
  322. laraflat support menu system so if you want to show your menu use this function
  323. ```menu('menuName')```
  324. this will build ul with li with menu itmes
  325. <!-- menus -->