Commit 9f34fce0 by Francisco Salazar

archivo de configuracion

parent 312e39db
...@@ -37,6 +37,12 @@ public function entries() ...@@ -37,6 +37,12 @@ public function entries()
php artisan vendor:publish --provider="Onestartup\Blog\BlogServiceProvider" php artisan vendor:publish --provider="Onestartup\Blog\BlogServiceProvider"
``` ```
- run command for publish config file
```php
php artisan vendor:publish --tag=config
```
- run serv - run serv
```php ```php
......
...@@ -32,6 +32,9 @@ class BlogServiceProvider extends ServiceProvider ...@@ -32,6 +32,9 @@ class BlogServiceProvider extends ServiceProvider
__DIR__.'/views/post' => resource_path('views/vendor/onestartup/blog'), __DIR__.'/views/post' => resource_path('views/vendor/onestartup/blog'),
]); ]);
$this->publishes([
__DIR__.'/config/blog.php' => config_path('blog.php'),
], 'config');
} }
...@@ -48,6 +51,6 @@ class BlogServiceProvider extends ServiceProvider ...@@ -48,6 +51,6 @@ class BlogServiceProvider extends ServiceProvider
$this->app->make('Onestartup\Blog\Controller\TagCatalogController'); $this->app->make('Onestartup\Blog\Controller\TagCatalogController');
$this->app->make('Onestartup\Blog\Controller\CommentPostController'); $this->app->make('Onestartup\Blog\Controller\CommentPostController');
$this->app->make('Onestartup\Blog\Controller\BlogController'); $this->app->make('Onestartup\Blog\Controller\BlogController');
$this->mergeConfigFrom( __DIR__.'/config/blog.php', 'blog');
} }
} }
<?php
return [
"blog-index" => [
"post-pagination" => 15,
"otros" => 3
],
"blog-show" => [
"otros" => 3
],
];
\ No newline at end of file
...@@ -17,19 +17,19 @@ class BlogController extends Controller ...@@ -17,19 +17,19 @@ class BlogController extends Controller
{ {
if(isset($request->category)){ if(isset($request->category)){
$category = Category::where('slug', $request->category)->first(); $category = Category::where('slug', $request->category)->first();
$posts = $category->entries()->where('status',1)->orderBy('publication_date', 'asc')->paginate(15); $posts = $category->entries()->where('status',1)->orderBy('publication_date', 'asc')->paginate(config("blog.blog-index.post-pagination"));
} elseif (isset($request->tags)) { } elseif (isset($request->tags)) {
$tags = explode(",", $request->tags); $tags = explode(",", $request->tags);
$posts = Entry::where('status',1)->where(function ($query) use($tags) { $posts = Entry::where('status',1)->where(function ($query) use($tags) {
for ($i = 0; $i < count($tags); $i++){ for ($i = 0; $i < count($tags); $i++){
$query->orwhere('tags', 'like', '%' . $tags[$i] .'%'); $query->orwhere('tags', 'like', '%' . $tags[$i] .'%');
} }
})->orderBy('publication_date', 'asc')->paginate(15); })->orderBy('publication_date', 'asc')->paginate(config("blog.blog-index.post-pagination"));
} else { } else {
$posts = Entry::where('status',1)->orderBy('publication_date', 'asc')->paginate(3); $posts = Entry::where('status',1)->orderBy('publication_date', 'asc')->paginate(config("blog.blog-index.post-pagination"));
} }
$otros = Entry::where('status',1)->inRandomOrder()->take(3)->get(); $otros = Entry::where('status',1)->inRandomOrder()->take(config("blog.blog-index.otros"))->get();
$categories = Category::where('active', 1)->get(); $categories = Category::where('active', 1)->get();
return view('blog-public::list') return view('blog-public::list')
...@@ -49,7 +49,7 @@ class BlogController extends Controller ...@@ -49,7 +49,7 @@ class BlogController extends Controller
for ($i = 0; $i < count($tags); $i++){ for ($i = 0; $i < count($tags); $i++){
$query->orwhere('tags', 'like', '%' . $tags[$i] .'%'); $query->orwhere('tags', 'like', '%' . $tags[$i] .'%');
} }
})->take(3)->get(); })->where("id", "<>", $post->id)->inRandomOrder()->take(config("blog.blog-show.otros"))->get();
$categories = Category::all(); $categories = Category::all();
...@@ -61,8 +61,6 @@ class BlogController extends Controller ...@@ -61,8 +61,6 @@ class BlogController extends Controller
return redirect('no_existe'); return redirect('no_existe');
} }
return view('blog-public::single') return view('blog-public::single')
->with('post', $post) ->with('post', $post)
->with('categories', $categories) ->with('categories', $categories)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment