Ejemplo n.º 1
0
 public function run()
 {
     $admin_access_permission = Permission::create(['name' => 'access-admin', 'display_name' => 'Access admin', 'description' => 'Access admin pages']);
     $owner_role = Role::create(array('name' => 'owner', 'display_name' => 'Owner', 'description' => 'Owner of the system', 'status' => Role::STATUS_HIDDEN));
     $owner_role->attachPermission($admin_access_permission);
     $admin_role = Role::create(array('name' => 'admin', 'display_name' => 'Administrator', 'description' => 'Manage operation of the system and important modules'));
     $admin_role->attachPermission($admin_access_permission);
     $tester_role = Role::create(array('name' => 'tester', 'display_name' => 'Tester', 'description' => 'Tester of the system', 'status' => Role::STATUS_HIDDEN));
     $tester_role->attachPermission($admin_access_permission);
     $user_role = Role::create(array('name' => 'user', 'display_name' => 'User', 'description' => 'Normal user'));
     // TODO: Add 1 administrator
     $owner = User::create(array('display_name' => 'Owner', 'name' => 'owner', 'email' => '*****@*****.**', 'password' => bcrypt(')^KM$bB-W7:Z@8eG'), 'url_avatar' => appDefaultUserProfilePicture(), 'url_avatar_thumb' => appDefaultUserProfilePicture(), 'activation_code' => str_random(32), 'active' => true));
     $owner->attachRole($owner_role);
     $admin = User::create(array('display_name' => 'Administrator', 'name' => 'admin', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'url_avatar' => appDefaultUserProfilePicture(), 'url_avatar_thumb' => appDefaultUserProfilePicture(), 'activation_code' => str_random(32), 'active' => true));
     $admin->attachRoles([$admin_role, $owner_role]);
     $tester = User::create(array('display_name' => 'Tester', 'name' => 'tester', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'url_avatar' => appDefaultUserProfilePicture(), 'url_avatar_thumb' => appDefaultUserProfilePicture(), 'activation_code' => str_random(32), 'active' => true));
     $tester->attachRole($tester_role);
     $locales = ['en', 'vi'];
     $category = new Category();
     $category->type = Category::LINK;
     $data = ['en' => ['name' => 'Example link category', 'slug' => 'example-link-category', 'description' => 'Example link category'], 'vi' => ['name' => 'Chuyên mục liên kết ví dụ', 'slug' => 'chuyen-muc-lien-ket-vi-du', 'description' => 'Chuyên mục liên kết ví dụ']];
     foreach ($locales as $locale) {
         $transData = $data[$locale];
         $trans = $category->translateOrNew($locale);
         $trans->name = $transData['name'];
         $trans->slug = $transData['slug'];
         $trans->description = $transData['description'];
     }
     $category->save();
     $data = [['en' => ['name' => 'Author on Facebook', 'url' => 'https://www.facebook.com/linhntaim', 'description' => 'Author on Facebook'], 'vi' => ['name' => 'Hồ sơ tác giả trên Facebook', 'url' => 'https://www.facebook.com/linhntaim', 'description' => 'Hồ sơ tác giả trên Facebook']], ['en' => ['name' => 'Author\'s Personal Site', 'url' => 'http://linhntaim.com', 'description' => 'Author\'s Personal Site'], 'vi' => ['name' => 'Trang cá nhân của tác giả', 'url' => 'http://linhntaim.com', 'description' => 'Trang cá nhân của tác giả']], ['en' => ['name' => 'Katniss on Github', 'url' => 'https://github.com/linhntaim/katniss', 'description' => 'Katniss on Github'], 'vi' => ['name' => 'Katniss trên Github', 'url' => 'https://github.com/linhntaim/katniss', 'description' => 'Katniss trên Github']]];
     foreach ($data as $item) {
         $link = new Link();
         foreach ($locales as $locale) {
             $transData = $item[$locale];
             $trans = $link->translateOrNew($locale);
             $trans->name = $transData['name'];
             $trans->description = $transData['description'];
             $trans->url = $transData['url'];
         }
         $link->save();
         $link->categories()->attach($category->id);
     }
     ThemeWidget::create(['widget_name' => 'base_links', 'theme_name' => '', 'placeholder' => 'default_placeholder', 'constructing_data' => '{"category_id":"' . $category->id . '","en":{"name":"Widget named Base Links","description":""},"vi":{"name":"Ví dụ về Công cụ hiển thị Base Links","description":""}}', 'active' => true, 'order' => 1]);
     ThemeWidget::create(['widget_name' => 'extra_html', 'theme_name' => '', 'placeholder' => 'default_placeholder', 'constructing_data' => '{"en":{"name":"Widget named Extra HTML","description":"","content":"<p><strong>Lorem Ipsum<\\/strong><sup>&reg;<\\/sup> is simply dummy text of the <em>printing and typesetting industry<\\/em>. <span style=\\"color:#FFFF00\\"><span style=\\"background-color:#000000\\">Lorem Ipsum<\\/span><\\/span> has been the industry&#39;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like <span style=\\"font-size:16px\\">Aldus PageMaker <\\/span>including versions of <em><strong><u>Lorem Ipsum<\\/u><\\/strong><\\/em>. <img alt=\\"smiley\\" src=\\"http:\\/\\/katniss.linhntaim.com\\/assets\\/libraries\\/ckeditor-4.5.5\\/plugins\\/smiley\\/images\\/regular_smile.png\\" style=\\"height:23px; width:23px\\" title=\\"smiley\\"><\\/p>\\r\\n\\r\\n<p><img alt=\\"\\" src=\\"http:\\/\\/katniss.linhntaim.com\\/files\\/user_2\\/katniss.png\\" style=\\"height:120px; width:120px\\"><\\/p>\\r\\n"},"vi":{"name":"V\\u00ed d\\u1ee5 v\\u1ec1 C\\u00f4ng c\\u1ee5 hi\\u1ec3n th\\u1ecb Extra HTML","description":"","content":"<p><strong>Lorem Ipsum<\\/strong><sup>&reg;<\\/sup> is simply dummy text of the <em>printing and typesetting industry<\\/em>. <span style=\\"color:#FFFF00\\"><span style=\\"background-color:#000000\\">Lorem Ipsum<\\/span><\\/span> has been the industry&#39;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like <span style=\\"font-size:16px\\">Aldus PageMaker <\\/span>including versions of <em><strong><u>Lorem Ipsum<\\/u><\\/strong><\\/em>. <img alt=\\"smiley\\" src=\\"http:\\/\\/katniss.linhntaim.com\\/assets\\/libraries\\/ckeditor-4.5.5\\/plugins\\/smiley\\/images\\/regular_smile.png\\" style=\\"height:23px; width:23px\\" title=\\"smiley\\"><\\/p>\\r\\n\\r\\n<p><img alt=\\"\\" src=\\"http:\\/\\/katniss.linhntaim.com\\/files\\/user_2\\/katniss.png\\" style=\\"height:120px; width:120px\\"><\\/p>\\r\\n"}}', 'active' => true, 'order' => 2]);
 }
