Beispiel #1
0
 public function getCreatefield(Request $request)
 {
     $this->validate($request, ['id' => 'required|integer', 'name' => 'required|alpha_num']);
     $req = InterRequest::find($request->input('id'));
     $field = new Field();
     $field->name = $request->input('name');
     $field->requestid = $req->id;
     if (!$field->save()) {
         return Redirect::back();
     }
     $data = $this->LoadDataByID($request->input('id'));
     $req = array();
     $number = 0;
     $arr = array_keys($data[0]);
     $arr[sizeof($arr)] = $request->input('name');
     $req[$number++] = $arr;
     for ($i = 0; $i < sizeof($data); $i++) {
         $data[$i][sizeof($data[$i])] = "null";
     }
     for ($j = 0; $j < sizeof($data); $j++) {
         $req[$number++] = array_values($data[$j]);
     }
     $this->SaveData($request->input('id'), $req);
     return $field->id;
 }
Beispiel #2
0
 public static function importField($request)
 {
     $new_field = new Field();
     $new_field->category_id = $request->get("category_id");
     $new_field->category_label = $request->get("category_label");
     $new_field->save();
 }
Beispiel #3
0
 public static function storeCategory($f_requests, $request, $category)
 {
     $category->name = $request['name'];
     $category->save();
     $ctg_id = $category->id;
     $ctg_name = $category->name;
     foreach ($f_requests->category_label as $ctg_label) {
         $field = new Field();
         $field->category_id = $ctg_id;
         $field->category_label = $ctg_label;
         $field->save();
     }
     return redirect()->route('category.create')->with('success_msg', 'Category :: ' . $ctg_name . ' is successfully saved.');
 }
 public function handle()
 {
     $script = '';
     foreach ($this->table->hasHasManyRelationList() as $relation) {
         $fromField = Field::find($relation['from_field_id']);
         $toModel = Table::find($relation['to_model_id']);
         $script .= $this->tab1 . 'public function ' . $relation['methodName'] . '(Request $request, ' . $this->table->model . ' $' . $this->table->variable . ')' . "\n";
         $script .= $this->tab1 . '{' . "\n";
         $script .= $this->tab2;
         $script .= '$' . $toModel->variablePlural . ' = $' . $this->table->variable . '->' . $relation['methodName'] . ';' . "\n";
         if ($toModel->hasBelongsToRelation()) {
             $script .= $this->tab2;
             $script .= '$' . $toModel->variablePlural . ' -> load(';
             foreach ($toModel->belongsToRelationList() as $relation) {
                 $script .= '\'' . $relation['methodName'] . '\', ';
             }
             $script = trim($script);
             $script = rtrim($script, ',');
             $script .= ');';
         }
         $script .= "\n";
         $script .= $this->tab2 . 'return response([\'data\' => $' . $toModel->variablePlural . ', \'status\' => \'success\', \'message\'=>\'\']);' . "\n" . "\n";
         $script .= $this->tab1 . '}' . "\n\n";
     }
     return $script;
 }
Beispiel #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $field_obj)
 {
     $field = Field::find($field_obj->id);
     $field->student_label = $request->get('student_label');
     $field->save();
     return redirect()->back();
 }
 public function processReportField($report_field)
 {
     $field = Field::FindOrFail($report_field->fieldId);
     $rule = $report_field->reportType;
     $processor = $this->setProcessor($field, $rule);
     return $processor->calculateResult();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $field = Field::findOrFail($id);
     $user = Auth::user();
     if ($user->can('hasFormAccess', $field)) {
         $field->delete();
         return response()->json(['status' => 'success']);
     }
     return response()->json(['status' => 'error']);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Field::truncate();
     Field::create(['field_name' => 'foreman', 'field_desc' => 'a worker, especially a man, who supervises and directs other workers.']);
     Field::create(['field_name' => 'Elevator Installers and Repairers', 'field_desc' => 'Assemble, install, repair, or maintain electric or hydraulic freight or passenger elevators, escalators, or dumbwaiters.']);
     Field::create(['field_name' => 'Plumber', 'field_desc' => 'A person who installs and repairs the pipes and fittings of water supply, sanitation, or heating systems.']);
     Field::create(['field_name' => 'Transportation Inspectors', 'field_desc' => 'Inspect equipment or goods in connection with the safe transport of cargo or people. Includes rail transportation inspectors, such as freight inspectors; rail inspectors; and other inspectors of transportation vehicles, not elsewhere classified.']);
     Field::create(['field_name' => 'Crane Operator', 'field_desc' => 'A crane operator is someone who uses a crane to transport various objects. There are many different types, makes, models and sizes of cranes, such as mobile cranes, tower cranes, boom trucks and self-erect tower cranes.']);
     Field::create(['field_name' => 'Carpenter', 'field_desc' => 'A person who makes and repairs wooden objects and structures.']);
     Field::create(['field_name' => 'Gardener', 'field_desc' => 'A person who tends and cultivates a garden as a pastime or for a living.']);
 }
 /**
  * Run the migrations.
  *
  * @return  void
  */
 public function up()
 {
     \App\Field::create(['name' => 'male', 'title' => '男', 'field_class' => 'gender'])->create(['name' => 'female', 'title' => '女', 'field_class' => 'gender'])->create(['name' => 'news', 'title' => '订阅号', 'field_class' => 'wechat_type'])->create(['name' => 'service', 'title' => '服务号', 'field_class' => 'wechat_type'])->create(['name' => 'enterprise', 'title' => '企业号', 'field_class' => 'wechat_type'])->create(['name' => 'depot', 'title' => '素材', 'field_class' => 'wechat_message_type'])->create(['name' => 'news', 'title' => '图文', 'field_class' => 'wechat_message_type'])->create(['name' => 'image', 'title' => '图片', 'field_class' => 'wechat_message_type'])->create(['name' => 'thumb', 'title' => '缩略图', 'field_class' => 'wechat_message_type'])->create(['name' => 'video', 'title' => '视频', 'field_class' => 'wechat_message_type'])->create(['name' => 'shortvideo', 'title' => '小视频', 'field_class' => 'wechat_message_type'])->create(['name' => 'voice', 'title' => '音频', 'field_class' => 'wechat_message_type'])->create(['name' => 'music', 'title' => '音乐', 'field_class' => 'wechat_message_type'])->create(['name' => 'text', 'title' => '文字', 'field_class' => 'wechat_message_type'])->create(['name' => 'link', 'title' => '连接', 'field_class' => 'wechat_message_type'])->create(['name' => 'location', 'title' => '地址', 'field_class' => 'wechat_message_type'])->create(['name' => 'callback', 'title' => '回调', 'field_class' => 'wechat_message_type'])->create(['name' => 'event', 'title' => '事件', 'field_class' => 'wechat_message_type'])->create(['name' => 'subscribe', 'title' => '关注', 'field_class' => 'wechat_event_type'])->create(['name' => 'unsubscribe', 'title' => '取消关注', 'field_class' => 'wechat_event_type'])->create(['name' => 'SCAN', 'title' => '扫描二维码', 'field_class' => 'wechat_event_type'])->create(['name' => 'LOCATION', 'title' => '地址', 'field_class' => 'wechat_event_type'])->create(['name' => 'CLICK', 'title' => '点击', 'field_class' => 'wechat_event_type'])->create(['name' => 'VIEW', 'title' => '视图', 'field_class' => 'wechat_event_type'])->create(['name' => 'scancode_push', 'title' => '扫描事件', 'field_class' => 'wechat_event_type'])->create(['name' => 'scancode_waitmsg', 'title' => '扫描事件「非跳转」', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_sysphoto', 'title' => '系统拍照发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_photo_or_album', 'title' => '拍照或者相册发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_weixin', 'title' => '相册发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'location_select', 'title' => '地址选择', 'field_class' => 'wechat_event_type'])->create(['name' => 'XXS', 'title' => '特小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XS', 'title' => '加小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'S', 'title' => '小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'M', 'title' => '中号', 'field_class' => 'clothes_size_type'])->create(['name' => 'L', 'title' => '大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XL', 'title' => '加大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XXL', 'title' => '特大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XXXL', 'title' => '特特大号', 'field_class' => 'clothes_size_type'])->create(['name' => '27', 'title' => '腰围27', 'field_class' => 'clothes_size_type'])->create(['name' => '28', 'title' => '腰围28', 'field_class' => 'clothes_size_type'])->create(['name' => '29', 'title' => '腰围29', 'field_class' => 'clothes_size_type'])->create(['name' => '30', 'title' => '腰围30', 'field_class' => 'clothes_size_type'])->create(['name' => '31', 'title' => '腰围31', 'field_class' => 'clothes_size_type'])->create(['name' => '32', 'title' => '腰围32', 'field_class' => 'clothes_size_type'])->create(['name' => '33', 'title' => '腰围33', 'field_class' => 'clothes_size_type'])->create(['name' => '34', 'title' => '腰围34', 'field_class' => 'clothes_size_type'])->create(['name' => 'store', 'title' => '自提', 'field_class' => 'express_type'])->create(['name' => 'express', 'title' => '快递', 'field_class' => 'express_type'])->create(['name' => 'sf-express', 'title' => '顺丰快递', 'field_class' => 'express_name'])->create(['name' => 'sto-express', 'title' => '申通快递', 'field_class' => 'express_name'])->create(['name' => 'yto-express', 'title' => '圆通快递', 'field_class' => 'express_name'])->create(['name' => 'zto-express', 'title' => '中通快递', 'field_class' => 'express_name'])->create(['name' => 'ems', 'title' => 'EMS', 'field_class' => 'express_name'])->create(['name' => 'deppon', 'title' => '德邦物流', 'field_class' => 'express_name'])->create(['name' => 'china_bank', 'title' => '中国银行', 'field_class' => 'bank_name'])->create(['name' => 'construction_bank', 'title' => '中国建设银行', 'field_class' => 'bank_name'])->create(['name' => 'ICBC', 'title' => '中国工商银行', 'field_class' => 'bank_name'])->create(['name' => 'BOCOM', 'title' => '交通银行', 'field_class' => 'bank_name'])->create(['name' => 'agricultural_bank', 'title' => '中国农业银行', 'field_class' => 'bank_name'])->create(['name' => 'merchants_bank', 'title' => '招商银行', 'field_class' => 'bank_name'])->create(['name' => 'post_savings_bank', 'title' => '中国邮政储蓄银行', 'field_class' => 'bank_name'])->create(['name' => 'everbright_bank', 'title' => '中国光大银行', 'field_class' => 'bank_name'])->create(['name' => 'minsheng_bank', 'title' => '中国民生银行', 'field_class' => 'bank_name'])->create(['name' => 'pingan_bank', 'title' => '中国平安银行', 'field_class' => 'bank_name'])->create(['name' => 'SPD', 'title' => '浦发银行', 'field_class' => 'bank_name'])->create(['name' => 'CITIC', 'title' => '中信银行', 'field_class' => 'bank_name'])->create(['name' => 'industrial_bank', 'title' => '兴业银行', 'field_class' => 'bank_name'])->create(['name' => 'huaxia_bank', 'title' => '华夏银行', 'field_class' => 'bank_name'])->create(['name' => 'communications_bank', 'title' => '广发银行', 'field_class' => 'bank_name'])->create(['name' => '', 'title' => '无'])->update(['id' => 0]);
     \App\Role::create(['id' => 99, 'name' => 'admin', 'display_name' => '超级管理员', 'url' => 'admin'])->create(['id' => 98, 'name' => 'manager', 'display_name' => '项目总监', 'url' => 'admin'])->create(['id' => 97, 'name' => 'owner', 'display_name' => '经理', 'url' => 'admin'])->create(['id' => 96, 'name' => 'leader', 'display_name' => '负责人', 'url' => 'admin'])->create(['id' => 1, 'name' => 'viewer', 'display_name' => '普通用户', 'url' => ''])->create(['id' => 2, 'name' => 'wechater', 'display_name' => '微信用户', 'url' => ''])->create(['id' => 3, 'name' => 'factory', 'display_name' => '厂商'])->create(['id' => 4, 'name' => 'agent', 'display_name' => '代理商'])->create(['id' => 5, 'name' => 'store', 'display_name' => '门店'])->create(['id' => 0, 'name' => 'guest', 'display_name' => '访客', 'url' => ''])->update(['id' => 0]);
     foreach (['role' => '用户组、权限', 'attachment' => '附件', 'member' => '用户', 'factory' => '厂商', 'agent' => '代理商', 'store' => '门店', 'product' => '产品', 'wechat-account' => '微信公众号', 'wechat-depot' => '微信素材', 'wechat-menu' => '微信菜单', 'wechat-message' => '微信消息', 'wechat-reply' => '微信自定义回复', 'wechat-user' => '微信用户'] as $k => $v) {
         foreach (['view' => '查看', 'create' => '新建', 'edit' => '编辑', 'destroy' => '删除', 'export' => '导出'] as $k1 => $v1) {
             \App\Permission::create(['name' => $k . '.' . $k1, 'display_name' => '允许' . $v1 . $v]);
         }
     }
     \App\Role::find(99)->perms()->sync(\App\Permission::all());
     (new \App\User())->add(['username' => 'admin', 'password' => '123456', 'nickname' => '超级管理员'], \App\Role::ADMIN);
 }
