Ejemplo n.º 1
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('categories', function ($categories) {
         return Category::where('permalink', $categories)->first();
     });
     $router->bind('posts', function ($posts) {
         return Post::where('permalink', $posts)->first();
     });
 }
Ejemplo n.º 2
0
 /**
  * Muestra un formulario para actualizar una post existente.
  *
  * @param  string $post
  * @return Response
  */
 public function edit(Post $post)
 {
     if (Gate::denies('edit-post', $post)) {
         session()->flash('message', 'No tienes permiso para editar posts');
         return redirect()->route('admin.posts.index');
     }
     $variables = ['post' => $post, 'tags' => Tag::lists('name', 'id'), 'categories' => Category::lists('name', 'id')];
     return view('admin/posts/edit', $variables);
 }
Ejemplo n.º 3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  string $permalink
  * @return \Illuminate\Http\Response
  */
 public function edit($permalink)
 {
     $variables = ['categories' => Category::lists('name', 'id'), 'tags' => Tag::lists('name', 'id'), 'notice' => Notice::where('permalink', $permalink)->first()];
     return view('admin/news/edit', $variables);
 }
Ejemplo n.º 4
0
 /**
  * Show the form for editing the specified landing page.
  *
  * @param  string $permalink
  * @return \Illuminate\Http\Response
  */
 public function edit($permalink)
 {
     $categories = Category::lists('name', 'id');
     $page = Landing::where('permalink', $permalink)->first();
     return view('admin/landing/edit', compact('page', 'categories'));
 }
Ejemplo n.º 5
0
 /**
  * Elimina la categoría de la base de datos
  *
  * @param  \Soundcore\Category $category
  * @return Response
  */
 public function destroy(Category $category)
 {
     $category->delete();
     session()->flash('message', 'Se eliminó la categoría "' . $category->name . '" satisfactoriamente');
     session()->flash('message_important', true);
     return redirect()->route('admin.categories.index');
 }
Ejemplo n.º 6
0
<?php

use Soundcore\Models\Category;
use Soundcore\Models\Landing;
use Soundcore\Models\User;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(User::class, function ($faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => str_random(10), 'remember_token' => str_random(10)];
});
$factory->define(Landing::class, function ($faker) {
    $title = $faker->sentence(6);
    $permalink = str_replace(' ', '-', str_replace('.', '', strtolower($title)));
    $category_count = Category::count();
    return ['category_id' => $faker->numberBetween(1, $category_count), 'title' => $title, 'permalink' => $permalink, 'description' => $faker->paragraph(2), 'content' => $faker->text(300), 'active' => $faker->numberBetween(0, 1), 'image_alt' => $title, 'meta_title' => $title, 'meta_description' => $faker->paragraph(2), 'meta_robots' => $faker->randomElement(['index, follow', 'noindex, nofollow'])];
});
Ejemplo n.º 7
0
 /**
  * Display tag news
  * 
  * @param  Request $request
  * @param  string  $permalink
  * @return Response
  */
 public function tagNews(Request $request, $permalink)
 {
     $variables = ['page' => $this->permalinkTrait($permalink), 'categories' => Category::NewsCategories(), 'tags' => Tag::NewsTags(), 'tag' => Tag::publicTagNews($permalink)];
     return view('public/tag/news', $variables);
 }