예제 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $cats = \App\Models\Category::lists('id');
     foreach (\App\Models\User::withTrashed()->get() as $user) {
         $user->categories = $cats;
         $user->save();
     }
 }
예제 #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $tags = Tag::lists("name", "id");
     $article = Article::with("tags")->find($id);
     $categories = Category::lists("name", "id");
     //        dd($article->tags->lists("id"));
     return view("dashboard.articles.edit", compact("article", "categories", "tags"));
 }
예제 #3
0
 public function run()
 {
     $faker = Faker::create();
     $cates = Category::lists('id')->toArray();
     for ($i = 1; $i <= 50; $i++) {
         Post::create(['title' => $faker->sentence(), 'summary' => $faker->paragraph(), 'category_id' => $faker->randomElement($cates), 'body' => $faker->text(10000), 'origin' => '', 'comment_count' => rand(0, 10), 'view_count' => rand(0, 200), 'favorite_count' => rand(0, 100), 'published' => rand(0, 1), 'slug' => 'post-' . $i]);
     }
 }
예제 #4
0
 public function adverts_update($id)
 {
     $advert = Advertisement::find($id);
     if (!$advert) {
         abort(404);
     }
     $categories_select = Category::lists('uk_title', 'id');
     return view('admin.advert_update')->with('advert', $advert)->with('categories_select', $categories_select);
 }
 public function edit($id)
 {
     $categories = Category::lists('title', 'id');
     $product = Product::find($id);
     $selected = [];
     foreach ($product->categories()->get() as $item) {
         array_push($selected, $item->id);
     }
     return view('admin.products.edit')->with('categories', $categories)->with('selected', $selected)->with('product', $product);
 }
 public function edit($id)
 {
     $book = Book::find($id);
     //if (auth()->user()->can('manageBook', $book)) {
     //if (Gate::denies('manageBook', $book)) {
     if (Gate::denies('manageBook', $book)) {
         abort(403, 'voce não é o dono desse livro');
     }
     $categories = Category::lists('name', 'id');
     return view('admin.books.edit', compact('book', 'categories'));
 }
예제 #7
0
 public function sell()
 {
     $categories = Category::lists('name', 'id');
     if (Request::isMethod('post')) {
         $rules = ['name' => 'required', 'description' => 'required', 'category' => 'required', 'file1' => 'required|mimes:jpeg,bmp,png', 'file2' => 'required|mimes:jpeg,bmp,png'];
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             $messages = $validator->messages();
             return Redirect::to('piac/eladok')->withErrors($messages)->withInput();
         } else {
             $adv = new Advertisement();
             $adv->name = Input::get('name');
             $adv->description = Input::get('description');
             $adv->category_id = Input::get('category');
             $adv->visible_from = Input::get('visible_from');
             $adv->visible_until = Input::get('visible_until');
             $adv->user_id = Auth::id();
             $adv->seo_url = Helper::lake_directory(Input::get('name'));
             $adv->save();
             if (Input::hasFile('file1') && Input::hasFile('file2')) {
                 $files = [];
                 $files[] = Input::file('file1');
                 $files[] = Input::file('file2');
                 $files[] = Input::file('file3');
                 $files[] = Input::file('file4');
                 $files[] = Input::file('file5');
                 foreach ($files as $key => $file) {
                     $directory = 'USER_' . Auth::id() . '/' . $adv->id;
                     $tmpFilePath = $_SERVER['DOCUMENT_ROOT'] . '/images/advertisements/' . $directory . '/';
                     if ($file) {
                         $tmpFileName = time() . '-' . $file->getClientOriginalName();
                         $file->move($tmpFilePath, $tmpFileName);
                         $advImg = new AdvertisementImage();
                         $advImg->advertisement_id = $adv->id;
                         $advImg->url = $directory . '/' . $tmpFileName;
                         $advImg->save();
                     }
                 }
             }
             Session::flash('message', 'Köszönjük!.Egyik adminisztrátorunk engedélyezni fogja hírdetésedet a következő 30 percben.');
             return Redirect::to('/');
         }
     }
     return view('market.sell', ['categories' => $categories]);
 }
예제 #8
0
 public function update($locale, $id)
 {
     $advertisement = Advertisement::where('published', 1)->where('id', $id)->first();
     if (!$advertisement || Auth::user()->id != $advertisement->user_id) {
         abort(404);
     }
     $categoryModel = new Category();
     $categories = $categoryModel->get_order_count();
     $categories_select = Category::lists(Config::get('app.locale') . '_title', 'id');
     $validtor = JsValidator::make($this->rules);
     $title = trans('message.update') . ': ' . $advertisement->title;
     return view('site.advertisements.update')->with('categories', $categories)->with('categories_select', $categories_select)->with('validator', $validtor)->with('title', $title)->with('advertisement', $advertisement);
 }
