Skip to content

Apply fixes from StyleCI #48

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

Open
wants to merge 1 commit into
base: release/0.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Http/Controllers/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Soda\Blog\Http\Controllers;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Soda\Blog\Models\Tag;
use Soda\Blog\Models\Post;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -225,11 +224,12 @@ protected function getPostSettings(Post $post)
return $settings;
}

protected function blogPostQuery() {
protected function blogPostQuery()
{
$sortConfig = (array) config('soda.blog.default_sort');
$posts = $this->currentBlog->posts()->whereNotNull('id')->withoutGlobalScope('position')->withoutGlobalScope('published');

if(array_keys($sortConfig)[0] == 'published_at') {
if (array_keys($sortConfig)[0] == 'published_at') {
$posts->orderByRaw('published_at IS NULL DESC');
}

Expand Down
4 changes: 2 additions & 2 deletions src/InstantArticles/AbstractInstantArticleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Soda\Blog\InstantArticles;

use Soda\Blog\Models\Post;
use Facebook\InstantArticles\Elements\InstantArticle;
use Facebook\InstantArticles\Transformer\Transformer;
use Soda\Blog\Models\Post;

abstract class AbstractInstantArticleParser implements InstantArticleParser
{
Expand Down Expand Up @@ -44,7 +44,7 @@ protected function applyRules(Transformer $transformer)
} catch (\ReflectionException $e) {
$factoryMethod =
new \ReflectionMethod(
'Facebook\\InstantArticles\\Transformer\\Rules\\' . $class,
'Facebook\\InstantArticles\\Transformer\\Rules\\'.$class,
'createFrom'
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/InstantArticles/DefaultParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Soda\Blog\InstantArticles;

use Soda\Blog\Models\Post;
use Facebook\InstantArticles\Elements\Time;
use Facebook\InstantArticles\Elements\Author;
use Facebook\InstantArticles\Elements\Footer;
use Facebook\InstantArticles\Elements\Header;
use Facebook\InstantArticles\Elements\InstantArticle;
use Facebook\InstantArticles\Elements\Time;
use Facebook\InstantArticles\Transformer\Transformer;
use Soda\Blog\Models\Post;

class DefaultParser extends AbstractInstantArticleParser implements InstantArticleParser
{
Expand Down Expand Up @@ -41,7 +41,7 @@ protected function applyContent(InstantArticle $article, Post $post)

protected function footer(Post $post)
{
return Footer::create()->withCredits('© ' . app('soda')->getApplication()->name);
return Footer::create()->withCredits('© '.app('soda')->getApplication()->name);
}

protected function transformContent(InstantArticle $article, $html)
Expand Down
17 changes: 8 additions & 9 deletions src/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
namespace Soda\Blog\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use Soda\Cms\Database\Models\User;
use Illuminate\Support\Facades\URL;
use Soda\Blog\Models\Traits\BlogSortableTrait;
use Illuminate\Database\Eloquent\Model;
use Soda\Blog\Models\Traits\BoundToBlog;
use Soda\Cms\Database\Models\DynamicContent;
use Soda\Cms\Database\Models\Traits\Draftable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Soda\Cms\Database\Models\Traits\HasMedia;
use Soda\Blog\Models\Traits\BlogSortableTrait;
use Soda\Cms\Database\Models\Traits\Draftable;
use Soda\Cms\Database\Models\Traits\Sluggable;
use Soda\Cms\Database\Models\User;

class Post extends Model
{
Expand Down Expand Up @@ -179,7 +179,7 @@ public function getPreviousPost()
{
$query = static::where('id', '!=', $this->id);

foreach ((array)config('soda.blog.default_sort') as $sortableField => $direction) {
foreach ((array) config('soda.blog.default_sort') as $sortableField => $direction) {
$query->where($sortableField, strtolower($direction) == 'DESC' ? '<=' : '>=', $this->$sortableField);

break;
Expand All @@ -192,7 +192,7 @@ public function getNextPost()
{
$query = static::reverseOrder()->where('id', '!=', $this->id);

foreach ((array)config('soda.blog.default_sort') as $sortableField => $direction) {
foreach ((array) config('soda.blog.default_sort') as $sortableField => $direction) {
$query->where($sortableField, strtolower($direction) == 'DESC' ? '>=' : '<=', $this->$sortableField);

break;
Expand All @@ -212,7 +212,6 @@ public function getExcerpt($numCharacters = null, $type = 'words', $stripTags =

// Return custom excerpt if auto excerpt is disabled
if ($currentBlog->getSetting('auto_excerpt') !== null && $currentBlog->getSetting('auto_excerpt') == 0) {

return isset($this->attributes['excerpt']) ? $this->attributes['excerpt'] : '';
}

Expand Down Expand Up @@ -266,7 +265,7 @@ public function getPropertiesAttribute()
$propertiesModel->exists = true;

foreach ($this->settings as $setting) {
if (!$setting->relationLoaded('field')) {
if (! $setting->relationLoaded('field')) {
$this->settings->load('field');
}

Expand Down
5 changes: 2 additions & 3 deletions src/SluggedBlogPostMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

namespace Soda\Blog;

use Illuminate\Contracts\Routing\Registrar as RouterContract;
use Illuminate\Http\Request;
use Soda\Blog\InstantArticles\DefaultParser;
use Soda\Blog\InstantArticles\InstantArticleParser;
use Soda\Cms\Http\RequestMatcher\Matchers\MatcherInterface;
use Illuminate\Contracts\Routing\Registrar as RouterContract;

class SluggedBlogPostMatcher implements MatcherInterface
{
Expand All @@ -27,7 +26,7 @@ public function matches($slug)
{
$blogSlug = trim($this->currentBlog->getSetting('slug'), '/');
$postSlug = trim($slug, '/');
$postSlug = '/' . trim(substr($postSlug, strlen($blogSlug), strlen($postSlug)), '/');
$postSlug = '/'.trim(substr($postSlug, strlen($blogSlug), strlen($postSlug)), '/');

if (ends_with($postSlug, static::INSTANT_ARTICLE_SLUG)) {
$this->isInstantArticle = true;
Expand Down
4 changes: 2 additions & 2 deletions src/SodaBlogServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Soda\Blog;

use Soda\Blog\InstantArticles\DefaultParser;
use Soda\Blog\InstantArticles\InstantArticleParser;
use Soda\Blog\Models\Blog;
use Soda\Blog\Models\Post;
use Soda\Blog\Console\Create;
use Soda\Blog\Console\Install;
use Illuminate\Support\Facades\Route;
use Soda\Blog\InstantArticles\DefaultParser;
use Soda\Cms\Support\Facades\SodaFacade as Soda;
use Soda\Blog\InstantArticles\InstantArticleParser;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class SodaBlogServiceProvider extends ServiceProvider
Expand Down