Beispiel #10
0
 public static function add_field()
 {
     if (isset($_POST["mytext"]) != '') {
         foreach ($_POST["mytext"] as $labelField) {
             if ($labelField != '') {
                 $field = Field::firstOrNew(array('student_label' => $labelField));
                 $field->save();
             }
         }
     }
     return Redirect::back()->with('msg', 'Field was successfuly updated');
 }
Beispiel #11
0
 public static function updateDueDate($requests)
 {
     $fields = Field::all();
     foreach ($fields as $field) {
         if ($field->student_label == "payment_date1") {
             $info = new Information();
             $info->field_id = $field->id;
             $info->value = $requests->get('due_1');
             $info->save();
         }
         $info = new Information();
         $info->field_id = $field->id;
         $info->save();
         if ($field->student_label == "payment_date2") {
             $info = new Information();
             $info->field_id = $field->id;
             $info->value = $requests->get('due_2');
             $info->save();
         }
         $info = new Information();
         $info->field_id = $field->id;
         $info->save();
         if ($field->student_label == "payment_date3") {
             $info = new Information();
             $info->field_id = $field->id;
             $info->value = $requests->get('due_3');
             $info->save();
         }
         $info = new Information();
         $info->field_id = $field->id;
         $info->save();
         if ($field->student_label == "payment_date4") {
             $info = new Information();
             $info->field_id = $field->id;
             $info->value = $requests->get('due_4');
             $info->save();
         }
         $info = new Information();
         $info->field_id = $field->id;
         $info->save();
         if ($field->student_label == "payment_date5") {
             $info = new Information();
             $info->field_id = $field->id;
             $info->value = $requests->get('due_5');
             $info->save();
         }
         $info = new Information();
         $info->field_id = $field->id;
         $info->save();
     }
     return Redirect::back()->with('msg', 'Due date was successfuly updated');
 }
Beispiel #12
0
 public static function viewInformation($request)
 {
     $fields = Field::groupBy('category_label')->get();
     $information = DB::table('fields')->join('information', function ($join) use($request) {
         $join->on('fields.id', '=', 'information.field_id')->where('fields.category_label', '=', $request->get('categoryLabel'))->where('information.value', 'LIKE', '%' . $request->get('filter') . '%');
     })->join('devices', function ($join) {
         $join->on('devices.id', '=', 'information.device_id');
     })->join('categories', function ($join) {
         $join->on('categories.id', '=', 'devices.category_id');
     })->select('information.*', 'fields.*', 'devices.*', DB::raw('inv_devices.name as "device_name"'), DB::raw('inv_devices.slug as "device_slug"'), 'categories.*', DB::raw('inv_categories.name as "category_name"'), DB::raw('inv_categories.slug as "category_slug"'))->paginate(25);
     $information->setPath('information');
     return view('field.index', compact('fields', 'information'));
 }
Beispiel #13
0
 public function postSelected(Request $request, $form_code)
 {
     $randomCode = Auth::id() . mt_rand(0, 999) . time();
     $form = Form::where('form_code', $form_code)->where('form_type', 'template')->where('form_active', '1')->firstOrFail();
     $form->update(['form_copy' => $form->form_copy + 1]);
     $formCopy = Form::create(['form_cuid' => Auth::id(), 'form_type' => 'normal', 'form_code' => $randomCode, 'form_active' => 0, 'form_title' => $form->form_title, 'form_summary' => $form->form_summary, 'form_sort' => 0, 'form_url' => $randomCode, 'form_tips_email' => 0, 'form_limit_auz' => 'allow_all']);
     foreach ($form->Field()->get() as $field) {
         $fieldCopy = Field::create(['field_cuid' => Auth::id(), 'field_form_id' => $formCopy->form_id, 'field_sort' => $field->field_sort, 'field_type' => $field->field_type, 'field_title' => $field->field_title, 'field_tips' => $field->field_tips, 'field_attr_name' => Auth::id() . mt_rand(0, 999) . time() . mt_rand(0, 999), 'field_attr_value' => $field->field_attr_value, 'field_attr_width' => $field->field_attr_width, 'field_must' => $field->field_must]);
         foreach ($field->FieldChildren()->get() as $fieldchildren) {
             FieldChildren::create(['fieldchildren_field_id' => $fieldCopy->field_id, 'fieldchildren_key' => $fieldchildren->fieldchildren_key, 'fieldchildren_value' => $fieldchildren->fieldchildren_value, 'fieldchildren_value2' => $fieldchildren->fieldchildren_value2, 'fieldchildren_value3' => $fieldchildren->fieldchildren_value3, 'fieldchildren_img_id' => $fieldchildren->fieldchildren_img_id, 'fieldchildren_checked' => $fieldchildren->fieldchildren_checked, 'fieldchildren_disabled' => $fieldchildren->fieldchildren_disabled]);
         }
     }
     $res = redirect('/form/info/' . $formCopy->form_code)->with('msgSuccess', '此表单模板已经添加到您的表单中心当中');
     return $res;
 }