Ejemplo n.º 2
0
 public function updateOrder(Request $request, $id)
 {
     $category = Category::findOrFail($id);
     $validator = Validator::make($request->all(), ['link_ids' => 'required|array|exists:links,id']);
     if ($validator->fails()) {
         return response()->json(['success' => false, 'msg' => $validator->errors()->all()]);
     }
     $link_ids = $request->input('link_ids');
     $order = 0;
     $category_links = $category->links();
     foreach ($link_ids as $link_id) {
         ++$order;
         $category_links->updateExistingPivot($link_id, ['order' => $order]);
     }
     return response()->json(['success' => true]);
 }
Ejemplo n.º 3
0
 public function viewHomeParams()
 {
     $links = empty($this->category_id) ? collect([]) : Category::findOrFail($this->category_id)->links;
     return array_merge(parent::viewHomeParams(), ['name' => $this->name, 'links' => $links]);
 }
Ejemplo n.º 4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit(Request $request, $id)
 {
     $link = Link::findOrFail($id);
     $this->theme->title([trans('pages.admin_links_title'), trans('form.action_edit')]);
     $this->theme->description(trans('pages.admin_links_desc'));
     return $this->_edit(['link' => $link, 'link_categories' => $link->categories, 'categories' => Category::where('type', Category::LINK)->get()]);
 }
Ejemplo n.º 5
0
 public function layoutSort(Request $request, $id)
 {
     $category = Category::where('type', Category::LINK)->where('id', $id)->firstOrFail();
     $this->theme->title([trans('pages.admin_link_categories_title'), trans('form.action_sort')]);
     $this->theme->description(trans('pages.admin_link_categories_desc'));
     return $this->_any('sort', ['category' => $category, 'links' => $category->links]);
 }