예제 #9
0
 /**
  *
  * @return Item
  */
 public function createItem($parent = NULL)
 {
     $categoryIds = Category::lists('id')->all();
     $item = new Item(['title' => $this->faker->sentence, 'category_id' => $this->faker->randomElement($categoryIds), 'priority' => $this->faker->numberBetween(1, 5)]);
     //        if ($item->priority === 1) {
     //            $urgent = $this->faker->boolean(5);
     //            if ($urgent) {
     //                $item->urgency = 1;
     //            }
     //        }
     $item->user()->associate(User::first());
     if ($this->faker->boolean(50)) {
         $item->body = 'item body';
     }
     if (!is_null($parent)) {
         $item->parent()->associate($parent);
     }
     $item->save();
     return $item;
 }
 public function composeProductsForm()
 {
     view()->composer('site.products.fields', function ($view) {
         $view->with('categories', \App\Models\Category::lists('name', 'id'))->with('tags', \App\Models\Tag::lists('name', 'id'))->with('files', \App\Fileentry::lists('original_filename', 'id'));
     });
 }
예제 #11
0
 public function projectedit(ProjectRepository $project_repo)
 {
     $categories = Category::lists('name', 'id');
     $genres = Genre::lists('name', 'id');
     $g_countries = Country::lists('countryName', 'countryID');
     $step_value = Session::get('editfstep');
     $edit_id = Session::has('editfs_id') ? Session::get('editfs_id') : '';
     $statArr = array('' => " -- Select -- ");
     $countries = array_merge($statArr, $g_countries);
     if (isset($edit_id)) {
         $projectdet = Project::where('id', $edit_id)->first();
     } else {
         $projectdet = array();
     }
     $gountryId = $projectdet['country_id'];
     $citylist = $this->project_repo->getcitylist($gountryId);
     $datan = array();
     foreach ($citylist as $cityval) {
         $id = $cityval['cityID'];
         $name = $cityval['cityName'];
         $datan[$id] = $name;
     }
     $rewardlist = $this->project_repo->getrewarddata($edit_id);
     if ($step_value == 1) {
         return view('project.startaproject-edit', ['last_insert_id' => $edit_id, 'categories' => $categories, 'genres' => $genres, 'projectdet' => $projectdet, '_menus' => $this->menuItems, 'login_url' => $this->login_url]);
     } elseif ($step_value == 2) {
         return view('project.startaproject-step2-edit', ['last_insert_id' => $edit_id, 'countries' => $countries, 'projectdet' => $projectdet, 'citylist' => $datan, '_menus' => $this->menuItems, 'login_url' => $this->login_url]);
     } elseif ($step_value == 3) {
         $prewordstat = $this->project_repo->projectrewordd($edit_id);
         if ($prewordstat > 0) {
             $rview = 'project.startaproject-step3-edit';
         } else {
             $rview = 'project.startaproject-step3';
         }
         return view($rview, ['rewardlist' => $rewardlist, 'last_insert_id' => $edit_id, 'projectdet' => $projectdet, '_menus' => $this->menuItems, 'login_url' => $this->login_url]);
     } elseif ($step_value == 4) {
         return view('project.project.create-step4', ['last_insert_id' => $edit_id, '_menus' => $this->menuItems, 'login_url' => $this->login_url]);
     } elseif ($step_value == 5) {
         return view('project.startaproject-confirmation', ['last_insert_id' => $edit_id, 'projectdet' => $projectdet, '_menus' => $this->menuItems, 'login_url' => $this->login_url]);
     } else {
         return view('project.project.editproject', ['last_insert_id' => $edit_id, '_menus' => $this->menuItems, 'login_url' => $this->login_url]);
     }
 }
예제 #12
0
 /**
  * Create a new profile composer.
  *
  * @param  UserRepository  $categories
  * @return void
  */
 public function __construct()
 {
     $this->categories = Category::lists('name', 'id')->toArray();
 }