Beispiel #14
0
 public function getIndex(Request $request)
 {
     User::createTable();
     // User::createAdmin('*****@*****.**','admin');
     Img::createTable();
     Mylog::createTable();
     Email::createTable();
     Banner::createTable();
     Activity::createTable();
     Form::createTable();
     Field::createTable();
     FieldChildren::createTable();
     Result::createTable();
     ResultRow::createTable();
     Charge::createTable();
 }
 public function handle()
 {
     $script = '<?php' . "\n\n";
     $script .= "Route::group(['prefix'=>'api/" . $this->devis->app_name . "'], function () {" . "\n";
     foreach ($this->devis->tables as $table) {
         if ($table->model != '') {
             $script .= "\t" . 'Route::resource("' . $table->name . '", "' . $table->controllerRouteApiClass() . '");' . "\n";
         }
         if ($table->hasHasBelongsToRelation()) {
             $script .= "\t" . 'Route::get("' . $table->name . '/{' . $table->variable . '}/showWithRelations", "' . $table->controllerRouteApiClass() . '@showWithRelations");' . "\n";
         }
         foreach ($table->hasHasManyRelationList() as $relation) {
             // var_dump($relation);
             $fromField = Field::find($relation['from_field_id']);
             $fromModel = Table::find($relation['model_id']);
             $toModel = Table::find($relation['to_model_id']);
             $script .= "\t\t" . 'Route::get("' . $table->name . '/{' . $fromModel->variable . '}/' . $relation['methodName'] . '", "' . $table->controllerRouteApiClass() . '@' . $relation['methodName'] . '");' . "\n";
         }
         if ($this->getSpecialVueComponentList($table)) {
             $script .= "\n\n";
             $script .= "//get Special Vue Component";
             $script .= "\n";
             foreach ($this->getSpecialVueComponentList($table) as $specialView) {
                 $specialView = '\\Organit\\bootstrapping\\Vue\\MiddlesepcialComponentViews\\' . $this->devis->app_name . '\\' . $specialView;
                 $script .= "\t\t" . (new $specialView($this->devis, $table))->CoreSpecialCompo()->RoutePHPLine();
                 $script .= "\n";
             }
         }
         $script .= "\n\n";
     }
     $script .= "});";
     $this->createFile('../app/Http/' . $this->devis->app_name . '_api.php', $this->devis->app_name, $script);
     echo "<h1>-->Copier dans app\\Providers\\RouteServiceProvider.php</h1>";
     echo "<pre>";
     echo "\n        require app_path('Http/" . $this->devis->app_name . "_routes.php');\n        require app_path('Http/" . $this->devis->app_name . "_api.php');";
     echo "</pre>";
     echo '<a href="/' . $this->devis->app_name . '">Test Route</a>';
 }
 public function index()
 {
     $fields = Field::orderBy('name')->lists('name', 'id');
     return view('statistics.statistic')->with('fields', $fields)->with('statistic_active', 'active');
 }
    public function handle()
    {
        //
        $script = '

                <style>

                </style>



                <template>

                <h1>' . $this->table->model . '  Index</h1>

                    Mettre ici : <br>
                    - menu des relations à plusieurs<br>
                    - menu des specialcompo
                    - acces a list
                    - acces a create
                    <br>
                    <br>
                    et le router-view


                    ';
        $hasHasManyRelation = false;
        $ManyRelationQuantity_sup_4 = false;
        /*
                                    if ($table->hasHasManyRelation()) {
                                        $hasHasManyRelation = true;
                                        hasHasManyRelationList()->count();
                                    }
                                    $hasSpecialVueComponent = false;
                                    if ($this->getSpecialVueComponentList($table)) {
                                        $hasSpecialVueComponent = true;
                                    }
                                    ////
                                    if (!$hasHasManyRelation && !$hasSpecialVueComponent) { //C
                                        # code...
                                    }
        */
        $script = '








                            <template>


                            <div class=row>
                            <h1>Index <b>{{object.name}}</b></h1>
                            <!--<ui-icon-button icon="navigate_before" @click.prevent="goBack" tooltip="Go back" type="primary" color="default" class="pull-left" ></ui-icon-button>-->
                            </div>
                            ' . "\n";
        if ($this->table->hasHasManyRelation()) {
            $script .= '
                                <div class="tabbable">
                                    <ul class="nav nav-pills nav-stacked col-md-3">
                                        <li class="active"><a href="#general" data-toggle="tab">General</a></li>
                                        ';
            if ($this->getSpecialVueComponentList($this->table)) {
                foreach ($this->getSpecialVueComponentList($this->table) as $specialView) {
                    $script .= '<li><a href="#' . $specialView . '" data-toggle="tab">' . $specialView . '</a></li>';
                }
            } else {
                foreach ($this->table->hasHasManyRelationList() as $relation) {
                    $script .= '<li class=""><a href="#' . $relation['methodName'] . '" data-toggle="tab">' . $relation['methodName'] . '</a></li>';
                }
            }
            $script .= '
                                    </ul>
                                    <div class="tab-content col-md-8">
                                        <div class="tab-pane fade in active" id="general">
                                        ';
            if ($this->table->name == 'vehicles') {
                $script .= '
                                            <div>
                                                    <!-- Nav tabs -->
                                                    <ul class="nav nav-tabs" role="tablist">
                                                    <li role="presentation" class="active"><a href="#form" aria-controls="home" role="tab" data-toggle="tab">' . $this->table->model . ' form</a></li>
                                                    ';
                foreach ($this->table->hasHasManyRelationList() as $relation) {
                    $script .= '<li><a href="#' . $relation['methodName'] . '" role="tab" data-toggle="tab">' . $relation['methodName'] . '</a></li>';
                }
                $script .= '
                                                    </ul>

                                                    <!-- Tab panes -->
                                                    <div class="tab-content">
                                                    <div role="tabpanel" class="tab-pane active" id="form">
                                                         <' . $this->table->VueTag('form') . ' :created-object.sync="created' . $this->table->model . '" ></' . $this->table->VueTag('form') . '>
                                                    </div>
                                                    ';
                foreach ($this->table->hasHasManyRelationList() as $relation) {
                    $related_model = \App\Table::find($relation['to_model_id']);
                    $fromField = \App\Field::find($relation['from_field_id']);
                    $script .= '
                                                               <div class="tab-pane fade in" id="' . $relation['methodName'] . '">
                                                                  <' . $related_model->VueTag('list', $relation['methodName']) . ' :from-id="getId" :url="getUrl(\'' . $relation['methodName'] . '\')"></' . $related_model->VueTag('list', $relation['methodName']) . '>
                                                               </div>';
                    $script .= '' . "\n";
                }
                $script .= '
                                                    </div>

                                                    </div>
                                            ';
            } else {
                $script .= ' <' . $this->table->VueTag('form') . ' :created-object.sync="created' . $this->table->model . '" ></' . $this->table->VueTag('form') . '> ';
            }
            $script .= '
                                        </div>
                                        ';
            if ($this->getSpecialVueComponentList($this->table)) {
                foreach ($this->getSpecialVueComponentList($this->table) as $specialView) {
                    $script .= '
                                            <div class="tab-pane fade in" id="' . $specialView . '">
                                                <' . $this->table->VueTag('', $specialView) . ' :' . $this->table->variable . '="object"></' . $this->table->VueTag('', $specialView) . '>

                                             </div>
                                            ';
                }
            } else {
                foreach ($this->table->hasHasManyRelationList() as $relation) {
                    $related_model = \App\Table::find($relation['to_model_id']);
                    $fromField = \App\Field::find($relation['from_field_id']);
                    $script .= '
                                                       <div class="tab-pane fade in" id="' . $relation['methodName'] . '">
                                                          <' . $related_model->VueTag('list', $relation['methodName']) . ' :from-id="getId()" :url="getUrl(\'' . $relation['methodName'] . '\')"></' . $related_model->VueTag('list', $relation['methodName']) . '>
                                                       </div>';
                    ///api/'.$this->devis->app_name.'/'.$this->table->name.'//'.strtolower($relation['methodName']).'
                    $script .= '' . "\n";
                    // $script.=$this->tab1.'import '.$related_model->vueComponentName('list') . ' from \'' . $this->table->vueComponentRelativePathTo($related_model, 'list').'\''."\n";
                }
            }
            $script .= '
                                    </div><!--tab content-->
                                </div>
                                ';
        } else {
            //doesn't have has many relation
            //-->load the form
            $script .= '<router-view></router-view>
                                #98789444da9 --> router-view -> Afficher le formulaire #98789444da9
                                ';
        }
        if ($this->table->name == 'vehicles') {
            $script .= '
                                        <h3>Financials</h3>

                                        <graph-line2></graph-line2>
                                        <h4>Actual</h4>

                                        <h4>Budget</h4>


                                        <h3>Cash fLOW FORECAST</h3>
                                        <graph-line1></graph-line1>


                                        ' . "\n\n";
        }
        $script .= '</template>' . "\n\n";
        $script .= "\n\n";
        $script .= '<script>' . "\n\n";
        $components = [];
        $script .= $this->tab1 . 'import ' . $this->table->vueComponentName('form') . ' from \'' . $this->table->vueComponentRelativePathTo($this->table, 'form') . '\'' . "\n";
        $components[] = $this->table->vueComponentName('form');
        $relationToModel = [];
        /*
         **  ajout des composant des relations
         */
        foreach ($this->table->hasHasManyRelationList() as $relation) {
            $related_model = \App\Table::find($relation['to_model_id']);
            $fromField = \App\Field::find($relation['from_field_id']);
            $componentName = $related_model->vueComponentName('list', $relation['methodName']);
            $path = $this->table->vueComponentRelativePathTo($related_model, 'list');
            // $relationToModel[]=$related_model->name;
            $components[] = $componentName;
            $script .= 'import ' . $componentName . ' from \'' . $path . '\'' . "\n";
            //$script.=$this->tab1.'import '.$related_model->vueComponentName('list') . ' from \'' . $this->table->vueComponentRelativePathTo($related_model, 'list').'\''."\n";
        }
        /*
         ** Ajout des special components
         */
        if ($this->getSpecialVueComponentList($this->table)) {
            foreach ($this->getSpecialVueComponentList($this->table) as $specialView) {
                $componentName = $this->table->vueComponentName('', $specialView);
                $path = $this->table->vueComponentRelativePathTo($this->table, $specialView);
                $components[] = $componentName;
                $script .= 'import ' . $componentName . ' from \'' . $path . '\'' . "\n";
            }
        }
        $script .= '


                            export default {
                                components: {' . "\n";
        foreach ($components as $component) {
            $script .= $this->tab4 . $component . ', ' . "\n";
        }
        $script .= '
                                },

                                props :{

                                },

                                ready () {
                                    this.fetchObject()
                                },
                                watch: {
                                    // \'object.crm_app.activity_id\': function (val, oldVal) {
                                    //     console.log(`value changed from ${oldVal} to ${val}`)
                                    // },


                                },

                                data(){
                                    return {

                                        object:{},
                                        ';
        $components = [];
        foreach ($this->table->relationship() as $relation) {
            if (in_array($relation['laravel_name'], ['belongsTo']) && !in_array($relation['to_model_id'], $components)) {
                $script .= '';
                $related_model = \App\Table::find($relation['to_model_id']);
                $components[] = $relation['to_model_id'];
                $script .= '
                                        showForm_' . $related_model->variable . ' : false,' . "\n";
                $script .= '
                                        created' . $related_model->model . ' : {},' . "\n";
                $script .= '
                                        ' . $related_model->model . 'List:[],' . "\n";
            }
        }
        $script .= '

                                    };
                                },

                                filters:{

                                },
                                computed : {
                                    getId(){
                                        return this.$route.params.' . strtolower(snake_case($this->table->model)) . '_id' . '
                                    }

                                },

                                methods: {
                                    fetchObject () {
                                        this.$http.get(\'/api/' . $this->devis->app_name . '/' . $this->table->name . '/\'+this.$route.params.' . strtolower(snake_case($this->table->model)) . '_id' . ').then(function (response) {
                                                  this.object = response.data.data
                                                  this.loading=false

                                              }, function (response) {
                                                  // error callback
                                              });
                                    },
                                    goBack(){
                                        this.$route.router.go(window.history.back())
                                    },
                                    getUrl(methodName){
                                        id = this.$route.params.' . strtolower(snake_case($this->table->model)) . '_id' . '
                                        return \'api/' . $this->devis->app_name . '/' . $this->table->name . '/\'+id+\'/\'+methodName
                                    },
                                    getId(){
                                        return this.$route.params.' . strtolower(snake_case($this->table->model)) . '_id' . '
                                    }
                                },
                            }

                            ';
        // dd($script);
        $script .= '</script>' . "\n\n";
        $script .= '<style>' . "\n\n";
        $script .= '</style>' . "\n\n";
        // File::put('uploads/bootstrapping/'.$this->devis->app_name.'/vue_components/'.$this->table->model.'/list.vue',$script);
        $this->createFile($this->path(), $this->devis->app_name, $script);
    }
 public function drop_field($id, Request $request)
 {
     if (!Auth::user()) {
         return redirect('/');
     }
     try {
         Field::where('id', '=', $id)->delete();
     } catch (\exception $e) {
         $rules = ['delete' => 'required'];
         $messages = ['delete.required' => 'წაშლა შეუძლებელია'];
         $this->validate($request, $rules, $messages);
     }
     return redirect('/admin');
 }
 public function handle()
 {
     $this->initializeMigrationsArray();
     // $this->sortMigrationArray();
     foreach ($this->migrationsArray as $key => $table) {
         // foreach ($this->devis->tables as $key=>$table) {
         // $table=Table::find($table_id);
         // echo '<h5>&nbsp;&nbsp;&nbsp;&nbsp;<i style="color:green">></i> Preparing files for table <u style="color:#15c">';
         // echo $table->name;
         // echo '</u></h5>';
         /*
          **  migrations
          */
         // $migrationScript = 'sdfsdfsdf '."\n";
         // $migrationScript.= 'sdfsdfsdf \n';
         $migrationScript = '<?php' . "\n\n";
         $migrationScript .= 'use Illuminate\\Database\\Schema\\Blueprint;' . "\n";
         $migrationScript .= 'use Illuminate\\Database\\Migrations\\Migration;' . "\n\n";
         $migrationClassName = $table->model == '' ? camel_case($table->name) : camel_case($table->model);
         $migrationScript .= 'class Create' . $this->devis->app_name . ucfirst($migrationClassName) . 'Table extends Migration' . "\n";
         $migrationScript .= '{' . "\n";
         $migrationScript .= "\t" . 'public function up()' . "\n";
         $migrationScript .= "\t" . '{' . "\n";
         $migrationScript .= "\t\t" . 'if( ! Schema::hasTable("' . $table->tableName . '")) {' . "\n";
         $migrationScript .= "\t\t\t" . 'Schema::create("' . $table->tableName . '", function (Blueprint $table) {' . "\n";
         foreach ($table->fields as $field) {
             if ($field->type->name) {
                 // $migrationScript.= "\t\t\t".'$table->'.$this->typeLaravelMethod($field).'("'.$field->name.'");'."\n"; //work
                 $onTable = '';
                 $referencesKey = '';
                 $has_constraint = false;
                 foreach ($field->relations()->get() as $key => $relation) {
                     if (in_array($relation->pivot->laravel_name, ['belongsTo'])) {
                         $has_constraint = true;
                         $onTable = Field::find($relation->pivot->to_field_id)->table->name;
                         $referencesKey = Field::find($relation->pivot->to_field_id)->name;
                     } else {
                         if (in_array($relation->pivot->laravel_name, ['belongsToMany'])) {
                             if ($field->is_incrementable) {
                                 $has_constraint = false;
                             } else {
                                 $has_constraint = true;
                             }
                         }
                     }
                     if ($has_constraint) {
                         if ($key == 0) {
                             $migrationScript .= "\t\t\t\t" . '$table->' . $this->typeLaravelMethod($field) . '(' . $this->fieldsArguments($field) . ')->unsigned();' . "\n";
                         }
                         $migrationScript .= "\t\t\t\t" . "//\$" . "table->foreign('" . $field->name . "')->references('" . $referencesKey . "')->on('" . $onTable . "');" . "\n\n";
                     }
                 }
                 if (!$has_constraint) {
                     //la table pivot d'un belongs to Many n'est pas spécifiée dans les relations. Allos la chercher
                     if ($table->getPrimaries()->count() > 1) {
                         $onTable = \DB::table('relationships')->where('laravel_name', 'belongsToMany')->where('to_field_id', $field->id)->where('pivot_table_name', $table->name)->first();
                         $onTable = $onTable;
                         if ($onTable) {
                             $field_a = Field::find($onTable->from_field_id);
                             $onTable = $field_a->table;
                             $referencesKey = $field_a->name;
                             $migrationScript .= "\t\t\t\t" . '$table->' . $this->typeLaravelMethod($field) . '(' . $this->fieldsArguments($field) . ')->unsigned();' . "\n";
                             $migrationScript .= "\t\t\t\t" . "//\$" . "table->foreign('" . $field->name . "')->references('" . $referencesKey . "')->on('" . $onTable->name . "');" . "\n\n";
                         } else {
                             $migrationScript .= "\t\t\t\t" . '$table->' . $this->typeLaravelMethod($field) . '(' . $this->fieldsArguments($field) . ');' . "\n";
                         }
                     } else {
                         $migrationScript .= "\t\t\t\t" . '$table->' . $this->typeLaravelMethod($field) . '(' . $this->fieldsArguments($field) . ');' . "\n";
                     }
                 }
             }
         }
         $migrationScript .= "\t\t\t\t" . '$table->timestamps();' . "\n";
         $migrationScript .= "\t\t\t" . '});' . "\n";
         $migrationScript .= "\t\t" . '}//endif' . "\n";
         //endif
         $migrationScript .= "\t" . '}' . "\n\n\n";
         //$migrationScript.='}'."\n";
         $migrationScript .= "\t" . 'public function down()' . "\n";
         $migrationScript .= "\t" . '{' . "\n";
         $migrationScript .= "\t\t" . 'if( Schema::hasTable("' . $table->tableName . '")) {' . "\n";
         $migrationScript .= "\t\t\t" . 'Schema::drop("' . $table->tableName . '");' . "\n";
         $migrationScript .= "\t\t" . '}' . "\n";
         $migrationScript .= "\t" . '}' . "\n";
         $migrationScript .= '}' . "\n\n\n";
         $order = $key;
         $nbOf0 = 6 - strlen($order);
         $zeros = '';
         for ($i = 0; $i < $nbOf0; $i++) {
             $zeros .= '0';
         }
         $order = $zeros . $order;
         $migrationTableName = $table->model == '' ? snake_case($table->name) : snake_case($table->model);
         //$migrationClassName= $table->model==''? camel_case($table->name):camel_case($table->model);
         // if ($table->name == 'contact_vehicle') {
         //     dd($migrationTableName);
         // }
         $migrationFileName = Carbon::now()->format('Y_m_d') . '_' . $order . '_create_' . $this->devis->app_name . '_' . $migrationTableName . '_table.php';
         $this->createFile('../database/migrations/' . $this->devis->app_name . '/' . $migrationFileName, $this->devis->app_name, $migrationScript, true);
     }
     echo "<div style='color:white; background-color:blue; padding:15px'>";
     echo "php artisan migrate --path=/database/migrations/" . $this->devis->app_name;
     echo "</div>";
     echo "<div style='color:white; background-color:purple; padding:15px'>";
     echo "<p>to seed a specific file<p>";
     echo "<h1>php artisan db:seed --class=MiddleDataBatch1Seeder</h1>";
     echo "</div>";
     \Artisan::call('migrate', array('--path' => '/database/migrations/' . $this->devis->app_name));
     // die('+++++++++++++qsdqsdqsdss++++++++++');
 }
