Exemple #1
1
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $username = str_replace('/', '', $request->getRequestUri());
     $blog = Blog::where('username', '=', $username)->first();
     if ($blog) {
         $blog->views++;
         $blog->save();
     }
     return $next($request);
 }
 /**
  * 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('blog', function ($slug) {
         return Blog::where('slug', $slug)->first();
     });
 }
Exemple #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $username = explode('/', $request->path())[0];
     // check that {username} exists
     if ($username != 'admin' && Blog::where('username', '=', $username)->count() == 0) {
         return redirect()->route('404');
     }
     return $next($request);
 }
Exemple #4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $username = explode('/', $request->path())[0];
     $blog = Blog::where('username', '=', $username)->first();
     if ($blog && $blog->status != 'active') {
         return redirect()->route('disabled', $username);
     }
     return $next($request);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($title)
 {
     //
     // $blog = Blog::find($id);
     // dd($blog); die
     $blog = Blog::where('slug', $title)->first();
     if (!$blog) {
         abort(404);
     }
     return view('blog.single')->with('data', $blog);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (\Auth::guest()) {
         $blog = \App\Blog::where('status', 'publish')->latest()->paginate(5);
         $photo = \App\Photo::get();
     } else {
         return redirect('/');
         $blog = \App\Blog::latest()->paginate(5);
         $photo = \App\Photo::get();
     }
     return view('blog.list', compact('blog'))->with('photo', $photo);
 }
Exemple #7
0
 /**
  * @return \Illuminate\View\View
  */
 public function getIndexFrontend()
 {
     //featured blog
     $featured = Blog::where('featured', 1)->first();
     // Grab all the blogs
     $blogs = Blog::latest()->where('id', '!=', $featured->id)->simplePaginate(5);
     $blogs->setPath('blog');
     $tags = $this->tags;
     //return $tags;
     $latest = Blog::latest()->take(5)->get();
     // Show the page
     return View('blog.index', compact('featured', 'blogs', 'tags', 'latest'));
 }
 public function pencarian(Request $req)
 {
     $TabAktif = $req->TabAktif;
     $LinkPage = "pencarian?cari={$req->cari}&TabAktif={$TabAktif}&page=";
     // Blog
     $Blogs = Blog::where('judul', 'like', '%' . $req->cari . '%')->orderBy('id', 'desc')->paginate($this->Perpage);
     // Page
     $Pages = Page::where('judul', 'like', '%' . $req->cari . '%')->orderBy('id', 'desc')->paginate($this->Perpage);
     $PrevPage = $Pages->currentPage() > 1 ? $LinkPage . ($Pages->currentPage() - 1) : "#";
     $NextPage = $Pages->hasMorePages() > 0 ? $LinkPage . ($Pages->currentPage() + 1) : "#";
     $PrevBlog = $Blogs->currentPage() > 1 ? $LinkPage . ($Blogs->currentPage() - 1) : "#";
     $NextBlog = $Blogs->hasMorePages() > 0 ? $LinkPage . ($Blogs->currentPage() + 1) : "#";
     return view('admin.beranda.search', ['Blogs' => $Blogs, 'Pages' => $Pages, 'Cari' => $req->cari, 'TabAktif' => $TabAktif, 'PrevBlog' => $PrevBlog, 'NextBlog' => $NextBlog, 'PrevPage' => $PrevPage, 'NextPage' => $NextPage]);
 }