예제 #13
0
 /**
  * get business category list.
  *
  * TODO: SHOULD BE USED WITH VIEW COMPOSER
  *
  * @return array list of categories for combo
  */
 protected function listCategories()
 {
     return Category::lists('slug', 'id')->transform(function ($item) {
         return trans('app.business.category.' . $item);
     });
 }
 /**
  * Show the form for editing the specified employees.
  *
  * @    param  int $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $employees = $this->employeesRepository->find($id);
     $TipoDoc = \App\Models\comboType::find(1)->Options->lists('description', 'id');
     $Sexo = \App\Models\comboType::find(3)->Options->lists('description', 'id');
     $EstadoCivil = \App\Models\comboType::find(4)->Options->lists('description', 'id');
     $TipoContrato = \App\Models\comboType::find(5)->Options->lists('description', 'id');
     $Ubicacion = \App\Models\comboType::find(6)->Options->lists('description', 'id');
     $Localidades = \App\Models\comboType::join('comboOptions', 'comboTypes.id', '=', 'comboOptions.type_id')->where('comboTypes.type', 'Localidades')->lists('comboOptions.description', 'comboOptions.id')->prepend('', '');
     $turno = \App\Models\comboType::join('comboOptions', 'comboTypes.id', '=', 'comboOptions.type_id')->where('comboTypes.type', 'Turno')->lists('comboOptions.description', 'comboOptions.id')->prepend('', '');
     $ObraSocial = \App\Models\obraSocial::selectRaw('CONCAT(codigo, "-", nombre) as nombre, id')->lists('nombre', 'id')->prepend('', '');
     $Category = \App\Models\Category::lists('category', 'id')->prepend('', '');
     $Specialty = \App\Models\Specialty::where('category', '=', $employees->categoria)->get()->lists('specialty', 'id')->prepend('', '');
     $conceptos_revista = \App\Models\concepto_revista::where('id', '!=', $employees->estado)->lists('descripcion', 'id')->prepend('', '');
     $estado_revista = \App\Models\concepto_revista::find($employees->estado);
     $situacion_revista = \App\Models\EstadosRevista::with('Situacion')->DelLegajoVigente($id)->first();
     $conyugue = \App\Models\Familiar::ConyugueDe($id)->first();
     $hijos = \App\Models\Familiar::HijosDe($id)->get();
     //$estados_revista  = \App\Models\estado_revista::lists('descripcion','id');
     //$categoria  = \App\Models\Categorias::lists('categoria','id');
     //$especialidad  = \App\Models\Especialidades::lists('especialidad','id');
     if (empty($employees)) {
         Flash::error('employees not found');
         return redirect(route('employees.index'));
     }
     return view('employees.edit', compact('employees', 'TipoDoc', 'turno', 'Sexo', 'EstadoCivil', 'Ubicacion', 'TipoContrato', 'ObraSocial', 'Category', 'Specialty', 'conceptos_revista', 'estado_revista', 'situacion_revista', 'conyugue', 'hijos', 'Localidades'));
     //->with('estados_revista', $estados_revista)
     //->with('categoria', $categoria)
     //->with('especialidad', $especialidad)
 }
예제 #15
0
 public function __construct()
 {
     $this->categories = Category::lists('title', 'id');
     $this->cities = Cities::get()->toArray();
     $this->ad_types = AdType::lists('name', 'id');
 }
예제 #16
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return \Response
  */
 public function store(Request $request)
 {
     if (auth()->check()) {
         return redirect()->back()->with('info', 'Cannot register when logged in');
     }
     $validator = \Validator::make($request->all(), ['username' => 'required|unique:users|min:3|max:25|alpha_num', 'email' => 'required|email|unique:users|confirmed', 'password' => 'required|min:6|confirmed', 'g-recaptcha-response' => 'required|recaptcha']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors())->withInput($request->except(['password', 'password_confirmation']));
     }
     $activation_token = str_random(8) . md5($request->get('email')) . str_random(10);
     $user = new User();
     $user->username = $request->get('username');
     $user->email = $request->get('email');
     $user->password = $request->get('password');
     $user->activation_token = $activation_token;
     $user->disabled = 0;
     $user->verified = 0;
     $user->categories = Category::lists('id');
     if ($user->save()) {
         $data = ['username' => $user->username, 'activation_token' => $activation_token];
         // Send Mail
         \Mail::queue('emails.activation', $data, function ($message) use($user) {
             $message->to($user->email, $user->username)->subject('Welcome to w0bm. Activate your account');
         });
         return redirect('/')->with('info', 'Please activate your account to finish registration');
     } else {
         return redirect()->back()->with('error', 'Account could not be created')->withInput($request->except(['password', 'password_confirmation']));
     }
 }