Beispiel #20
0
 public function handle()
 {
     // dd('<-----FORM------->',$this->devis, $this->table ,$this->view);
     var_dump('***********************************************************************************************************');
     var_dump($this->table->name);
     $viewScript = "@extends('layouts." . $this->table->the_namespace->theme->name . "')" . "\n\n";
     $viewScript .= "@section('menu')" . "\n";
     $viewScript .= $this->tab1 . "@include('" . $this->devis->app_name . "." . $this->space->name . "/" . $this->menuFileNameUsed() . "')" . "\n";
     $viewScript .= "@endsection" . "\n";
     $viewScript .= "\n\n";
     $viewScript .= "@section('content')" . "\n";
     $viewScript .= '<h1>' . $this->title . '</h1>';
     $viewScript .= "\n";
     $viewScript .= "\n";
     $hasHasManyRelation = false;
     $relatedHasManyModel = [];
     foreach ($this->table->fields as $field) {
         foreach ($field->relations as $relation) {
             var_dump($relation->pivot->laravel_name);
             if (in_array($relation->pivot->laravel_name, ['hasMany', 'belongsToMany', 'morphToMany'])) {
                 $hasHasManyRelation = true;
                 var_dump('HM');
                 $related_table = Field::find($relation->pivot->to_field_id)->table;
                 $relatedHasManyModel[] = $relation;
                 echo "related";
                 var_dump($related_table->name);
             }
         }
     }
     $viewScript .= "\n";
     if (!empty($relatedHasManyModel)) {
         // if ($hasHasManyRelation) {
         $viewScript .= "\n    <div>\n\n  <!-- Nav tabs -->\n  <ul class='nav nav-tabs' role='tablist'>\n    <li role='presentation' class='active'><a href='#general' aria-controls='general' role='tab' data-toggle='tab'>General</a></li>" . "\n";
         foreach ($relatedHasManyModel as $key => $relatedModel) {
             $viewScript .= "<li role='presentation'><a href='#" . $relatedModel->name . "' aria-controls='" . $relatedModel->name . "' role='tab' data-toggle='tab'>" . $relatedModel->name . "</a></li>" . "\n";
         }
         $viewScript .= "\n  </ul>\n\n  <!-- Tab panes -->\n  <div class='tab-content'>\n    <div role='tabpanel' class='tab-pane fade in active' id='general'>@include('" . $this->table->viewPathInController() . ".form')</div>" . "\n";
         //foreach ($relatedHasManyModel as $key => $relatedModel) {
         foreach ($this->table->fields as $field) {
             foreach ($field->relations as $relation) {
                 if (in_array($relation->pivot->laravel_name, ['belongsToMany', 'morphedByMany', 'morphToMany'])) {
                     $related_table = \App\Table::find($relation->pivot->to_model);
                 }
                 if (in_array($relation->pivot->laravel_name, ['hasMany', 'belongsTo'])) {
                     $related_table = Field::find($relation->pivot->to_field_id)->table;
                 }
                 $fromField = Field::find($relation->pivot->from_field_id);
                 $toField = Field::find($relation->pivot->to_field_id);
                 $toModel = $toField->table;
                 if ($field->relations()->where('from_field_id', $fromField->id)->wherePivot('laravel_name', 'hasMany')->count() > 1) {
                     $functionNamne = $related_table->variablePlural . '_' . $toField->name;
                     $functionNamne = ends_with($functionNamne, '_id') ? substr($functionNamne, 0, -3) : $functionNamne;
                     $functionNamne = camel_case($functionNamne);
                 } else {
                     $functionNamne = $related_table->variablePlural;
                 }
                 if (in_array($relation->pivot->laravel_name, ['hasMany', 'belongsToMany', 'morphToMany'])) {
                     $viewScript .= "<div role='tabpanel' class='tab-pane fade' id='" . $functionNamne . "'>\n                                    @forelse(\$" . $this->table->variable . "->" . $functionNamne . " as \$" . $relatedModel->variable . ")\n                                    {{ \$" . $relatedModel->variable . " }}\n                                    @empty\n                                    No " . $relatedModel->name . " Yet\n                                    @endforelse\n                                </div>" . "\n\n";
                 }
             }
         }
         //}
         $viewScript .= "\n\n  </div>\n\n</div>\n    ";
     } else {
         $viewScript .= $this->tab1 . "@include('" . $this->table->viewPathInController() . ".form')";
     }
     //$viewScript.= $this->tab1.'<h1>'.$this->view.'</h1>';
     $viewScript .= "\n";
     $viewScript .= "\n";
     $viewScript .= "@endsection";
     // $viewScript.="\n\n";
     $this->createFile('../resources/views/' . $this->devis->app_name . '/' . $this->table->the_namespace->name . '/' . $this->table->model . '/' . $this->view . '.blade.php', $this->devis->app_name, $viewScript);
 }