Exemple #9
0
 public function search($type, $query)
 {
     $result = "";
     if ($type == "samples") {
         $result = Sample::where('title', 'LIKE', "%{$query}%")->paginate(24);
     } elseif ($type == "blogs") {
         $result = Blog::where('title', 'LIKE', "%{$query}%")->paginate(24);
     } elseif ($type == "downloads") {
         $result = download::where('title', 'LIKE', "%{$query}%")->paginate(24);
     } else {
         return redirect()->route('home')->with('error', 'مشکل در جستجو دوباره تلاش کنید');
     }
     $type = str_singular($type);
     return view('search', compact('result', 'type'));
 }
 public function read(Request $request)
 {
     $page = 'blog';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $pages = Pages::where('slug', '=', $page)->first();
     $date = $request->year . '-' . $request->month . '-' . $request->day;
     $blog = Blog::where('date', '=', $date)->where('slug', '=', $request->slug)->first();
     array_set($blog, "date", Carbon::createFromFormat('Y-m-d', $blog->date));
     //INCREMENT
     Blog::find($blog->blogId)->increment('read');
     //MORE BLOG
     $moreBlog = Blog::orderBy('date', 'desc')->where('blogId', '!=', $blog->blogId)->limit(2)->addSelect('title')->addSelect('date')->addSelect('slug')->get();
     foreach ($moreBlog as $item) {
         array_set($item, "date", Carbon::createFromFormat('Y-m-d', $item->date));
     }
     return view('website.blog.intern')->with(compact('page', 'pages', 'websiteSettings', 'blog', 'moreBlog'));
 }
 public function post(Request $request)
 {
     $page = 'busca';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $pages = Pages::where('slug', '=', $page)->first();
     if (!$request->inputSearch) {
         return redirect('/')->with('message', 'Informe algum conteúdo para a busca.');
     }
     $blog = Blog::where('title', 'LIKE', '%' . $request->inputSearch . '%')->orWhere('subtitle', 'LIKE', '%' . $request->inputSearch . '%')->orderBy('date', 'desc')->get();
     foreach ($blog as $item) {
         array_set($item, "date", Carbon::createFromFormat('Y-m-d', $item->date));
     }
     $newsAndReleases = NewsAndReleases::where('title', 'LIKE', '%' . $request->inputSearch . '%')->orWhere('subtitle', 'LIKE', '%' . $request->inputSearch . '%')->orderBy('date', 'desc')->get();
     foreach ($newsAndReleases as $item) {
         array_set($item, "date", Carbon::createFromFormat('Y-m-d', $item->date));
     }
     return view('website.search.index')->with(compact('page', 'pages', 'websiteSettings', 'request', 'blog', 'newsAndReleases'));
 }
 public function getArticle($slug)
 {
     $data = [];
     if (Auth::check()) {
         $data['dashboardAuth'] = 1;
     } else {
         $data['auth'] = 1;
     }
     $data['general'] = 1;
     $articles = Blog::where('slug', $slug)->select('users.first_name', 'users.id as user_id', 'title', 'slug', 'intro', 'body', 'image', 'blog.created_at')->leftJoin('users', 'users.id', ' =', 'user_id')->take(1)->get()->toArray();
     if (!count($articles)) {
         return view('errors.404');
     }
     foreach ($articles as &$value) {
         $value['month'] = MyDate::getMonth($value['created_at']);
         $value['day'] = MyDate::getDay($value['created_at']);
         $value['spent_days'] = MyDate::getSpentDays($value['created_at']);
     }
     $data['article'] = $articles[0];
     $data['single'] = 1;
     return view('frontend.blog.single', $data);
 }
Exemple #13
0
 public function loadblogs(Request $request)
 {
     if ($request->ajax()) {
         $sort = $request->input('sort');
         $blogs = Blog::where('del', 0)->with('user')->orderBy($sort, 'desc')->paginate(15);
         $content = '';
         foreach ($blogs as $blog) {
             $slug = slug($blog['title']);
             $userName = $blog->user->first_name . " " . $blog->user->last_name;
             $img = $blog->user->img;
             $content .= '
 			<div class="userBlogList">
                 <i class="fa fa-clock-o" data-toggle="tooltip" data-placement="top" title="' . fdate($blog->created_at) . '"></i>
                 <i class="fa fa-eye" data-toggle="tooltip" data-placement="top" title="' . $blog->view_ . '"></i>
                 <i class="fa fa-heart" data-toggle="tooltip" data-placement="top" title="' . $blog->vote . '"></i>
 			</div>
 			<P> 
 			<img  class="img-circle img-small" alt="' . $userName . '" src="' . asset("images/profiles/thumb/thumb_" . $img) . '"  /> 
 			<a href="' . route('blog.show', ['blog' => $blog->id, 'str' => $slug]) . '"> ' . $blog->title . '  </a>
 			</P>';
         }
         return response()->json($content);
     }
 }
 public function updateBlog()
 {
     $blogData = Input::except('blogTags', '_token');
     if ($blogData['blogDate'] == '') {
         unset($blogData['blogDate']);
     }
     $validation = Validator::make($blogData, Blog::$updateBlog);
     if ($validation->passes()) {
         $blog = BlogTag::where('blog_id', Input::get('id'))->delete();
         $blog = Blog::where('id', Input::get('id'))->update($blogData);
         $blogTags = Input::get('blogTags');
         foreach ($blogTags as $blogTagsData) {
             BlogTag::create(['blog_id' => Input::get('id'), 'user_id' => '1', 'tag_id' => $blogTagsData]);
         }
         $Response = array('success' => '1', 'blogId' => Input::get('id'));
     } else {
         $Response = array('success' => '0', 'err' => $validation->messages());
     }
     return $Response;
 }
