Example #1
0
 function viewOaca($id = 0)
 {
     $oaca = RegistroOaca::find($id);
     $content_introduction = ElementsOaca::contentOaca(ElementsOaca::INTRODUCTION, $id);
     $collectChild_introduction = ElementsOaca::arrayContentChild(ElementsOaca::INTRODUCTION, $id);
     $content_develop = ElementsOaca::searchElementsDevelop($id);
     $content_close = ElementsOaca::searchElementsClose($id);
     //dd( $collectChild_introduction);
     return view('oaca.pages.oaca', ['oaca' => $oaca, 'collectChild_introduction' => $collectChild_introduction, "pattern_array" => ElementsOaca::DEVELOP_ARRAY, "content_develop" => $content_develop[2], "pattern_array" => ElementsOaca::CLOSE_ARRAY, "content_close" => $content_close[2]]);
 }
 function postClose(Request $request)
 {
     //dd($request->input('data'));
     $Arr = explode(",", $request->input('elementos-delete'));
     $collection = ElementsOaca::destroy($Arr);
     $position = 0;
     if ($request->input('data')) {
         foreach ($request->input('data') as $key => $value) {
             if ($value['type'] != 'image') {
                 $element = ElementsOaca::firstOrNew(['id' => $value['id']]);
                 $element->type_element = $value['type'];
                 $element->content = $value['content'];
                 $element->moment = ElementsOaca::CLOSE;
                 $element->pattern_pedagogicaltechno = $value['pattern'];
                 $element->position_order = $position;
                 $element->contentchild = $value['contentchild'];
                 $element->register_id = $request->input('register_id');
                 $element->save();
                 $position++;
             } else {
                 if ($value['type'] == 'image') {
                     $element = ElementsOaca::firstOrNew(['id' => $value['id']]);
                     $element->type_element = $value['type'];
                     $element->moment = ElementsOaca::CLOSE;
                     $element->pattern_pedagogicaltechno = $value['pattern'];
                     $element->position_order = $position;
                     $element->contentchild = $value['contentchild'];
                     $element->register_id = $request->input('register_id');
                     $filebackground = $request->file($value['content']);
                     if ($filebackground != null) {
                         $namebackground = $filebackground->getClientOriginalName();
                         $public_path = public_path();
                         $url = $public_path . '/assets/imgs/contents-img/close';
                         $filebackground->move($url, $namebackground);
                         $element->content = '/assets/imgs/contents-img/close/' . $namebackground;
                         $element->save();
                         $position++;
                     } else {
                         $element->save();
                         $position++;
                     }
                 }
             }
         }
     }
     return redirect('/admin');
 }