Beispiel #21
0
 public function testRelations()
 {
     foreach ($this->tables()->where('model', '<>', '')->get() as $a => $table) {
         echo '<h5>&nbsp;&nbsp;&nbsp;&nbsp;<i style="color:green">></i> Preparing files for table <u style="color:#15c">';
         echo $table->name;
         echo '</u></h5>';
         $modelScript = '<?php' . "\n\n";
         $modelScript .= 'namespace ' . $table->modelNamespace() . ';' . "\n\n";
         $modelScript .= 'use Illuminate\\Database\\Eloquent\\Model;' . "\n\n";
         $useList = [];
         // if($table->name == 'users'){
         foreach ($table->fields as $field) {
             // echo $field->name.'<br>';
             foreach ($field->relations as $relation) {
                 // echo "<h1>".$relation->pivot->laravel_name."</h1>";
                 if ($relation->pivot->laravel_name == 'belongsToMany') {
                     $related_table = \App\Table::find($relation->pivot->to_model);
                     // $related_field = \App\Field::find($relation->pivot->on_field_id);
                     // $useList[]=$related_table->modelNamespaceClass();
                 } else {
                     $related_table = Field::find($relation->pivot->to_field_id)->table;
                 }
                 $useList[] = $related_table->modelNamespaceClass();
                 // echo $relation->table->modelNamespaceClass();
             }
         }
         // dd('class=>',$table->modelNamespaceClass(), 'uses=>', $useList);
         // }
         // var_dump($this->renderUsesStatements($useList));
         var_dump($useList);
         $modelScript .= 'class ' . $table->model . ' extends Model' . "\n";
         $modelScript .= '{' . "\n\n";
         // $modelScript.="\t TESTSTSTSTS";
         $modelScript .= $this->tab1 . 'protected $guarded = [];' . "\n";
         $modelScript .= $this->tab1 . 'protected $table = "' . $table->tablename . '";' . "\n";
         $modelScript .= "\n";
         foreach ($table->fields as $field) {
             foreach ($field->relations as $relation) {
                 if (isset($relation->name)) {
                     $related_table = Field::find($relation->pivot->to_field_id)->table()->first();
                     if ($relation->pivot->laravel_name == 'morphedByMany') {
                         $modelScript .= $this->tab1 . 'public function ' . $related_table->variablePlural . '() {' . "\n";
                         $relation->pivot->to_field_id = Field::find($relation->pivot->to_field_id)->name;
                         $modelScript .= $this->tab2 . 'return $this->morphedByMany(' . $related_table->modelNamespaceClass() . '::class);' . "\n";
                         $modelScript .= $this->tab1 . '}' . "\n";
                     }
                     if ($relation->pivot->laravel_name == 'belongsTo') {
                         $modelScript .= $this->tab1 . 'public function ' . $related_table->variable . '() {' . "\n";
                         $relation->pivot->to_field_id = Field::find($relation->pivot->to_field_id)->name;
                         $modelScript .= $this->tab2 . 'return $this->belongsTo(' . $related_table->modelNamespaceClass() . '::class);' . "\n";
                         $modelScript .= $this->tab1 . '}' . "\n";
                     }
                     if ($relation->pivot->laravel_name == 'hasMany') {
                         $modelScript .= $this->tab1 . 'public function ' . $related_table->variablePlural . '() {' . "\n";
                         $relation->pivot->to_field_id = Field::find($relation->pivot->to_field_id)->name;
                         $modelScript .= $this->tab2 . 'return $this->hasMany(' . $related_table->modelNamespaceClass() . '::class);' . "\n";
                         $modelScript .= $this->tab1 . '}' . "\n";
                     }
                     // var_dump($relation->name);
                 }
             }
         }
         $modelScript .= "\n\n";
         $modelScript .= '}' . "\n\n";
         // $modelScript='';
         // echo "------>";
         // if ($table->name == 'users') {
         //     dd($modelScript);
         // }
     }
     //dd('stop script model');
 }