Exemple #15
0
 public function blogView($url)
 {
     //
     $blog = Blog::where('url', $url)->first();
     return view('pages.blog-view', ['blog' => $blog]);
 }
 /**
  * Display a listing of the blog.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return view('blog.index', ['blogs' => Blog::where("is_published", true)->paginate(7)]);
 }
Exemple #17
0
 public function disabled($username)
 {
     $blog = Blog::where('username', '=', $username)->first();
     return view('errors.disabled')->with(['username' => $username, 'blog' => $blog]);
 }
Exemple #18
0
 public static function blog($type, $data)
 {
     if ($type == 'id') {
         return Blog::findOrFail($data);
     }
     return Blog::where($type, $data)->first();
 }
 public function BlogLainnya($take)
 {
     $bloglainnya = Blog::where('draft', 0)->where('arsip', 0)->orderBy('id', 'desc')->take($take)->get();
     return $bloglainnya;
 }
@endsection

@section('content')
<div class="container">
	<div class="row" style="margin-top: 20px;">
		<div class="col-sm-offset-1 div col-sm-6">
			<p class="ltittle">个人空间列表</p>
		</div>
	</div>
	<div class="row">
	<?php 
use App\Blog;
?>
	@foreach($users as $user)
	<?php 
$blog = Blog::where('user_id', $user->id)->first();
?>
	<div class="col-sm-4">

		<div class="media">
  <div class="media-left">
    <a href="{{ URL('blog/'.$user->id.'/home') }}">
    @if($blog->icon == null)
		<img src="{{asset('assets/images/website/default_user.jpg')}}" alt="" class="media-object">
		@else
		<img src="{{asset('assets/images/icon/'.$blog->icon)}}" alt="" class="media-object">
		@endif
    </a>
  </div>
  <div class="media-body">
    <h4 class="media-heading">{{$blog->name}}</h4>
 public function blogData($url)
 {
     $blogData = Blog::where('url', $url)->first();
     return view('blog')->with('data', $blogData);
 }
Exemple #22
0
 /**
  * Display the specified resource.
  *
  * GET /{id}
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $blog = Blog::where('id', $id)->paginate(10);
     return view('pages.index')->with('blog', $blog);
 }
Exemple #23
0
<?php

Route::bind("blog", function ($value, $route) {
    return \App\Blog::where("slug", $value)->first();
});
Route::bind("blog_category", function ($value, $route) {
    return \App\BlogCategory::where("slug", $value)->first();
});
Route::get("/", ["as" => "home.index", "uses" => "HomeController@index"]);
Route::get("blog", ["as" => "blog.index", "uses" => "BlogController@index"]);
Route::get("blog/{blog}", ["as" => "blog.show", "uses" => "BlogController@show"]);
Route::get("blog/category/{blog_category}", ["as" => "blog.category.show", "uses" => "BlogCategoryController@show"]);
Route::group(["middleware" => ["guest"]], function () {
    Route::get("login", ["as" => "user.login", "uses" => "UserController@login"]);
    Route::post("login", ["as" => "user.login", "uses" => "UserController@doLogin"]);
});
Route::group(["middleware" => ["auth"], "namespace" => "Backend", "prefix" => config("app.backend")], function () {
    Route::get("blog", ["as" => "backend.blog.index", "uses" => "BlogController@index"]);
    Route::get("blog/create", ["as" => "backend.blog.create", "uses" => "BlogController@create"]);
    Route::post("blog", ["as" => "backend.blog.store", "uses" => "BlogController@store"]);
    Route::get("blog/{blog}/edit", ["as" => "backend.blog.edit", "uses" => "BlogController@edit"]);
    Route::put("blog/{blog}", ["as" => "backend.blog.update", "uses" => "BlogController@update"]);
    Route::get("blog/{blog}/delete", ["as" => "backend.blog.destroy", "uses" => "BlogController@destroy"]);
    Route::get("blog/category", ["as" => "backend.blog.category.index", "uses" => "BlogCategoryController@index"]);
    Route::get("blog/category/create", ["as" => "backend.blog.category.create", "uses" => "BlogCategoryController@create"]);
    Route::post("blog/category", ["as" => "backend.blog.category.store", "uses" => "BlogCategoryController@store"]);
    Route::get("blog/category/{blog_category}/edit", ["as" => "backend.blog.category.edit", "uses" => "BlogCategoryController@edit"]);
    Route::put("blog/category/{blog_category}", ["as" => "backend.blog.category.update", "uses" => "BlogCategoryController@update"]);
    Route::get("blog/category/{blog_category}/delete", ["as" => "backend.blog.category.destroy", "uses" => "BlogCategoryController@destroy"]);
    Route::get("logout", ["as" => "user.logout", "uses" => "UserController@logout"]);
});
    public function searchBlog()
    {
        $searchQuery = Input::get('searchQuery');
        $blogResult = Blog::where('blogTitle', 'LIKE', '%' . $searchQuery . '%')->get();
        if (count($blogResult) == 0) {
            $resultData = '<div class="alert alert-danger" role="alert"><strong>Searching for the Posts contains the word "' . $searchQuery . '" ( ' . count($blogResult) . ' Results )</div>';
        } else {
            $resultData = '<div class="alert alert-success" role="alert"><strong>Searching for the Posts contains the word "' . $searchQuery . '" ( ' . count($blogResult) . ' Result )</div>';
        }
        foreach ($blogResult as $key) {
            $resultData .= '<h2><a href="' . asset("/") . 'blog/' . $key["blogUrl"] . '" style="text-decoration:none">' . $key["blogTitle"] . '</a></h2>
				<p class="lead">by <a style="text-decoration:none">Sulthan Allaudeen</a></p>
				<p style="float:right"><span class="glyphicon glyphicon-time"></span> Posted on 01 Sep 2015 </p>';
        }
        return $resultData;
    }
Exemple #25
0
 public function index()
 {
     $blogs = Blog::where('state', '=', 1)->orderBy('created_at', 'desc')->paginate(5);
     return view('blog')->with(compact('blogs'));
 }
Exemple #26
0
 public function index()
 {
     $blogs = Blog::where('del', 0)->where('user_id', Sentinel::getUser()->id)->orderBy('created_at', 'desc')->paginate(config('app.paginat_min'));
     return view('user.blogs.index', compact('blogs'));
 }
Exemple #27
0
 public function users(User $user)
 {
     $blogs = Blog::where('user_id', $user->id)->where('del', 0)->paginate(config('app.paginat_min'));
     return view('user.blogs', compact('blogs', 'user'));
 }
Exemple #28
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id, $seo)
 {
     App\Product::where('id', $id)->increment('views');
     $post = App\Blog::where('id', $id)->get()->first();
     return \View::make('post', ['title' => 'Blog', 'favorites' => App\Product::orderBy('views', 'desc')->limit(6)->get(), 'post' => $post, 'relevant' => App\Product::whereIn('section_id', explode(';', $post->sections))->orderBy('views', 'desc')->limit(6)->get()]);
 }
Exemple #29
0
Route::get('/', 'PagesController@home');
Route::get('/about/{name}', 'PagesController@about');
Route::get('/contact', 'PagesController@contact');
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
use App\User;
use App\Blog;
Route::get('/user', function () {
    dd(User::all());
});
Route::get('/blog/create', function () {
    $blog = new Blog();
    $blog->name = "First Blog";
    $blog->description = "First Blog";
    $blog->save();
});
Route::get('/blog', function () {
    return Blog::all();
});
Route::get('/blog/{id}', function ($id) {
    $blog = Blog::find($id);
    return $blog;
});
Route::get('/blog/t/{tit}', function ($tit) {
    $blog = Blog::where('name', "=", $tit)->get();
    return $blog;
});
Exemple #30
0
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
Route::get('/', function () {
    $blog = \App\Blog::where('status', 'publish')->Take(3)->latest()->get();
    return view('home', compact('blog'));
});
// Registration routes...
Route::get('Shop', function () {
    return view('shop');
});
// Registration routes...
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
Route::resource('blog', 'BlogController');
Route::resource('photos', 'PhotosController');
// Blog routes...
Route::post('blog/{id}/photo', 'BlogController@addPhoto');
// Adding Photos to post
Route::post('blog/create', 'BlogController@store');