/** * @inheritdoc */ public function belongs(Table $table) { $tmp_vector = array_reverse(array_map(function ($val) { return ($val + 1) % 2; }, $table->getVector())); return $tmp_vector == $table->getVector() || (new CClass())->belongs($table); }
/** * @inheritdoc */ public function belongs(Table $table) { $vector = $table->getVector(); $count_vector = count($vector); $truth_table = $table->getTruthTable(); $count_line = count($truth_table[0]); $sets = []; for ($i = 0; $i < $count_vector; $i++) { if ($vector[$i] == 1) { array_push($sets, $i); } } $sets_count = count($sets); if ($sets_count < 2) { return false; } for ($i = 0; $i < $count_line; $i++) { $k = 0; for ($j = 0; $j < $sets_count; $j++) { if ($truth_table[$sets[$j]][$i] == 1) { $k++; } } if ($k > 1) { return true; } } return false; }
/** * Examples: xy, 0, 1 * @inheritdoc */ public function belongs(Table $table) { $sknf = 0; $vector = $table->getVector(); $count = count($vector); for ($i = 0; $i < $count; $i++) { if ($vector[$i] == 0) { $sknf++; } } return $sknf != 1; }
/** * @inheritdoc */ public function belongs(Table $table) { $values = []; $truth_table = $table->getTruthTable(); $vector = $table->getVector(); $count_vector = count($vector); $count_line = count($truth_table[0]); for ($i = 0; $i < $count_vector; $i++) { $line_values = []; array_push($line_values, '0'); for ($t = 0; $t < $count_line; $t++) { for ($j = 0; $j < $count_line; $j++) { if ($truth_table[$i][$j] == '1') { $k = $j + 1; $tmp_key = (string) $k; while (strlen($tmp_key) != $t + 1 && $k != $count_line) { if ($truth_table[$i][$k] == '1') { $tmp_key .= $k + 1; } $k++; } if (!in_array($tmp_key, $line_values)) { array_push($line_values, $tmp_key); } } } } $find_key = '0'; $find_val = 0; $tmp_val = 0; foreach ($line_values as $value) { if (!array_key_exists($value, $values)) { $find_key = $value; } else { $tmp_val += (int) $values[$value]; } } if ($tmp_val % 2 != (int) $vector[$i]) { $find_val = 1; } $values[$find_key] = $find_val; } foreach ($values as $key => $value) { if ($key > 10 && $value == 1) { return false; } } return true; }
/** * @inheritdoc */ public function belongs(Table $table) { $vector = $table->getVector(); $count_vector = count($vector); $nulls = 0; $ones = 0; for ($i = 0; $i < $count_vector; $i++) { if ($vector[$i] == 0) { $nulls++; } else { $ones++; } } return $nulls == $count_vector || $ones == $count_vector; }
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; }
/** * @inheritdoc */ public function belongs(Table $table) { $vector = $table->getVector(); $count = count($vector); for ($i = 0; $i < $count; $i++) { if ($vector[$i] == 1) { for ($j = $i + 1; $j < $count; $j++) { if ($vector[$j] == 0) { return false; } } return true; } } return true; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StoreTableRequest $request) { $table = new Table(); $table->name = $request->get('name'); $table->fields = $request->get('fields'); $table->visible = $request->get('visible'); $table->save(); Schema::create($table->name, function ($dbTable) use($table) { foreach ($table->fields as $field) { $fieldType = $field['type']; $fieldName = $field['name']; $dbTable->{$fieldType}($fieldName); } }); return redirect('/tables'); }
/** * Seed the tags table */ public function run() { Table::truncate(); Table::create(['name' => 'users', 'sheetsu_url' => 'https://sheetsu.com/apis/f3b4ef5f', 'google_url' => 'https://docs.google.com/spreadsheets/d/1aERPe066OVhzt4vTVpo3e_F9y0OhFmiktBp3UmL7PvQ/edit#gid=0']); Table::create(['name' => 'posts', 'google_url' => 'https://docs.google.com/spreadsheets/d/1AQwg3T-krYmJjmu-dEX8ql8AS8H65tLqF7y9DVBXrpg/edit#gid=0', 'sheetsu_url' => 'https://sheetsu.com/apis/d2cc733e']); Table::create(['name' => 'user_friend_pivot', 'google_url' => 'https://docs.google.com/spreadsheets/d/1_sLyWSV38lVrueCIZPjBxy5rLbcrQcX8tyynuS-8cYk/edit#gid=0', 'sheetsu_url' => 'https://sheetsu.com/apis/c3684899']); }
/** * Run the database seeds. * * @return void */ public function run() { $timestamp = date('Y-m-d G:i:s'); $foods = [['name' => 'Rezanci Sicilijana', 'price' => '860', 'type' => 'meal', 'fats' => '500', 'proteins' => '', 'carbs' => '', 'eta' => '15', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['name' => 'Rižota z bučkami in gamberi', 'price' => '1080', 'type' => 'meal', 'fats' => '600', 'proteins' => '', 'carbs' => '', 'eta' => '15', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['name' => 'Ajdovi njoki z jurčki in tartufi', 'price' => '1380', 'type' => 'meal', 'fats' => '600', 'proteins' => '', 'carbs' => '', 'eta' => '15', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['name' => 'Espresso', 'price' => '140', 'type' => 'drink', 'fats' => '', 'proteins' => '', 'carbs' => '', 'eta' => '2', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['name' => 'Zeleni čaj', 'price' => '180', 'type' => 'drink', 'fats' => '', 'proteins' => '', 'carbs' => '', 'eta' => '2', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['name' => 'Tiramisu', 'price' => '480', 'type' => 'dessert', 'fats' => '', 'proteins' => '', 'carbs' => '', 'eta' => '2', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['name' => 'Čokoladni souffle', 'price' => '650', 'type' => 'dessert', 'fats' => '', 'proteins' => '', 'carbs' => '', 'eta' => '2', 'created_at' => $timestamp, 'updated_at' => $timestamp]]; \App\Food::insert($foods); $tables = [['number' => '1', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['number' => '2', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['number' => '3', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['number' => '4', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['number' => '5', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['number' => '6', 'created_at' => $timestamp, 'updated_at' => $timestamp], ['number' => '7', 'created_at' => $timestamp, 'updated_at' => $timestamp]]; \App\Table::insert($tables); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $table = Table::find($id); $table->number = ''; $table->save(); $table->delete(); return redirect()->back()->withSuccess('Tafel succesvol verwijderd.'); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $rules = []; $type = $this->get('type'); $table = Table::where('name', $type)->firstOrFail(); foreach ($table->fields as $field) { $rules[$field['name']] = 'required'; } return $rules; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StoreContentRequest $request) { $table = Table::where('name', $this->contentType)->first(); $attributes = []; foreach ($table->fields as $field) { $attributes[$field['name']] = $request->get($field['name']); } DB::table($this->contentType)->insert($attributes); return redirect("/content?type={$this->contentType}"); }
/** * @inheritdoc */ public function belongs(Table $table) { $vector = $table->getVector(); $count_vector = count($vector); $truth_table = $table->getTruthTable(); $count_line = count($truth_table[0]); for ($i = 0; $i < $count_line; $i++) { $k = 0; for ($j = 0; $j < $count_vector; $j++) { if ($vector[$j] <= $truth_table[$j][$i]) { $k++; } } if ($k == $count_vector) { return true; } } return false; }
/** * Show the form for editing the specified resource. * * @param int $id * * @return Response */ public function edit(Devis $devis, $table_id, $field_id) { $table = Table::findOrFail($table_id); $field = Field::findOrFail($field_id); $firstField = $devis->tables()->where('id', $table->id)->first()->fields->first(); $tableList = $devis->tables()->get(); $fieldList = $table->fields()->get(); $fieldTypeList = FieldType::all()->lists('name', 'id'); $fakerList = []; //$tableList = Table::lists('model'); return view('admin.field.edit', compact('field', 'tableList', 'devis', 'table', 'fieldList', 'firstField', 'fieldTypeList', 'fakerList')); }
public function handle() { $script = ''; /* ** create */ $script .= $this->tab1 . 'public function create()' . "\n"; $script .= $this->tab1 . '{' . "\n"; // admin.client.create foreach ($this->relationship as $relation) { $table_ = Table::find($relation['to_model_id']); if (in_array($relation['laravel_name'], ['belongsTo', 'belongsToMany'])) { $foreignLabelList = $table_->fields()->where('is_on_foreign_label', 1); if ($foreignLabelList->count() == 1) { $label = $foreignLabelList->first()->name; $script .= $this->tab2 . '$' . $table_->variablePlural . '=' . $table_->model . '::lists("' . $label . '", "' . $table_->getPrimaries()->first()->name . '");' . "\n"; } if ($foreignLabelList->count() > 1) { $script .= $this->tab2 . '$' . $table_->variablePlural . '=' . $table_->model . '::select(\\DB::raw("CONCAT('; $label = ''; foreach ($foreignLabelList->get() as $key => $foreignLabel) { $label .= $foreignLabel->name; if ($key + 1 != $foreignLabelList->count()) { $label .= ", ' ', "; } } $script .= $label . ') AS full_name, ' . $table_->getPrimaries()->first()->name . '"))->lists("full_name", "' . $table_->getPrimaries()->first()->name . '");' . "\n"; } else { if ($foreignLabelList->count() == 0) { echo "<div style='color:white; background-color:red'>\n <h1>You have to specify a foreign_label for the table <a target='_blank' href='" . route('admin.devis.{devis}.tables.fields.create', [$this->devis->id, $table_->id]) . "'>{{$table_->name}}</a></h1>\n </div>"; } } } } $script .= $this->tab2 . "return View::make('" . $this->viewbasePath . ".create'"; if (count($this->relationship) > 0) { $script .= ', compact(['; } foreach ($this->relationship as $relation) { $table_ = Table::find($relation['to_model_id']); if (in_array($relation['laravel_name'], ['belongsTo', 'belongsToMany'])) { $script .= "'" . $table_->variablePlural . "',"; } } $script = rtrim($script, ","); if (count($this->relationship) > 0) { $script .= '])'; } $script .= ");" . "\n"; $script .= $this->tab1 . '}' . "\n\n"; return $script; }
public function ManyComponents() { if ($this->table->hasHasManyRelation()) { foreach ($this->table->hasHasManyRelationList() as $relation) { $related_model = \App\Table::find($relation['to_model_id']); $componentName = $related_model->vueComponentName('list', $relation['methodName']); $path = $this->table->vueComponentRelativePathTo($related_model, 'list'); $importScriptLine = 'import ' . $componentName . ' from \'' . $path . '\''; $methodName = $relation['methodName']; $this->ManyComponents->push(compact(['componentName', 'path', 'importScriptLine', 'related_model', 'methodName'])); } } }
public function closeOrder($tableId) { echo '<pre>'; $table = Table::find($tableId); $client = $table->clients()->orderBy('entertime', 'DESC')->first(); var_dump($table); $lastOrder = $client->orders()->where('endtime', NULL)->get(); foreach ($lastOrder as $order) { $order->endtime = Carbon::now('Europe/Brussels'); $order->save(); } return 'ended'; }
public function getVariableList() { foreach ($this->relationship as $relation) { $table_ = Table::find($relation['to_model_id']); if (in_array($relation['laravel_name'], ['belongsTo', 'belongsToMany'])) { $this->viewsVariableList->push($table_); } else { if (in_array($relation['laravel_name'], ['hasMany'])) { $related_table = Table::find($relation['to_model_id']); foreach ($related_table->relationship() as $relation_2) { if (in_array($relation_2['laravel_name'], ['belongsTo', 'belongsToMany'])) { $related_table_2 = Table::find($relation_2['to_model_id']); $this->viewsVariableList->push($related_table_2); } } } } } return $this; }
public function pull($id) { $table = Table::find($id); $url = $table->sheetsu_url; $client = new Client(); $json = $client->get($url); $data = json_decode($json->getBody()); $goto = ''; switch ($table->name) { case 'users': $goto = $this->updateUsers($data->result); break; case 'posts': $goto = $this->updatePosts($data->result); break; case 'user_friend_pivot': $goto = $this->updateFriends($data->result); break; } return redirect($goto); }
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"; $viewScript .= "\n"; $viewScript .= "@section('content')" . "\n"; $viewScript .= '<h1>' . $this->title . '</h1>'; foreach ($this->table->relationship() as $relation) { $table_ = Table::find($relation['to_model_id']); if ($relation['laravel_name'] == 'belongsTo') { $viewScript .= "\n"; //$viewScript.='{{var_dump($'.$table_->variablePlural.')}}'."\n"; } } $viewScript .= $this->tab1 . "@include('" . $this->table->viewPathInController() . ".form')" . "\n"; $viewScript .= '@endsection'; $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); }
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 sortMigrationArray() { foreach ($this->devis->tables as $table) { # get list $requireTables //ok // $table = Table::find($table_id); echo $table->name; $requireTables = []; foreach ($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); $requireTables[] = $related_table->id; } if (in_array($relation->pivot->laravel_name, ['belongsTo'])) { $related_table = Field::find($relation->pivot->to_field_id)->table; $requireTables[] = $related_table->id; } } } var_dump($requireTables); # get the current position of the table $currentindex // dd($this->migrationsArray->search('1')); var_dump($this->migrationsArray); foreach ($requireTables as $key => $requireTable) { #remove the requireTables from array $index = array_search($requireTable, $this->migrationsArray); unset($this->migrationsArray[$index]); var_dump($currentTableIndex); //place le require fields before the $currentindex $this->insert_before($this->migrationsArray, $currentTableIndex, array($index => $requireTable)); } var_dump($this->migrationsArray); //die('++-++-'); // } } }
public static function constructRouterVue____________________old(Table $table, $chaine_cumul = '', $chaine_list = '', $chaine_edit = '', $loop = 0) { var_dump($table->RouterVue); var_dump($loop); $chaine_cumul .= $table->name . '/'; $chaine_list = str_replace('/', '/id/', $chaine_cumul); $chaine_edit = rtrim($chaine_list, '/id/'); //put thre keys // $chaine_list.=$table->primary().'/'; // $chaine_cumul.=$table->name.'/'; foreach ($table->hasHasManyRelationList() as $relation) { // var_dump($relation); $toTable = Table::find($relation['to_model_id']); //var_dump(rtrim($chaine_list, '/')); //var_dump(rtrim($chaine_edit, '/')); Table::constructRouterVue($toTable, $chaine_cumul, $chaine_list, $chaine_edit, $loop++); } var_dump(rtrim($chaine_list, '/')); $table->RouterVue->push(['type' => 'list', 'route' => rtrim($chaine_list, '/')]); var_dump(rtrim($chaine_edit, '/')); $table->RouterVue[] = ['type' => 'list', 'route' => rtrim($chaine_list, '/')]; // var_dump(rtrim($chaine_cumul, '/')); // if (isset($toTable)) { //Table::constructRouterVue($table, $chaine_cumul, $chaine_list, $chaine_edit, $loop++); # code... // } }
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 putGuestBackToDistribution($id) { $guest = Guest::find($id); $currentQue = Que::where('guest_id', $id)->limit(1)->orderBy('the_time')->first(); $previousTable = Table::find(GuestRoute::where('guest_id', $id)->where('position_id', 2)->limit(1)->orderBy('the_time', 'desc')->first()->table_id); $guest = Guest::find($id); $guest->is_inside = 1; $guest->status = 'after test drive'; $guest->save(); $guestRoute = new GuestRoute(); $guestRoute->guest_id = $id; $guestRoute->position_id = 2; $guestRoute->branche_id = $previousTable->branche_id; $guestRoute->save(); $previousTable->current_que = $previousTable->current_que + 1; $previousTable->guests_count = $previousTable->guests_count + 1; $previousTable->save(); $numberOfQue = count(Que::where('table_id', $previousTable->id)->get()); if (intval($numberOfQue) > 2) { $lastTwo = Que::where('table_id', $previousTable->id)->limit(3)->orderBy('the_time', 'desc')->get(); $the_time = Carbon::parse($lastTwo[2]->the_time)->addSecond(); } else { $the_time = Carbon::now()->addMinutes(5); } $currentQue->the_time = $the_time; $currentQue->table_id = $previousTable->id; $currentQue->save(); return redirect()->back(); }
public function getTableStatus() { $tables = Table::all(); foreach ($tables as $table) { //check if table has clients if (count($table->clients()->where('leavetime', null)->get())) { $table->hasClient = true; $client = $table->clients()->where('leavetime', null)->first(); //check if client is waiting if (count($client->orders) > 0) { $order = $client->orders()->where('endtime', '=', null)->first(); if ($order) { $table->waiting = true; } else { $table->waiting = false; } } else { $table->waiting = false; } } else { $table->hasClient = false; } } return $tables->toJson(); }
public function handle() { foreach ($this->devis->tables()->where('model', '<>', '')->get() as $a => $table) { // echo '<h5> <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 handle() { $script = ' <style> .spacer{ height: 50px; display: block; } </style> <template > <!--<pre>{{object | json}}</pre>--> <h1>' . $this->table->model . ' Form</h1> <div v-if="loading"> <ui-preloader :show="true"></ui-preloader> </div> <div class="row" v-show="!loading"> <div class="col-lg-12"> <div class="ibox float-e-margins"> <div class="ibox-title"> <!--<div class="row" v-if="mode==\'update\'"> <div class="col-md-12"> <div class="pull-right"><a @click="deleteObject(object)"> Detete</a></div> </div> </div>--> </div> <div class="ibox-content"> <validator name="validation1"> <form novalidate class="form-horizontal form-label-left">'; foreach ($this->table->fields()->orderBy('order', 'asc')->get() as $field) { if ($field->is_incrementable || in_array($field->name, ['created_at', 'updated_at', 'updated_by'])) { continue; } //v-if="\''.$field->name.'\'=!label" $script .= ' <div > ' . $this->VueformType($field) . ' </div> '; //<!--<div v-else> // <input type="text" :name="label" :value="value"> // </div>--> } $script .= ' <div class="col-sm-12"> <!--<button @click="cancel" class="btn btn-default pull-right">Cancel</button>--> <!--<button v-if="mode==\'update\'" @click.prevent="deleteObject(object)" class="btn btn-danger pull-left">Delete</button>--> <ui-icon-button v-if="mode==\'update\'" icon="delete" @click.prevent="deleteObject(object)" tooltip="Delete" type="normal" color="danger" class="pull-left" ></ui-icon-button> <button @click.prevent="submit(object)" class="btn btn-primary pull-right" :disabled="$validation1.invalid'; // foreach ($this->table->relationship() as $relation) { // if (in_array($relation['laravel_name'], ['belongsTo'])) { // $fromField = Field::find($relation['from_field_id']); // if ($fromField->isRequired()) { // $script.=' && !object.'.$fromField->name; // } // } // } $script .= ' "> <b v-if="mode==\'create\'">Create</b> <b v-if="mode==\'update\'">Update</b> ' . $this->table->model . ' <i class="fa fa-spin fa-spinner" v-show="sending"></i> </button> </div> </form> </validator> </div> </div> </div> </div> </template> <script> // import modal from \'../../snippets/modal.vue\'; ' . "\n"; $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 .= 'import ' . $related_model->vueComponentName('form') . ' from \'' . $this->table->vueComponentRelativePathTo($related_model, 'form') . '\'' . "\n"; } } $script .= ' export default { components: { '; $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 .= $this->tab4 . $related_model->vueComponentName('form') . ',' . "\n"; } } $script .= ' }, props :{ forceMode : { required: false, type:String, }, createdObject : { required: false, type:Object, }, // label : { // required: false, // type:String, // }, // value : { // required: false, // type:String, // } }, ready () { for (label in this.$route.params) { //console.log(label + \' : \' + this.$route.params[label]); '; //get the list of the forign foreach ($this->table->getForeignFieldList() as $field) { $script .= ' if (label == \'' . $field->name . '\') { var elem = document.querySelector(".' . $field->name . '"); // detruit le field dont on a la valeur elem.parentNode.removeChild(elem); this.object.' . $field->name . '=this.$route.params[label] //pre fill the form with the data } '; } $script .= ' } '; $script .= 'this.loading=true' . "\n"; if ($this->table->hasBelongsToRelation()) { foreach ($this->table->belongsToRelationList() as $relation) { $related_model = \App\Table::find($relation['to_model_id']); //$components[] = $relation['to_model_id']; $script .= 'this.fetch' . $related_model->model . '()' . "\n"; } } else { $script .= 'this.fetchObject()' . "\n"; } // 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.='this.fetch'.$related_model->model.'()'."\n"; // } // } $script .= ' // if (this.mode == \'update\') { // this.loading=true // this.fetchObject() // } }, watch: { '; $components = []; foreach ($this->table->relationship() as $relation) { if (in_array($relation['laravel_name'], ['belongsTo']) && !in_array($relation['to_model_id'], $components)) { $related_model = \App\Table::find($relation['to_model_id']); $components[] = $relation['to_model_id']; $script .= ' \'created' . $related_model->model . '\' :function (val, oldVal) { this.object.' . $relation['from_field'] . '=this.created' . $related_model->model . '.' . $related_model->primary() . ' },'; } } if ($this->table->hasBelongsToRelation()) { $script .= ' \'EverythingLoaded\': function (val, oldVal) { //#vtest# if(this.mode == \'update\') { if (val) { this.fetchObject() } }else { this.loading=false } }, ' . "\n"; } else { //no belongsTo Relation // $script.=' // if(this.mode == \'update\') { // if (val) { // this.fetchObject() // } // }else { // this.loading=false // } // '; } $script .= ' }, data(){ return { //debug:true, activityList:[], sending:false, loading:false, object:{}, '; $components = []; $toLoad = []; 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']; $functionLoadName = $related_model->model . 'Loaded'; $toLoad[] = $functionLoadName; $script .= ' showForm_' . $related_model->variable . ' : false,' . "\n"; $script .= ' created' . $related_model->model . ' : {},' . "\n"; $script .= ' ' . $related_model->model . 'List:[],' . "\n"; $script .= ' ' . $related_model->model . 'Loaded:[],' . "\n"; } } // if ($this->table->hasBelongsToRelation()){ // $toLoad = []; // foreach ( $this->table->belongsToRelationList() as $relation) { // $related_model = \App\Table::find($relation['to_model_id']); // $functionLoadName = 'fetch'.$related_model->model.'Loaded'; // $toLoad[]=$functionLoadName; // $script.=' // '.$functionLoadName.':false,'."\n"; // // $script.=$functionLoadName.','."\n" ; // // // '.$functionLoadName.' : function(){ // // return this.'.$related_model->model.'List[0]? true : false // // }, // // '."\n"; // // } // } $script .= ' }; }, filters:{ }, computed : { mode : function (){ if(this.forceMode){ return this.forceMode } return this.$route.params.' . strtolower(snake_case($this->table->model)) . '_id' . ' ? \'update\' : \'create\' }, '; if ($this->table->hasBelongsToRelation()) { // $toLoad = []; // foreach ( $this->table->belongsToRelationList() as $relation) { // $related_model = \App\Table::find($relation['to_model_id']); // $functionLoadName = 'fetch'.$related_model->model.'Loaded'; // $toLoad[]=$functionLoadName; // $script.=' // '.$functionLoadName.' : function(){ // return this.'.$related_model->model.'List[0]? true : false // }, // '."\n"; // } $script .= ' EverythingLoaded : function() { return '; foreach ($toLoad as $function) { $script .= 'this.' . $function . ' && '; //this.fetchUserLoaded && this.fetchVehicleLoaded } $script = rtrim($script, '&& '); $script .= ' } ' . "\n"; } $script .= ' }, 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 }); }, ' . "\n"; $components = []; foreach ($this->table->relationship() as $relation) { if (in_array($relation['laravel_name'], ['belongsTo'])) { $script .= ''; $related_model = \App\Table::find($relation['to_model_id']); $components[] = $relation['to_model_id']; $script .= ' //retrouver les données du belong to pour afficher la liste déroulante fetch' . $related_model->model . '(){ this.$http.get(\'/api/' . $this->devis->app_name . '/' . $related_model->name . '\').then(function (response) { this.' . $related_model->model . 'List = response.data.data this.' . $related_model->model . 'Loaded = true }, function (response) { // error callback }); },'; } elseif (in_array($relation['laravel_name'], ['hasMany'])) { } } $script .= ' submit(object) { this.sending=true if(this.mode == \'create\'){ this.$http.post(\'/api/' . $this->devis->app_name . '/' . $this->table->name . '\', object).then(function (response) { this.sending=false this.object = response.data.data' . "\n"; if ($this->table->hasPrimaries()) { $script .= ' this.createdId = response.data.data.' . $this->table->primary(); $script .= ' this.createdObject = response.data.data this.object={}'; $script .= "\n"; } $components = []; $script .= ' if (!this.forceMode) { '; if ($this->table->hasHasManyRelation() && $this->table->hasPrimaries()) { $script .= ' this.$route.router.go(\'/' . $this->table->name . '/\'+object.' . $this->table->primary() . ')'; } else { $script .= ' this.$route.router.go(window.history.back())'; } $script .= ' } '; $script .= ' }, function (response) { alert(\'erreur\') setTimeout(function() { debugger; }, 10000) throw new Error("Something went badly wrong!"); }); }// endif mode create else if (this.mode == \'update\'){ '; if ($this->table->hasPrimaries()) { $script .= ' this.$http.put(\'/api/' . $this->devis->app_name . '/' . $this->table->name . '/\'+object.' . $this->table->primary() . ', object).then(function (response) { this.sending=false this.object = response.data.data' . "\n"; $script .= ' this.createdObject = response.data.data' . "\n"; // $script.=' // this.$route.router.go(\'/'.$this->table->name.'/\'+object.'.$this->table->primary().')'; $script .= ' this.$route.router.go(\'/' . $this->table->name . '\')'; // if ($this->table->hasHasManyRelation()) { // }else { // $script.='this.$route.router.go(window.history.back())'; // } $script .= ' }, function (response) { alert(\'erreur\') setTimeout(function() { debugger; }, 10000) throw new Error("Something went badly wrong!"); }); '; } //end if ($this->table->hasPrimaries()) $script .= ' }//endif mode update }, cancel() { this.$route.router.go(window.history.back()) }, deleteObject(object) { '; if ($this->table->hasPrimaries()) { $script .= ' this.$http.delete(\'/api/' . $this->devis->app_name . '/' . $this->table->name . '/\'+object.' . $this->table->primary() . ', object).then(function (response) { this.sending=false this.$route.router.go(\'/' . $this->table->name . '\')'; $script .= ' }, function (response) { alert(\'erreur\') setTimeout(function() { debugger; }, 10000) throw new Error("Something went badly wrong!"); }); '; } //end if ($this->table->hasPrimaries()) { $script .= ' }, }, } </script> '; // File::put('uploads/bootstrapping/'.$this->devis->app_name.'/vue_components/'.$this->table->model.'/form.vue',$script); $this->createFile($this->path(), $this->devis->app_name, $script); }
public function search() { $name = Request::input('name'); return View('users.search')->with('tables', Table::where('name', 'like', '%' . $name . '%')->paginate(7)); }