Beispiel #22
0
 public function handle()
 {
     foreach ($this->devis->tables()->where('model', '<>', '')->get() as $a => $table) {
         // echo '<h5>&nbsp;&nbsp;&nbsp;&nbsp;<i style="color:green">></i> Preparing files for table <u style="color:#15c">';
         // echo $table->name;
         // echo '</u></h5>';
         $script = '<?php' . "\n\n";
         // dd($table->modelNamespace());
         $script .= 'namespace ' . $table->modelNamespace() . ';' . "\n\n";
         $script .= 'use Illuminate\\Database\\Eloquent\\Model;' . "\n\n";
         $useList = [];
         // if($table->name == 'users'){
         foreach ($table->fields as $field) {
             // echo $field->name.'<br>';
             foreach ($field->relations as $relation) {
                 if (in_array($relation->pivot->laravel_name, ['belongsToMany', 'morphedByMany', 'morphToMany'])) {
                     $related_table = \App\Table::find($relation->pivot->to_model);
                 }
                 if (in_array($relation->pivot->laravel_name, ['hasMany', 'belongsTo'])) {
                     $related_table = Field::find($relation->pivot->to_field_id)->table;
                 }
                 $useList[] = $related_table->modelNamespaceClass();
                 // echo $relation->table->modelNamespaceClass();
             }
         }
         // dd('class=>',$table->modelNamespaceClass(), 'uses=>', $useList);
         // }
         // var_dump($this->renderUsesStatements($useList));
         $script .= $this->renderUsesStatements($useList);
         $script .= 'class ' . $table->model . ' extends Model' . "\n";
         $script .= '{' . "\n\n";
         $script .= $this->tab1 . 'protected $guarded = [];' . "\n";
         $script .= $this->tab1 . 'protected $table = "' . $table->tablename . '";' . "\n";
         $dateFields = $table->fields->whereIn('field_type_id', [5, 6, 14]);
         // dd($dateFields->count());
         if ($dateFields->count() > 0) {
             $script .= $this->tab1 . 'protected $dates = [';
             foreach ($dateFields as $dateField) {
                 $script .= '\'' . $dateField->name . '\'' . ',';
             }
             $script = rtrim($script, ',');
             $script .= '];' . "\n";
         }
         //var_dump($table->getPrimaries()->count() > 0);
         if ($table->getPrimaries()->count() > 0) {
             if ($table->getPrimaries()->first()->name != 'id' && $table->getPrimaries()->count() == 1) {
                 $script .= $this->tab1 . 'protected $primaryKey = "' . $table->getPrimaries()->first()->name . '";' . "\n";
             }
         }
         $script .= "\n";
         foreach ($table->relationship() as $relation) {
             if ($relation['laravel_name'] == 'belongsTo') {
                 $defaultFieldName = strtolower(snake_case($relation['to_model'])) . '_id';
                 $script .= $this->tab1 . 'public function ' . $relation['methodName'] . '() {' . "\n";
                 $script .= $this->tab2 . 'return $this->belongsTo(' . $relation['to_model'] . '::class';
                 $showfirstArg = false;
                 if ($relation['from_field'] != $defaultFieldName) {
                     $showfirstArg = true;
                     $script .= ', "' . $relation['from_field'] . '"';
                 }
                 if ($relation['to_field'] != 'id') {
                     if (!$showfirstArg) {
                         $script .= ', "' . $relation['from_field'] . '"';
                     }
                     $script .= ', "' . $relation['to_field'] . '"';
                 }
                 $script .= ');' . "\n";
                 $script .= $this->tab1 . '}' . "\n";
             }
             if ($relation['laravel_name'] == 'hasMany') {
                 $defaultFieldName = strtolower(snake_case($relation['model'])) . '_id';
                 $script .= $this->tab1 . 'public function ' . $relation['methodName'] . '() {' . "\n";
                 $script .= $this->tab2 . 'return $this->hasMany(' . $relation['to_model'] . '::class';
                 $showfirstArg = false;
                 if ($relation['to_field'] != $defaultFieldName) {
                     $showfirstArg = true;
                     $script .= ', "' . $relation['to_field'] . '"';
                 }
                 if ($relation['from_field'] != 'id') {
                     if (!$showfirstArg) {
                         $script .= ', "' . $relation['to_field'] . '"';
                     }
                     $script .= ', "' . $relation['from_field'] . '"';
                 }
                 $script .= ');' . "\n";
                 $script .= $this->tab1 . '}' . "\n";
             }
             if ($relation['laravel_name'] == 'belongsToMany') {
                 /*
                  **  defaultPivotTableName
                  */
                 $array = array($relation['model'], $relation['to_model']);
                 sort($array);
                 $defaultPivotTableName = $this->devis->prefix() . strtolower($array[0] . '_' . $array[1]);
                 //end defaultPivotTableName
                 $script .= $this->tab1 . 'public function ' . $relation['methodName'] . '() {' . "\n";
                 //$relation->pivot->to_field_id = Field::find($relation->pivot->to_field_id)->name;
                 $script .= $this->tab2 . 'return $this->belongsToMany(' . $relation['to_model'] . '::class';
                 // $prefixNull=false;
                 // if ($this->devis->prefix() == '') {
                 //     $prefixNull=true;
                 //     // $script.=', "'.$this->devis->prefix().$relation['pivot_table'].'"';
                 // }else{
                 //     $prefixNull=false;
                 //
                 // }
                 $prefixNull = false;
                 if ($this->devis->prefix() == '') {
                     $prefixNull = true;
                 }
                 if ($this->devis->prefix() . $relation['pivot_table'] != $defaultPivotTableName || !$prefixNull) {
                     $script .= ', "' . $this->devis->prefix() . $relation['pivot_table'] . '"';
                 }
                 $script .= ');' . "\n";
                 $script .= $this->tab1 . '}' . "\n";
             }
         }
         $script .= "\n\n";
         /*
          **  specials methods fom the database class methods
          */
         foreach ($table->methods as $method) {
             // if ($method->isValidPHP()) {
             $script .= $this->tab1 . 'public function ' . $method->name . ' () {' . "\n";
             $script .= $this->tab2 . $method->content . "\n";
             $script .= $this->tab1 . "}\n\n";
             // }
         }
         $script .= "\n\n";
         $script .= '}' . "\n\n";
         // $script='';
         // echo "------>";
         // var_dump('../app/Models/'.$this->devis->app_name.'/'.$table->the_namespace->name.'/'.$table->model.'.php',$this->devis->app_name,$script);
         $this->createFile('../app/Models/' . $this->devis->app_name . '/' . $table->the_namespace->name . '/' . $table->model . '.php', $this->devis->app_name, $script, true);
         // die('++');
         //dd('123');
         // if ($table->name == 'users') {
         //     dd($script);
         // }
     }
     //dd('stop script model');
 }
 public function fieldReservations($id)
 {
     $field = Field::with('company', 'reservations')->find($id);
     return response()->json($field);
 }
Beispiel #24
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     return response()->json(Field::find($id));
 }
