/**
  * 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}");
 }
Beispiel #3
0
 /**
  * Saves matches into database
  *
  * 
  */
 public function storeGamesForm(SaveGamesRequest $request)
 {
     $input = $request->except('_token');
     $count = count($input['match_id']);
     for ($i = 0; $i < $count; $i++) {
         if ($input['home_goals'][$i] != '') {
             DB::table('matches')->where('id', $input['match_id'][$i])->update(['home_goals' => $input['home_goals'][$i], 'away_goals' => $input['away_goals'][$i]]);
         }
     }
     // Update Tables .tables
     for ($i = 0; $i < $count; $i++) {
         if ($input['home_goals'][$i] != '') {
             // Update der Heimmannschaft
             $homePoints = 0;
             if ($input['home_goals'][$i] > $input['away_goals'][$i]) {
                 $homePoints = 3;
             } elseif ($input['home_goals'][$i] === $input['away_goals'][$i]) {
                 $homePoints = 1;
             }
             //TODO: Check if club_id exists in table
             if (Table::where('club_id', $input['home_id'][$i])->first() != NULL) {
                 Table::where('club_id', $input['home_id'][$i])->update(['goals' => DB::raw('goals +' . $input['home_goals'][$i]), 'goals_against' => DB::raw('goals_against +' . $input["away_goals"][$i]), 'matchday_count' => DB::raw('matchday_count + 1'), 'points' => DB::raw('points + ' . $homePoints)]);
             } else {
                 Table::insert(['club_id' => $input['home_id'][$i], 'goals' => DB::raw('goals +' . $input['home_goals'][$i]), 'goals_against' => DB::raw('goals_against +' . $input["away_goals"][$i]), 'matchday_count' => DB::raw('matchday_count + 1'), 'points' => DB::raw('points + ' . $homePoints), 'league_id' => $input['league'], 'season' => $input['season']]);
             }
             //Update der Auswärtsmannschaft
             $awayPoints = 0;
             if ($input['home_goals'][$i] < $input['away_goals'][$i]) {
                 $awayPoints = 3;
             } elseif ($input['home_goals'][$i] == $input['away_goals'][$i]) {
                 $awayPoints = 1;
             }
             if (Table::where('club_id', $input['away_id'][$i])->first() != NULL) {
                 Table::where('club_id', $input['away_id'][$i])->update(['goals' => DB::raw('goals + ' . $input["away_goals"][$i]), 'goals_against' => DB::raw('goals_against + ' . $input["home_goals"][$i]), 'matchday_count' => DB::raw('matchday_count + 1'), 'points' => DB::raw('points + ' . $awayPoints)]);
             } else {
                 Table::insert(['club_id' => $input['away_id'][$i], 'goals' => DB::raw('goals + ' . $input["away_goals"][$i]), 'goals_against' => DB::raw('goals_against + ' . $input["home_goals"][$i]), 'matchday_count' => DB::raw('matchday_count + 1'), 'points' => DB::raw('points + ' . $awayPoints), 'league_id' => $input['league'], 'season' => $input['season']]);
             }
         }
     }
     return redirect('spiele');
 }
