Пример #1
0
 public function run()
 {
     DB::table('navigations')->delete();
     $title1 = new I18n();
     $title1->i18n_type_id = I18nType::where('name', '=', 'title')->first()->id;
     $title1->save();
     $title1->translate('fr', 'Accueil');
     $title1->translate('en', 'Home');
     $title7 = new I18n();
     $title7->i18n_type_id = I18nType::where('name', '=', 'title')->first()->id;
     $title7->save();
     $title7->translate('fr', 'Contact');
     $title7->translate('en', 'Contact');
     DB::table('navigations')->insert(array(array('i18n_title' => $title1->id, 'parent_id' => 0, 'order' => 1, 'navigable_id' => 1, 'navigable_type' => 'Page'), array('i18n_title' => $title7->id, 'parent_id' => 0, 'order' => 2, 'navigable_id' => 2, 'navigable_type' => 'Page')));
     //Admin navigation group
     DB::table('admin_navigation_groups')->delete();
     $adminNav1 = I18n::add(array('fr' => 'Racine', 'en' => 'Root'), 'key', 'admin.admin_navigation_root');
     $adminNav2 = I18n::add(array('fr' => 'Gestion des contenus', 'en' => 'Content managment'), 'key', 'admin.admin_navigation_content');
     $adminNav3 = I18n::add(array('fr' => 'Gestion des utilisateurs', 'en' => 'User managment'), 'key', 'admin.admin_navigation_user');
     $adminNav4 = I18n::add(array('fr' => 'Traduction', 'en' => 'Translation'), 'key', 'admin.admin_navigation_translation');
     $adminNav5 = I18n::add(array('fr' => 'Option', 'en' => 'Option'), 'key', 'admin.admin_navigation_option');
     DB::table('admin_navigation_groups')->insert(array(array('i18n_title' => $adminNav1, 'parent_id' => 0, 'order' => 0, 'deletable' => false), array('i18n_title' => $adminNav2, 'parent_id' => 0, 'order' => 1, 'deletable' => true), array('i18n_title' => $adminNav3, 'parent_id' => 0, 'order' => 2, 'deletable' => true), array('i18n_title' => $adminNav4, 'parent_id' => 0, 'order' => 3, 'deletable' => true), array('i18n_title' => $adminNav5, 'parent_id' => 0, 'order' => 4, 'deletable' => true)));
 }
Пример #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array();
     $tag_name_datas = array();
     foreach (Input::except('_token') as $k => $v) {
         if (strpos($k, 'tag_name_') !== false) {
             $rules[$k] = Config::get('validator.admin.tag.name');
             $tag_name_datas[mb_substr($k, strlen('tag_name_'), strlen($k) - strpos($k, 'tag_name_'))] = $v;
         }
     }
     //return var_dump($tag_name_datas);
     // Validate the inputs
     $validator = Validator::make(Input::except('_token'), $rules);
     if ($validator->passes()) {
         //create i18n key
         $i18n_name = new I18n();
         $i18n_name->i18n_type_id = I18nType::where('name', '=', 'tag')->first()->id;
         $i18n_name->save();
         foreach ($tag_name_datas as $locale => $value) {
             if (!$i18n_name->translate($locale, $value)) {
                 return Redirect::to('admin/tag')->with('error', Lang::get('admin.tag_save_fail'));
             }
         }
         $tag = new Tag();
         $tag->i18n_name = $i18n_name->id;
         // Was the blog post created?
         if ($tag->save()) {
             //track user
             parent::track('create', 'Tag', $tag->id);
             return Redirect::to('admin/tag')->with('success', Lang::get('admin.tag_save_success'));
         }
         // Redirect to the blog post create tag
         return Redirect::to('admin/tag/create')->with('error', Lang::get('admin.tag_save_fail'));
     }
     // Form validation failed
     return Redirect::to('admin/tag/create')->withInput()->withErrors($validator);
 }
 /**
  * Store all type of menu, parent, child internal or external link and button
  *
  * @return Response
  */
 public function store()
 {
     $rules = array();
     $navigation_title_datas = array();
     foreach (Input::except('_token') as $k => $v) {
         if (strpos($k, 'navigation_title_') !== false) {
             $rules[$k] = Config::get('validator.admin.navigation_title.title');
             $navigation_title_datas[mb_substr($k, strlen('navigation_title_'), strlen($k) - strpos($k, 'navigation_title_'))] = $v;
         }
     }
     $rules = array_merge($rules, Config::get('validator.admin.navigation'));
     //return var_dump($rules);
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         //create i18n key
         $i18n_title = new I18n();
         $i18n_title->i18n_type_id = I18nType::where('name', '=', 'navigation')->first()->id;
         $i18n_title->save();
         foreach ($navigation_title_datas as $locale => $value) {
             if (!$i18n_title->translate($locale, $value)) {
                 return Redirect::to('admin/navigation')->with('error', Lang::get('admin.navigation_save_fail'));
             }
         }
         $navigation = new Nav();
         $navigation->i18n_title = $i18n_title->id;
         if (Input::has('parent_id')) {
             $navigation->parent_id = Input::get('parent_id');
         } else {
             $navigation->parent_id = 0;
         }
         //There case : external link, internal link and link container (button)
         if (Input::has('url_external')) {
             //create a link and put the id in the navigable_id :)
             $nav_link = new NavLink();
             $nav_link->url = Input::get('url_external');
             $nav_link->save();
             $navigation->navigable_id = $nav_link->id;
             $navigation->navigable_type = 'NavLink';
         }
         if (Input::has('model_resource_id')) {
             $result_explode = explode('|', Input::get('model_resource_id'));
             $navigation->navigable_id = $result_explode[1];
             $navigation->navigable_type = $result_explode[0];
         }
         if (!Input::has('url_external') && !Input::has('model_resource_id')) {
             $nav_link = new NavLink();
             $nav_link->url = '#';
             $nav_link->save();
             $navigation->navigable_id = $nav_link->id;
             $navigation->navigable_type = 'NavLink';
         }
         if (Input::has('order')) {
             $navigation->order = Input::get('order');
         } else {
             $navigation->order = Nav::max() + 1;
         }
         // Was the blog post created?
         if ($navigation->save()) {
             //track user
             parent::track('create', 'Navigation', $navigation->id);
             Cache::forget('DB_Nav');
             // Redirect to the new blog post menu
             return Redirect::to('admin/navigation')->with('success', 'Le menu à bien été ajouté !');
         }
         // Redirect to the blog post create menu
         return Redirect::to('admin/navigation/create')->with('error', 'Le menu n\'a pas pu être enregistrée...');
     }
     // Form validation failed
     return Redirect::to('admin/navigation/create')->withInput()->withErrors($validator);
 }