예제 #17
0
 public function getEditproject(ProjectRepository $project_repo)
 {
     $users = User::lists('name', 'id');
     $categories = Category::lists('name', 'id');
     $genres = Genre::lists('name', 'id');
     $g_countries = Country::lists('countryName', 'countryID');
     $step_value = Session::get('editstep');
     $edit_id = Session::has('edit_id') ? Session::get('edit_id') : '';
     $statArr = array('' => " -- Select -- ");
     $countries = array_merge($statArr, $g_countries);
     if (isset($edit_id)) {
         $projectdet = Project::where('id', $edit_id)->first();
     } else {
         $projectdet = array();
     }
     $gountryId = $projectdet['country_id'];
     /*
     $getCitylist = $this->project_repo->getcitylist($gountryId);  
     echo "<pre>";
     print_r($getCitylist);
     exit;
      $statArr = array(
     				    0 => array(
     				        'cityID' => '',
     				        'cityName' => 'Select City'
     				    ) 
     			   );
     $result = array_merge($statArr, $citylist); 
     */
     $citylist = $this->project_repo->getcitylist($gountryId);
     $datan = array();
     foreach ($citylist as $cityval) {
         $id = $cityval['cityID'];
         $name = $cityval['cityName'];
         $datan[$id] = $name;
     }
     $rewardlist = $this->project_repo->getrewarddata($edit_id);
     $url = config('medias.url');
     $func = "edit";
     if ($step_value == 1) {
         return view('admin.project.editproject', ['func' => $func, 'url' => $url, 'last_insert_id' => $edit_id, 'categories' => $categories, 'genres' => $genres, 'users' => $users, 'projectdet' => $projectdet]);
     } elseif ($step_value == 2) {
         return view('admin.project.create-step2-edit', ['func' => $func, 'url' => $url, 'last_insert_id' => $edit_id, 'countries' => $countries, 'projectdet' => $projectdet, 'citylist' => $datan]);
     } elseif ($step_value == 3) {
         return view('admin.project.create-step3-edit', ['func' => $func, 'url' => $url, 'rewardlist' => $rewardlist, 'last_insert_id' => $edit_id, 'projectdet' => $projectdet]);
     } elseif ($step_value == 4) {
         return view('admin.project.create-step4', ['func' => $func, 'url' => $url, 'last_insert_id' => $edit_id]);
     } elseif ($step_value == 5) {
         return view('admin.project.confirmation', ['func' => $func, 'url' => $url, 'last_insert_id' => $edit_id]);
     } else {
         return view('admin.project.editproject', ['func' => $func, 'url' => $url, 'last_insert_id' => $edit_id]);
     }
 }
예제 #18
0
 /**
  * Returns page with form for adding new category
  *
  * @return View Laravel view
  */
 public function create()
 {
     $categories = Category::lists('slug', 'id');
     $categories[''] = 'No parent (root)';
     return view('admin.categories.create')->with(compact('categories'));
 }
예제 #19
0
// 用户
$factory->define(User::class, function (Generator $faker) use($dates) {
    return array_merge(['name' => $faker->unique()->name, 'email' => $faker->unique()->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)], $dates);
});
// 分类
$factory->define(Category::class, function (Generator $faker) use($dates) {
    return array_merge(['name' => $faker->unique()->word, 'slug' => $faker->word, 'desc' => $faker->paragraph], $dates);
});
// 期数
$factory->define(Issue::class, function (Generator $faker) use($dates) {
    return array_merge(['issue' => $faker->unique()->numberBetween(1, 30), 'published_at' => $faker->dateTimeThisYear], $dates);
});
// 文章
$factory->define(PublishingArticle::class, function (Generator $faker) use($dates) {
    $issues = Issue::lists('issue')->toArray();
    $categoryIds = Category::lists('id')->toArray();
    return array_merge(['issue' => $faker->randomElement($issues), 'category_id' => $faker->randomElement($categoryIds), 'title' => $faker->sentence(), 'desc' => $faker->paragraph, 'url' => $faker->url, 'presenter' => $faker->name], $dates);
});
// 投稿
$factory->define(ContributeArticle::class, function (Generator $faker) use($dates) {
    return array_merge(['title' => $faker->sentence(), 'desc' => $faker->paragraph, 'url' => $faker->url, 'presenter' => $faker->name], $dates);
});
// 文章标签
$factory->define(Tag::class, function (Generator $faker) use($dates) {
    return array_merge(['name' => $faker->unique()->word], $dates);
});
// 文章和标签之间的关联关系
$factory->define(Taggable::class, function (Generator $faker) use($dates) {
    $taggableIds = PublishingArticle::lists('id')->toArray();
    $tagIds = Tag::lists('id')->toArray();
    return ['tag_id' => $faker->randomElement($tagIds), 'taggable_id' => $faker->randomElement($taggableIds), 'taggable_type' => $faker->randomElement([PublishingArticle::class, ContributeArticle::class])];
예제 #20
0
 /**
  * Create a new profile composer.
  *
  * @param  UserRepository  $categories
  * @return void
  */
 public function __construct()
 {
     $this->categories = array('' => 'Select a Category') + Category::lists('name', 'id')->toArray();
 }
예제 #21
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function addBook($book_id = null)
 {
     $book_types = BookType::lists('book_type', 'book_type_id');
     $categories = Category::lists('category_name', 'category_id');
     if ($book_id) {
         return view('admin.partials.add_book', ['book' => Book::findOrFail($book_id), 'categories' => $categories, 'book_types' => $book_types]);
     } else {
         return view('admin.partials.add_book', ['categories' => $categories, 'book_types' => $book_types]);
     }
 }