Beispiel #4
0
 public function finishWork($table)
 {
     $item = Table::find($table);
     $item->active = 0;
     $item->save();
     $ques = Que::where('table_id', $table)->get();
     $guests = [];
     foreach ($ques as $que) {
         $item->current_que = $item->current_que - 1;
         $currentTable = Table::where('branche_id', $item->branche_id)->where('active', 1)->limit(1)->orderBy('current_que')->orderBy('id')->first();
         $currentTable->current_que = $currentTable->current_que + 1;
         $currentTable->guests_count = $currentTable->guests_count + 1;
         $currentTable->save();
         $que->table_id = $currentTable->id;
         $que->save();
     }
     return redirect()->back();
 }
 public function search()
 {
     $name = Request::input('name');
     return View('users.search')->with('tables', Table::where('name', 'like', '%' . $name . '%')->paginate(7));
 }
 public function list_for_devis($devis_id)
 {
     $devis = Devis::find($devis_id);
     $table = Table::where('devis_id', $devis_id)->orderBy('updated_at', 'desc')->paginate(50);
     return view('admin.table.index', compact('devis', 'table'));
 }
 public function constructRouterVue2(Table $from_Table, $chaine_cumul = '', $chaine_edit = '', $chaine_list = '', $loop = 0)
 {
     //var_dump($loop);
     $chaine_cumul .= $from_Table->name . '/';
     $pieces = explode('/', $chaine_cumul);
     end($pieces);
     $avantDernier = prev($pieces);
     $table = Table::where('name', $avantDernier)->first();
     $id = ':id_' . $table->variable;
     echo "<h2>__________________________________________________________________________________________________________________________________________________________</h2>";
     var_dump($pieces);
     $chaine_edit = '';
     foreach ($pieces as $piece) {
         $table = Table::where('name', $piece)->first();
         if ($table) {
             $chaine_edit .= $piece . '/:id_' . $table->variable . '/';
         }
     }
     $chaine_list .= rtrim($chaine_edit, '/:id_' . $from_Table->variable . '/');
     //put thre keys
     // $chaine_edit.=$this->primary().'/';
     // $chaine_cumul.=$this->name.'/';
     foreach ($from_Table->hasHasManyRelationList() as $relation) {
         // var_dump($relation);
         $toTable = Table::find($relation['to_model_id']);
         //var_dump(rtrim($chaine_edit, '/'));
         //var_dump(rtrim($chaine_list, '/'));
         $this->constructRouterVue2($toTable, $chaine_cumul, $chaine_edit, $chaine_list, $loop++);
     }
     //var_dump(rtrim($chaine_edit, '/'));
     $chaine_list = rtrim($chaine_list, '/');
     $chaine_edit = rtrim($chaine_edit, '/');
     var_dump('------------chaine_edit');
     var_dump($chaine_edit);
     /*
             $toComponentTable = strrchr($chaine_list, '/');
             if (!$toComponentTable) {
                 echo ">>";
                 $toComponentTable=$chaine_list;
             }*/
     $toComponentTable = $avantDernier;
     echo "--->";
     var_dump($toComponentTable);
     echo "<---";
     echo "<h2>EDITION</h2>";
     /*
      **  EDITION
      */
     $table = Table::where('name', $toComponentTable)->first();
     if ($table) {
         $edit = new CreateEditComponent($this->devis, $table);
         $path = $edit->getPath();
     } else {
         echo "la table {$toComponentTable} non trouvee !!";
         $toComponentTable = $chaine_list;
         $table = Table::where('name', $toComponentTable)->first();
         $path = '';
         if ($table) {
             $list = new CreateEditComponent($this->devis, $table);
             $path = $list->getPath();
         }
     }
     $edition = $this->RouterVue[] = ['type' => 'edit', 'route' => $chaine_edit, 'to_component' => $toComponentTable, 'path' => $path];
     //var_dump($this->RouterVue);
     var_dump($edition);
     /*
      **  list
      */
     echo "<h2>LIST</h2>";
     //var_dump($chaine_list);
     $route = '';
     var_dump('edition[route]');
     var_dump($edition['route']);
     //$route = strrchr($edition['route'], '/')
     // $route=substr($edition['route'], 0, strpos($edition['route'], '/'));//remove everything after /
     $route = substr($edition['route'], 0, strrpos($edition['route'], '/'));
     //remove everything after /
     //  var_dump('route for list');
     //  var_dump($route);
     $table = Table::where('name', $toComponentTable)->first();
     if ($table) {
         $edit = new CreateListComponent($this->devis, $table);
         $path = $edit->getPath();
     } else {
         $toComponentTable = $chaine_list;
         $table = Table::where('name', $toComponentTable)->first();
         $path;
         if ($table) {
             $list = new CreateListComponent($this->devis, $table);
             $path = $list->getPath();
         }
     }
     $list = $this->RouterVue[] = ['type' => 'list', 'route' => $route, 'to_component' => $toComponentTable, 'path' => $path];
     var_dump($list);
     /*
      **  create
      */
     echo "<h2>FORM</h2>";
     $route = $list['route'] . '/create';
     //remove everything after /
     $table = Table::where('name', $toComponentTable)->first();
     if ($table) {
         $edit = new CreateFormComponent($this->devis, $table);
         $path = $edit->getPath();
     } else {
         $toComponentTable = $chaine_list;
         $table = Table::where('name', $toComponentTable)->first();
         $path = '';
         if ($table) {
             $list = new CreateFormComponent($this->devis, $table);
             $path = $list->getPath();
         }
     }
     $form = $this->RouterVue[] = ['type' => 'create', 'route' => $route, 'to_component' => $toComponentTable, 'path' => $path];
     var_dump($form);
     /*
             ** Ajout des component specifiques
     
             if ($this->getSpecialVueComponentList($this->table)){
                 foreach ($this->getSpecialVueComponentList($this->table) as $specialView) {
                     $componentName = $this->table->vueComponentName('', $specialView);
                     //$path = $this->table->vueComponentRelativePathTo($this->table, $specialView);
                     $tag = '<'.$this->table->VueTag('',$specialView ).' :'.$this->table->variable.'="object"></'.$this->table->VueTag('',$specialView ).'>';
     
                     //var_dump($editList);
                     //si la fin du liste == model concerné dans le specialcompo
                     //dd($edition['to_component'], $this->table->name);
     
     
     
     
                     // $file =  strrchr($path, '/');
                     // $file = trim($file, '/');
                     // $file = trim($file, '.php');
     
                     //on les execute pour trouver les namespaces
                     $vueClass =  '\Organit\bootstrapping\Vue\MiddlesepcialComponentViews\\'.$this->devis->app_name.'\\'.$specialView;
                 //     dd(
                 //     (new $vueClass($this->devis,$table))->CoreSpecialCompo()->model()
                 //     ,
                 //     (new \Organit\bootstrapping\Vue\MiddlesepcialComponentViews\Middle\BankAccount($this->devis,$table))->CoreSpecialCompo()->model()
                 // );
     
                 //recuperer la liste des table qui on des speciaux compo
                 $list_qq=[];
                 foreach ($this->devis->tables as $_table ) {
                     if ($_table == 'vehicles') {
                         dd($this->getSpecialVueComponentList($_table));
                         # code...
                     }
                     $list_qq[] =  $this->getSpecialVueComponentList($_table);
                 }
                 //dd($list_qq);
                 var_dump('********');
                 var_dump($vueClass);
                     $model = (new $vueClass($this->devis,$this->table))->CoreSpecialCompo()->model();
                     $related_table = Table::where('model', $model)->first();
                     if ($related_table) {
                         //if ($edition['to_component'] == $related_table->name) {
                             $this->RouterVue[]=[
                                 'type' => 'secial',
                                 'route' => $edition['route'].'/get_'.$componentName,
                                 'to_component' => $componentName,
                                 'path' => $edition['path'].'/'.$componentName,
                                 'tag' => $tag
                             ];
                         //}
                         # code...
                     }
     
     
     
     
                 }
             }
     */
     // var_dump(rtrim($chaine_cumul, '/'));
     // if (isset($toTable)) {
     //Table::constructRouterVue($table, $chaine_cumul,  $chaine_edit, $chaine_list, $loop++);
     # code...
     // }
 }