Inheritance: extends Illuminate\Database\Eloquent\Model
コード例 #1
1
ファイル: IncrementBlogViews.php プロジェクト: otsaan/e-blog
 /**
  * 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);
 }
コード例 #2
0
 public function index(Slider $slider, Blog $blog)
 {
     $this->data['slider'] = $slider->getActiveSliders();
     $this->data['blogsContent'] = $blog->getFewBlogs(2);
     $this->data['content'] = json_decode(file_get_contents(storage_path() . '/administrator_settings/main.json'));
     return view('pages.main', $this->data);
 }
コード例 #3
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct(Blog $Blog)
 {
     $this->middleware('auth', ['except' => ['index', 'show']]);
     $this->middleware('admin', ['only' => ['create', 'edit', 'update', 'destroy']]);
     $this->Blog = $Blog;
     $this->Blogs = $Blog->blogs();
 }
コード例 #4
0
 public function update(Blog $blog, BlogRequest $request)
 {
     $blog->update($request->all());
     $this->syncTags($blog, $request->input('tag_list'));
     flash()->overlay('Your blog has been updated!', 'Good Job');
     return redirect('blogs');
 }
コード例 #5
0
 public function update($data)
 {
     $post = strip_tags($data['post']);
     $blog = Blog::find($data['blogID']);
     $blog->post = $post;
     $blog->save();
 }
コード例 #6
0
ファイル: BlogController.php プロジェクト: pastebimas/blog
 /**
  * Add the point to  
  * 
  * 
  */
 public function getShare($id, $social)
 {
     $url = '';
     $post = \App\Blog::find($id);
     if ($post == NULL) {
         App::abort(404);
     }
     // add social point if it is not robot
     if (!isset($_SERVER['HTTP_USER_AGENT']) && !preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
         $post->socialPoint++;
         $post->save();
     }
     switch ($social) {
         case 'twitter':
             $url = 'https://twitter.com/home?status=';
             $url .= $post['title'] . ' ' . $post->getUrl();
             break;
         case 'facebook':
             $url = 'https://www.facebook.com/sharer/sharer.php?u=';
             $url .= $post->getUrl();
             break;
         case 'googlePlus':
             $url = 'https://plus.google.com/share?url=';
             $url .= $post->getUrl();
             break;
         case 'linkedIn':
             $url = 'https://www.linkedin.com/shareArticle?mini=true&';
             $url .= 'url=' . $post->getUrl() . '&title=' . $post['title'] . '&summary=&source=';
             break;
     }
     return \Redirect::to($url);
 }
コード例 #7
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('blog', function ($slug) {
         return Blog::where('slug', $slug)->first();
     });
 }
コード例 #8
0
 public function run()
 {
     \App\Blog::create(array('writer_id' => 1, 'title' => 'hey baba', 'content' => 'very bad'));
     \App\Blog::create(array('writer_id' => 1, 'title' => 'hey manika', 'content' => 'very bad'));
     \App\Blog::create(array('writer_id' => 2, 'title' => 'nil wakka', 'content' => 'very good'));
     \App\Blog::create(array('writer_id' => 3, 'title' => 'thor', 'content' => 'very but'));
     \App\Blog::create(array('writer_id' => 4, 'title' => 'hey nre', 'content' => 'very sin'));
 }
コード例 #9
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('blogs', function ($id) {
         return \App\Blog::published()->findOrFail($id);
     });
 }
コード例 #10
0
 public function run()
 {
     $faker = Factory::create();
     Blog::truncate();
     foreach (range(1, 100) as $index) {
         Blog::create(['title' => $faker->sentence(2), 'excerpt' => $faker->sentence(3), 'content' => $faker->sentence(20), 'published_at' => $faker->dateTime(), 'user_id' => 1]);
     }
 }
コード例 #11
0
ファイル: FrontendController.php プロジェクト: andy-am/itam
 public function search()
 {
     $input = Input::all();
     if (isset($input['query'])) {
         $query = $input['query'];
         $data = Blog::select('title')->where('title', 'LIKE', '%' . $query . '%')->get()->toArray();
         return response()->json(["data" => $data]);
     }
 }
