New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Facebook Like, Share #2

Merged
merged 7 commits into from Dec 22, 2017
Merged
Diff settings

Always

Just for now

Copy path View file
@@ -10,3 +10,4 @@ Homestead.yaml
npm-debug.log
yarn-error.log
.env
composer.lock
Copy path View file
@@ -0,0 +1,45 @@
<?php
namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class Blog
* @package App
*/
class Blog extends Model
{
/**
* @var string
*/
protected $table = 'blogs';
/**
* @var array
*/
protected $dates = ['published_at'];
/**
* @var array
*/
protected $fillable = ['title', 'slug', 'excerpt', 'content', 'published_at'];
/**
* @param $query
* @return mixed
*/
public function scopePublished($query)
{
return $query->where('published_at', '<=', Carbon::now());
}
/**
* @param $date
*/
public function setPublishedAtAttribute($date)
{
$this->attributes['published_at'] = Carbon::parse($date);
}
}
@@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers;
use App\Blog;
use Illuminate\Http\Request;
/**
* Class BlogController
* @package App\Http\Controllers
*/
class BlogController extends Controller
{
/**
* @var int
*/
protected $paginate = 10;
/**
* @param Request $request
*/
public function __construct(Request $request)
{
$this->request = $request;
}
public function index()
{
$blogs = Blog::published()->paginate(
$this->paginate
);
return view('blog.index', [
'blogs' => $blogs,
'title' => 'Blogs',
'open_graph' => [
'title' => 'Blogs',
'image' => asset('assets/logo.jpeg'),
'url' => $this->request->url(),
'description' => 'A blog website to share tutorials and tips !',
'keywords' => 'A Laravel Blog, Tips, Tutorials',
],
]);
}
/**
* @param $slug
*/
public function view($slug)
{
$blog = Blog::published()
->where('slug', $slug)
->firstOrFail();
return view('blog.view', [
'blog' => $blog,
'open_graph' => [
'title' => $blog->title,
'image' => asset('assets/preview.jpeg'),
'url' => $this->request->url(),
'description' => $blog->excerpt,
],
]);
}
}
Copy path View file
@@ -6,11 +6,12 @@
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"dts/ebay-sdk-php": "^12.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"omnipay/paypal": "^2.6",
"sudiptpa/guid": "^1.0",
"sudiptpa/paypal-ipn": "^2.0",
"symfony/event-dispatcher": "^2.8"
},
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.