Beispiel #25
0
 public function create_belongsTo_relation_with(Request $request, Table $toModel)
 {
     $model = $this;
     $from_field_name = snake_case($toModel->model) . '_id';
     if ($request->has('from_field_id') && $request->from_field_id != '') {
         $from_field_name = Field::find($request->from_field_id)->name;
     }
     //dd($model);
     // $from_field_name = snake_case($toModel->model).'_id';
     $to_field_name = 'id';
     if ($toModel->hasPrimaries()) {
         $to_field_name = $toModel->getPrimaries()->first()->name;
     }
     // old --- $to_field_name = 'id';
     $field = $model->findOrCreate(['name' => $from_field_name, 'is_unsigned' => true, 'field_type_id' => 1]);
     $toField = $toModel->findOrCreate(['name' => $to_field_name, 'is_primary' => true, 'is_incrementable' => true, 'field_type_id' => 1]);
     // if ( !  $field->has_relation($toField)) {
     $field->relations()->attach($toField, ['from_field_name' => $field->name, 'to_field_name' => $toField->name, 'laravel_name' => $request->laravel_name, 'pivot_table_name' => '']);
     // }
     // else {
     // Flash::error('A relation Already exists beetween this 2 fields');
     // return false;
     // }
     $toField->relations()->attach($field, ['from_field_name' => $toField->name, 'to_field_name' => $field->name, 'laravel_name' => 'hasMany', 'pivot_table_name' => '']);
     // if ( !  $toField->has_relation($field)) {
     // }
     // else {
     //     Flash::error('A relation Already exists beetween this 2 fields');
     //     return false;
     // }
 }
 public function edit_announcement($id)
 {
     $fields = Field::orderBy('name')->lists('name', 'id');
     $terms = Term::lists('name', 'id');
     $municipalities = Municipality::lists('name', 'id');
     $regions = Region::lists('name', 'id');
     $type = array(0 => 'ვატარებ', 1 => 'ვეძებ');
     $quarter = Quarter::all()->lists('name', 'id');
     $months = Month::all()->lists('name', 'id');
     $select = DB::select(' SELECT trainings.id, field_training.field_id, term_training.term_id, municipality_training.municipality_id, month_training.month_id
                             FROM trainings
                             JOIN field_training ON trainings.id = field_training.training_id
                             JOIN term_training ON trainings.id = term_training.training_id
                             JOIN municipality_training ON trainings.id = municipality_training.training_id
                             JOIN month_training ON trainings.id = month_training.training_id
                             where trainings.id = ' . $id . '
                             group by trainings.id
                ');
     $select = $select[0];
     $training_filtered = new \stdClass();
     $training_instance = Training::find($select->id);
     $training_field = Field::find($select->field_id);
     $training_municipality = Municipality::find($select->municipality_id);
     $training_months = DB::select('SELECT months.name FROM month_training JOIN months ON months.id = month_training.month_id WHERE training_id = ' . $training_instance->id);
     $training_terms = DB::select('SELECT terms.name FROM term_training JOIN terms ON terms.id = term_training.term_id WHERE training_id = ' . $training_instance->id);
     foreach ($training_months as $month) {
         $training_months_array[] = $month->name;
     }
     foreach ($training_terms as $term) {
         $training_terms_array[] = $term->name;
     }
     $training_filtered->id = $training_instance->id;
     $training_filtered->header = $training_instance->name;
     $training_filtered->description = $training_instance->description;
     $training_filtered->file = $training_instance->file;
     $training_filtered->link = $training_instance->link;
     $training_filtered->field['name'] = $training_field->name;
     $training_filtered->field['id'] = $training_field->id;
     $training_filtered->months = $training_months_array;
     $training_filtered->terms = $training_terms_array;
     $training_filtered->municipality['name'] = $training_municipality->name;
     $training_filtered->municipality['id'] = $training_municipality->id;
     $training_filtered->region = $training_municipality->region_id;
     $training_filtered->isAdmin = Auth::check();
     return view('edit.edit_announcement', ['fields' => $fields, 'terms' => $terms, 'regions' => $regions, 'municipalities' => $municipalities, 'quarter' => $quarter, 'month' => $months, 'type' => $type, 'training' => $training_filtered]);
 }
Beispiel #27
0
 /**
  *
  * Mass assign a value to many records at once, similar to update, but loops through all of them
  *
  * @param $pid
  * @param $fid
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function massAssignRecords($pid, $fid, Request $request)
 {
     if (!$this->checkPermissions($fid, 'modify')) {
         return redirect()->back();
     }
     $flid = $request->input("field_selection");
     if (!is_numeric($flid)) {
         flash()->overlay("That is not a valid field");
         return redirect()->back();
     }
     if ($request->has($flid)) {
         $form_field_value = $request->input($flid);
         //Note this only works when there is one form element being submitted, so if you have more, check Date
     } else {
         flash()->overlay("You didn't provide a value to assign to the records", "Whoops.");
         return redirect()->back();
     }
     if ($request->has("overwrite")) {
         $overwrite = $request->input("overwrite");
         //Overwrite field in all records, even if it has data
     } else {
         $overwrite = 0;
     }
     $field = Field::find($flid);
     foreach (Form::find($fid)->records()->get() as $record) {
         if ($field->type == "Text") {
             $matching_record_fields = $record->textfields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $textfield = $matching_record_fields->first();
                 if ($overwrite == true || $textfield->text == "" || is_null($textfield->text)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $textfield->text = $form_field_value;
                     $textfield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $tf = new TextField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $tf->flid = $field->flid;
                 $tf->rid = $record->rid;
                 $tf->text = $form_field_value;
                 $tf->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         } elseif ($field->type == "Rich Text") {
             $matching_record_fields = $record->richtextfields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $richtextfield = $matching_record_fields->first();
                 if ($overwrite == true || $richtextfield->rawtext == "" || is_null($richtextfield->rawtext)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $richtextfield->rawtext = $form_field_value;
                     $richtextfield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $rtf = new RichTextField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $rtf->flid = $field->flid;
                 $rtf->rid = $record->rid;
                 $rtf->rawtext = $form_field_value;
                 $rtf->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         } elseif ($field->type == "Number") {
             $matching_record_fields = $record->numberfields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $numberfield = $matching_record_fields->first();
                 if ($overwrite == true || $numberfield->number == "" || is_null($numberfield->number)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $numberfield->number = $form_field_value;
                     $numberfield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $nf = new NumberField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $nf->flid = $field->flid;
                 $nf->rid = $record->rid;
                 $nf->number = $form_field_value;
                 $nf->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         } elseif ($field->type == "List") {
             $matching_record_fields = $record->listfields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $listfield = $matching_record_fields->first();
                 if ($overwrite == true || $listfield->option == "" || is_null($listfield->option)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $listfield->option = $form_field_value;
                     $listfield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $lf = new ListField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $lf->flid = $field->flid;
                 $lf->rid = $record->rid;
                 $lf->option = $form_field_value;
                 $lf->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         } elseif ($field->type == "Multi-Select List") {
             $matching_record_fields = $record->multiselectlistfields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $multiselectlistfield = $matching_record_fields->first();
                 if ($overwrite == true || $multiselectlistfield->options == "" || is_null($multiselectlistfield->options)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $multiselectlistfield->options = implode("[!]", $form_field_value);
                     $multiselectlistfield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $mslf = new MultiSelectListField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $mslf->flid = $field->flid;
                 $mslf->rid = $record->rid;
                 $mslf->options = implode("[!]", $form_field_value);
                 $mslf->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         } elseif ($field->type == "Generated List") {
             $matching_record_fields = $record->generatedlistfields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $generatedlistfield = $matching_record_fields->first();
                 if ($overwrite == true || $generatedlistfield->options == "" || is_null($generatedlistfield->options)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $generatedlistfield->options = implode("[!]", $form_field_value);
                     $generatedlistfield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $glf = new GeneratedListField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $glf->flid = $field->flid;
                 $glf->rid = $record->rid;
                 $glf->options = implode("[!]", $form_field_value);
                 $glf->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         } elseif ($field->type == "Date") {
             $matching_record_fields = $record->datefields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $datefield = $matching_record_fields->first();
                 if ($overwrite == true || $datefield->month == "" || is_null($datefield->month)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $datefield->circa = $request->input('circa_' . $flid, '');
                     $datefield->month = $request->input('month_' . $flid);
                     $datefield->day = $request->input('day_' . $flid);
                     $datefield->year = $request->input('year_' . $flid);
                     $datefield->era = $request->input('era_' . $flid, 'CE');
                     $datefield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $df = new DateField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $df->circa = $request->input('circa_' . $flid, '');
                 $df->month = $request->input('month_' . $flid);
                 $df->day = $request->input('day_' . $flid);
                 $df->year = $request->input('year_' . $flid);
                 $df->era = $request->input('era_' . $flid, 'CE');
                 $df->rid = $record->rid;
                 $df->flid = $flid;
                 $df->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         } elseif ($field->type == "Schedule") {
             $matching_record_fields = $record->schedulefields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $schedulefield = $matching_record_fields->first();
                 if ($overwrite == true || $schedulefield->events == "" || is_null($schedulefield->events)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $schedulefield->events = implode("[!]", $form_field_value);
                     $schedulefield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $sf = new ScheduleField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $sf->flid = $field->flid;
                 $sf->rid = $record->rid;
                 $sf->events = implode("[!]", $form_field_value);
                 $sf->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         } elseif ($field->type == "Geolocator") {
             $matching_record_fields = $record->geolocatorfields()->where("flid", '=', $flid)->get();
             $record->updated_at = Carbon::now();
             $record->save();
             if ($matching_record_fields->count() > 0) {
                 $geolocatorfield = $matching_record_fields->first();
                 if ($overwrite == true || $geolocatorfield->locations == "" || is_null($geolocatorfield->locations)) {
                     $revision = RevisionController::storeRevision($record->rid, 'edit');
                     $geolocatorfield->locations = implode("[!]", $form_field_value);
                     $geolocatorfield->save();
                     $revision->oldData = RevisionController::buildDataArray($record);
                     $revision->save();
                 } else {
                     continue;
                 }
             } else {
                 $gf = new GeolocatorField();
                 $revision = RevisionController::storeRevision($record->rid, 'edit');
                 $gf->flid = $field->flid;
                 $gf->rid = $record->rid;
                 $gf->locations = implode("[!]", $form_field_value);
                 $gf->save();
                 $revision->oldData = RevisionController::buildDataArray($record);
                 $revision->save();
             }
         }
     }
     flash()->overlay("The records were updated", "Good Job!");
     return redirect()->action('RecordController@index', compact('pid', 'fid'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     $field = Field::with('photos', 'company', 'reviews.user')->where('id', '=', $id)->get();
     return response()->json($field);
 }
Beispiel #29
0
 public function handle()
 {
     $fakerScript = '<?php' . "\n\n";
     foreach ($this->devis->tables()->where('model', '<>', '')->get() as $table) {
         // var_dump('------------------------',$table->name);
         // echo '<h5>&nbsp;&nbsp;&nbsp;&nbsp;<i style="color:green">></i> Preparing faker class for model <u style="color:#15c">';
         // echo $table->name;
         // echo '</u></h5>';
         if ($table->hasFixedRecords()) {
             $class = $table->modelNamespaceClass();
             if (Schema::hasTable($table->TableName)) {
                 $class::truncate();
             }
             foreach ($table->raws as $raw) {
                 $recordList = [];
                 foreach ($raw->records as $record) {
                     $recordList[$record->field->name] = $record->value;
                 }
                 $class::create($recordList);
             }
             continue;
         }
         //endif ($table->hasFixedRecords())
         $fakerScript .= '$factory->define(' . $table->modelNamespace() . '\\' . $table->model . '::class, function (Faker\\Generator $faker) {' . "\n";
         $fakerScript .= "\t" . '$faker = Faker\\Factory::create("fr_FR");' . "\n";
         $fakerScript .= "\t" . 'return [' . "\n";
         foreach ($table->fields as $field) {
             if ($field->is_incrementable) {
                 continue;
             }
             $hasRelation = false;
             foreach ($field->relations as $relation) {
                 if (in_array($relation->pivot->laravel_name, ['hasMany', 'belongsTo'])) {
                     $hasRelation = true;
                     $related_table = Field::find($relation->pivot->to_field_id)->table;
                     $toField = Field::find($relation->pivot->to_field_id);
                 }
                 // if ($related_table->name == 'vehicle_types') {
                 //     $fakerScript.="\t\t". '---->"'.$related_table->hasFixedRecords()."\n";
                 //     # code...
                 // }
                 if ($related_table->hasFixedRecords()) {
                     //dd($table->name,'123',$field->name);
                     // $fakerScript.="\t\t". '"'.$field->name.'" => $faker->'.$toField->randomFixedRecord()."\n";
                     $fakerScript .= "\t\t" . '"' . $field->name . '" => $faker->randomElement($array = ' . $toField->randomFixedRecord() . '),' . "\n";
                 } else {
                     $fakerScript .= "\t\t" . '"' . $field->name . '" => function () {' . "\n";
                     $fakerScript .= "\t\t\t" . 'return factory(';
                     $fakerScript .= $related_table->modelNamespaceClass() . '::class';
                     $fakerScript .= ')->create()->';
                     //$fakerScript.='id';
                     $fakerScript .= $related_table->getPrimaries()->first()->name;
                     $fakerScript .= ';' . "\n";
                     $fakerScript .= "\t\t" . '},' . "\n";
                 }
             }
             if (!$hasRelation) {
                 $fakerScript .= "\t\t" . '"' . $field->name . '" => ' . $this->fakerMethod($field) . ',' . "\n";
             }
         }
         $fakerScript .= "\t" . '];' . "\n";
         $fakerScript .= '});' . "\n";
         $fakerScript .= "\n\n";
     }
     //File::put('uploads/bootstrapping/'.$this->devis->app_name.'/ModelFactory/ModelFactory.php',$fakerScript);
     $this->createFile('../database/factories/' . $this->devis->app_name . '_factory.php', $this->devis->app_name, $fakerScript);
     foreach ($this->devis->tables()->where('model', '<>', '')->get() as $table) {
         if ($table->hasFixedRecords()) {
             continue;
         }
         if (Schema::hasTable($table->tablename)) {
             // dd($table->modelNamespaceClass());
             factory($table->modelNamespaceClass())->create();
             // factory(\App\Models\Middle\Web\Provider::class)->create();
             // echo "string";
         }
     }
     // '../database/factories/'.$this->app_name.'_factory.php',
 }
Beispiel #30
0
 public function handle()
 {
     // dd('<-----FORM------->',$this->devis, $this->table ,$this->view);
     $viewScript = "@extends('layouts." . $this->table->the_namespace->theme->name . "')" . "\n\n";
     $viewScript .= "@section('menu')" . "\n";
     $viewScript .= $this->tab1 . "@include('" . $this->devis->app_name . "." . $this->table->the_namespace->name . "/" . $this->menuFileNameUsed() . "')" . "\n";
     $viewScript .= "@endsection" . "\n";
     $basePath = $this->table->devis->app_name . '.' . $this->table->the_namespace->name . "." . $this->table->variable;
     if ($this->table->the_namespace->name == 'Web') {
         $basePath = $this->table->devis->app_name . "." . $this->table->variable;
     }
     $viewScript .= "\n@section('content')\n    <h1>" . $this->title . "</h1>\n    <a href='{{ route('" . $basePath . ".create') }}' class='btn btn-success btn-sm'><i class='fa fa-plus'></i> Create</a>\n" . "\n\n";
     $primary = '';
     if ($this->table->getPrimaries()->first()) {
         // dd($primary, )
         $primary = $this->table->getPrimaries()->first()->name;
         # code...
     } else {
         $viewScript .= "\n        <div class='alert alert-error'>PAs de primary yey sur cette table - - les liens edt et create ne fonctionne pas</div>\n\n        ";
     }
     $viewScript .= "\n<div class='table-responsive'>\n <table class='table table-striped table-bordered table-hover dataTables-example' data-toggle='table' data-search='true' data-show-columns='true' data-pagination='true' data-height='750'>\n  <thead>\n    <tr>\n        <th>Actions</th>";
     foreach ($this->table->fields()->where('is_on_index_view', 1)->orderBy('order', 'asc')->get() as $field) {
         $viewScript .= "\n            <th>" . $field->label . "</th>";
     }
     $viewScript .= "\n    </tr>\n</thead>\n<tbody>\n    @forelse(\$" . $this->table->variablePlural . " as \$" . $this->table->variable . ")\n<tr>\n\n\n\n            <td>\n\n            {{--\n                <a href='{{ route('" . $basePath . ".edit', [\$" . $this->table->variable . "->" . $primary . "]) }}'><i class='fa fa-edit'></i></a>\n                <a href='{{ route('" . $basePath . ".delete', [\$" . $this->table->variable . "->" . $primary . "]) }}'><i class='fa fa-times'></i></a>\n            --}}\n\n                <a href='{{ route('" . $basePath . ".edit', [\$" . $this->table->variable . "->" . $primary . "]) }}'><i class='fa fa-edit'></i></a>\n                {!! Form::open([\n                    'method'=>'DELETE',\n                    'route' => ['" . $basePath . ".destroy', \$" . $this->table->variable . "->" . $primary . "],\n                    'style' => 'display:inline'\n                ]) !!}\n                    {!! Form::submit('Delete', ['class' => 'btn btn-danger btn-xs', 'onclick'=>'return confirm()']) !!}\n                {!! Form::close() !!}\n\n\n            </td>\n";
     foreach ($this->table->fields()->where('is_on_index_view', 1)->orderBy('order', 'asc')->get() as $field) {
         $hasBelongsToRelation = false;
         // echo "--------------------------------------------<br>";
         // echo "<h1>".$field->name."</h1>";
         // echo "hasBelongsToRelation -->$hasBelongsToRelation";
         foreach ($field->relations()->get() as $key => $relation) {
             if (in_array($relation->pivot->laravel_name, ['belongsTo'])) {
                 $hasBelongsToRelation = true;
                 $fromField = Field::find($relation->pivot->from_field_id);
                 $toField = Field::find($relation->pivot->to_field_id);
                 $toModel = $toField->table;
                 $defaultFieldName = strtolower(snake_case($toModel->model)) . '_id';
                 if ($fromField->name == $defaultFieldName) {
                     if ($toModel->variable == 'update') {
                         $functionNamne = 'updat';
                     } else {
                         $functionNamne = $toModel->variable;
                     }
                 } else {
                     $functionNamne = camel_case($fromField->name);
                 }
                 $viewScript .= $this->tab3 . "<td>";
                 foreach ($toModel->fields()->where('is_on_foreign_label', 1)->get() as $fieldLabel) {
                     // $viewScript.='789';
                     $viewScript .= "{{ \$" . $this->table->variable . "->" . $functionNamne . "->" . $fieldLabel->name . " or ''}} ";
                 }
                 $viewScript .= "</td> " . "\n";
             }
         }
         // echo "hasBelongsToRelation2 -->$hasBelongsToRelation";
         if ($this->table->name == 'accounts') {
             // var_dump('---->',$field->name);
         }
         if (!$hasBelongsToRelation) {
             //$viewScript.="<td>";
             if ($field->type->name == 'text') {
                 // str_limit('The PHP framework for web artisans.', 7);
                 $viewScript .= $this->tab3 . "<td>{{ str_limit(\$" . $this->table->variable . "->" . $field->name . ", 7)}}</td> " . "\n";
             } else {
                 $viewScript .= $this->tab3 . "<td>{{ \$" . $this->table->variable . "->" . $field->name . "}}</td> " . "\n";
             }
         }
         // $viewScript.=
     }
     $viewScript .= "\n            <!--<td>\n                {{ \$" . $this->table->variable . "->" . $field->name . " }}\n            </td>-->\n</tr>\n\n    @empty\n\n            <tr><td>No data yet ...</td><tr>\n\n    @endforelse\n    </tbody>\n</table>\n</div>\n";
     $viewScript .= "\n@endsection\n";
     $this->createFile('../resources/views/' . $this->devis->app_name . '/' . $this->table->the_namespace->name . '/' . $this->table->model . '/' . $this->view . '.blade.php', $this->devis->app_name, $viewScript);
 }