コード例 #12
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = User::lists('id')->toArray();
     $categorys = Category::where('type_id', '=', Category::TYPE_BLOG)->lists('id')->toArray();
     $faker = Faker\Factory::create();
     foreach (range(1, 28) as $index) {
         Blog::create(['title' => 'blog ' . $faker->sentence(), 'body' => implode('<br>', $faker->paragraphs(16)), 'user_id' => $faker->randomElement($users), 'type_id' => Blog::TYPE_BLOG, 'category_id' => $faker->randomElement($categorys), 'last_comment_user_id' => $faker->randomElement($users)]);
     }
 }
コード例 #13
0
ファイル: BlogController.php プロジェクト: graftphp/graft
 public function update()
 {
     $b = Blog::find($_POST['id']);
     $b->title = $_POST['title'];
     $b->date = $_POST['date'];
     $b->content = $_POST['content'];
     $b->save();
     Functions::redirect('/');
 }
コード例 #14
0
ファイル: Active.php プロジェクト: otsaan/e-blog
 /**
  * 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);
 }
コード例 #15
0
ファイル: Exists.php プロジェクト: otsaan/e-blog
 /**
  * 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);
 }
コード例 #16
0
 public function getDashboardData()
 {
     $blogCount = Blog::all()->count();
     $tagCount = Tag::all()->count();
     $contactCount = ContactMails::where('messageStatus', 0)->count();
     $totalCount = ContactMails::all()->count();
     $totalHit = UserLog::all()->count();
     return 1;
     #$Response = array('success' => '1', 'blogCount' => $blogCount, 'tagCount' => $tagCount , 'contactCount' => $contactCount, 'totalCount' => 'totalHit' => $totalHit);
 }
コード例 #17
0
ファイル: HomeController.php プロジェクト: majid-n/laravel
 public function index()
 {
     $blogs = Blog::with('user')->orderBy('created_at', 'desc')->paginate(15);
     $downloads = Download::with('user')->orderBy('created_at', 'desc')->paginate(15);
     $samples = Sample::with('user')->orderBy('created_at', 'desc')->paginate(15);
     $lastusers = User::orderBy('created_at', 'desc')->paginate(15);
     $sample_cats = Samplecategories::all();
     $guests = Online::guests()->count();
     return view('index', compact('blogs', 'downloads', 'samples', 'sample_cats', 'lastusers', 'guests'));
 }
コード例 #18
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(UserValidationRequest $request)
 {
     // extra validation specific to registering Users
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     Auth::login($this->create($request->except('blog_name')));
     $newBlog = Blog::create(['name' => $request->blog_name, 'user_id' => Auth::user()->id]);
     $newBlog->save();
     return redirect($this->redirectPath());
 }
コード例 #19
0
 public function index($id)
 {
     //$articles=DB::table('blog_articles')->where('blog_id','=',$id)->paginate(15);
     if (Auth::user()->tag == 'teacher') {
         $user = User::find($id);
         $blog = $user->blog;
         if (empty($blog)) {
             # code...
             $blog = new Blog();
             $blog->name = $user->name;
             $blog->user_id = $user->id;
             $blog->save();
         }
         $articles = $blog->articles()->get();
         $user = User::find($id);
         $data = array('articles' => $articles, 'user' => $user, 'blog' => $blog);
         //return $data;
         return view('blog.admin.index')->with('data', $data);
     } else {
         return '该博客暂时不对实验室外部人员开放';
     }
 }
コード例 #20
0
ファイル: BlogController.php プロジェクト: bausano/Ebchod
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if (isset($request->title) && isset($request->blog)) {
         $img = time() . "." . \Input::file('img')->getClientOriginalExtension();
         \Input::file('img')->move('uploads', $img);
         $data = ['name' => $request->title, 'seo' => str_slug($request->title), 'content' => $request->blog, 'user_id' => \Auth::user()->id, 'img' => $img];
         if (isset($request->sections_ids)) {
             $data['sections'] = $request->sections_ids;
         }
         App\Blog::insert($data);
     }
     return \Redirect::to('admin');
 }
コード例 #21
0
 public function edit(EditBlogRequest $request, $id)
 {
     $blog = Blog::find($id);
     $params = $request->all();
     if ($request->hasFile('picture')) {
         $params['picture'] = $request->file('picture')->getClientOriginalName();
         \File::delete('images/blog/' . $params['old_picture_name']);
         $request->file('picture')->move('images/blog', $params['picture']);
     }
     $blog->fill($params);
     $blog->save();
     return redirect()->back()->with('success_message', 'Datos actualizados');
 }
コード例 #22
0
 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]);
 }
コード例 #23
0
ファイル: SearchController.php プロジェクト: majid-n/laravel
 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'));
 }
コード例 #24
0
ファイル: BlogController.php プロジェクト: otsaan/e-blog
 public function report(Request $request, $id)
 {
     $blog = Blog::find($id);
     Message::create(['content' => $request->note, 'to_user_id' => $blog->user->id, 'from_user_id' => $request->from, 'read' => false]);
     $user = $blog->user;
     $from = User::find($request->from);
     if ($user->notify_email) {
         Mail::send('email.report', ['username' => $blog->username, 'from' => $from, 'note' => $request->note], function ($message) use($user) {
             $message->to($user['email'], $user['username'])->subject('Blog signalé');
         });
     }
     $url = route('blog', $blog->username);
     $note = 'Blog ' . $blog->id . ' signalé: (<a href="' . $url . '">' . $url . '</a>)<br>';
     $note .= $request->note;
     Message::create(['content' => $note, 'to_user_id' => User::where('role', '=', 'admin')->first()->id, 'from_user_id' => $request->from, 'read' => false]);
     return redirect()->back();
 }
コード例 #25
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('blog', function ($id) {
         return Blog::published()->findOrFail($id);
     });
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('projects', function ($id) {
         return \App\Project::findOrFail($id);
     });
     $router->bind('pages', function ($name) {
         return \App\Page::where('location', $name)->firstOrFail();
     });
 }
コード例 #26
0
 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'));
 }
コード例 #27
0
ファイル: Controller.php プロジェクト: andy-am/itam
 public function __construct()
 {
     $A_authors = Author::all();
     view()->share('A_authors', $A_authors);
     $A_projects = Project::all();
     view()->share('A_projects', $A_projects);
     $A_blogs = Blog::all();
     view()->share('A_blogs', $A_blogs);
     $A_newsletters = Newsletter::all();
     view()->share('A_newsletters', $A_newsletters);
     $A_quotations = Quotation::all();
     view()->share('A_quotations', $A_quotations);
     $quotations = Quotation::all();
     //dump($quotations);
     $quotations = count($quotations) > 1 ? $quotations->random(2) : $quotations;
     view()->share('quotations', $quotations);
 }
コード例 #28
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // create $countryList
     $countriesCount = DB::table('countries')->count();
     $numRows = 6;
     $numInColmn = $countriesCount / $numRows;
     $countryList = [];
     for ($i = 0; $i < $numRows; $i++) {
         $countries[$i] = Country::whereBetween('id', array($i * $numInColmn, ($i + 1) * $numInColmn))->get();
         $iplus = $i + 1;
         $countryList["countries{$iplus}"] = $countries[$i];
     }
     // create $featuredBlogs
     $featuredBlogs = Blog::featured()->recent()->get();
     // create $recentPosts
     $recentPosts = BlogPost::recent()->get();
     return view('pages.index', compact('countryList', 'numRows', 'featuredBlogs', 'recentPosts'));
 }
コード例 #29
0
 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'));
 }
コード例 #30
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id = null)
 {
     if ($id == null) {
         //$locations_with_devices = Blogs::with('Employees')->get();
         //return $locations_with_devices;
         /* echo '<pre>';
            print_r($locations_with_devices);
            echo '</pre>';*/
         /*$a = Blog::orderBy('id', 'desc')->get();
           $b = Employee::find($a->user_id);
           echo '<pre>';
           print_r($b);
           echo '</pre>';*/
         //return View('blogs.list');
         //return Blog::orderBy('id', 'desc')->get();
         $blogs = Blog::All();
         return View::make('blogs.list')->with('blogs', $blogs);
     } else {
         return $this->show($id);
     }
 }