Skip to content
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

Laravel 6.0 Shift #3

Merged
merged 7 commits into from
Oct 28, 2019
Merged
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
32 changes: 10 additions & 22 deletions app/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@

namespace App;

use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Cviebrock\EloquentSluggable\SluggableScopeHelpers;
use Carbon\Carbon;
use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Laravel\Scout\Searchable;

class Blog extends Model
{

use Sluggable, SluggableScopeHelpers, Searchable, Notifiable;

// Add the fillable fields so that they are mass-assignable on this model.
protected $fillable = ['title','series', 'feat_image', 'body', 'slug', 'user_id', 'published_at', 'tag' ];

protected $fillable = ['title', 'series', 'feat_image', 'body', 'slug', 'user_id', 'published_at', 'tag'];

/**
* Return the sluggable configuration array for this model.
Expand All @@ -27,13 +25,13 @@ public function sluggable()
{
return [
'slug' => [
'source' => 'title'
]
'source' => 'title',
],
];
}

/**
* Get the tags associated with a given blog
* Get the tags associated with a given blog.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
Expand All @@ -52,8 +50,6 @@ public function user()
return $this->belongsTo(\App\User::class);
}



/**
* Return a collection of search results.
*
Expand All @@ -62,12 +58,9 @@ public function user()
*/
public function scopeSearch($query)
{
return Blog::search($query)->get()->all();
return self::search($query)->get()->all();
}




/**
* Find the published articles in a query scope.
*
Expand All @@ -78,7 +71,6 @@ public function scopePublished($query)
$query->where('published_at', '<=', Carbon::now()->toDateTimeString());
}


/**
* Find the unpublished articles in a query scope.
*
Expand All @@ -101,7 +93,6 @@ public function scopeTrending($query, $take = 3)
return $query->orderBy('reads', 'desc')->take($take)->get();
}


/**
* Returns the latest published blog post.
*
Expand All @@ -122,8 +113,6 @@ public function setPublishedAtAttribute($date)
$this->attributes['published_at'] = Carbon::createFromFormat('Y-m-d', $date);
}



/*
* Return the published attribute and convert to
* a UK format.
Expand Down Expand Up @@ -160,9 +149,8 @@ public function getUpdatedAtAttribute($date)
return Carbon::parse($date)->format('d-m-Y');
}


/**
* Accessor
* Accessor.
*
* Get the taglist attribute id and return it to the form.
*
Expand All @@ -183,7 +171,7 @@ public function getBodyHtmlAttribute($value)
}

/**
* Specify a Slack webhook to send notifications to
* Specify a Slack webhook to send notifications to.
* @return mixed
* @internal param $value
*/
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
Commands\GenerateSitemap::class
Commands\GenerateSitemap::class,
];

/**
Expand All @@ -36,7 +36,6 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{

require base_path('routes/console.php');
}
}
4 changes: 2 additions & 2 deletions app/Events/BlogWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Events;

use App\User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\InteractsWithSockets;
use App\User;
use Illuminate\Queue\SerializesModels;

class BlogWasCreated
{
Expand Down
3 changes: 1 addition & 2 deletions app/Events/BlogWasUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Events;

use App\User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Queue\SerializesModels;
use App\User;

class BlogWasUpdated
{
Expand All @@ -16,7 +16,6 @@ class BlogWasUpdated
*/
public $user;


/**
* Create a new event instance.
*
Expand Down
6 changes: 3 additions & 3 deletions app/Events/SomeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;

class SomeEvent
{
Expand Down
7 changes: 1 addition & 6 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ class Handler extends ExceptionHandler
*
* @param Exception $exception
* @return void
*
*
*/
public function report(Exception $exception)
{
if ($this->shouldReport($exception)) {
}

return parent::report($exception);
}

Expand All @@ -61,7 +60,6 @@ public function render($request, Exception $exception)
return parent::render($request, $exception);
}


if ($exception instanceof HttpNotFoundException) {
return response(view('errors.404'), 404);

Expand All @@ -74,16 +72,13 @@ public function render($request, Exception $exception)
return parent::render($request, $exception);
}


if ($e instanceof ChargeNotFoundException) {
return response(view('errors.422'), 422);

return parent::render($request, $exception);
}
}



/**
* Convert an authentication exception into an unauthenticated response.
*
Expand Down
3 changes: 1 addition & 2 deletions app/Exceptions/HttpNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php

namespace App\Exceptions;

class HttpNotFoundException extends \Exception
{

}
1 change: 0 additions & 1 deletion app/Exceptions/MethodNotAllowedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

class MethodNotAllowedException extends \Exception
{

}
2 changes: 0 additions & 2 deletions app/Exceptions/MethodNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace App\Exceptions;

class MethodNotFoundException extends \Exception
{

}
Loading