✨ Ajoute la page de listing public
This commit is contained in:
25
app/Home.php
25
app/Home.php
@@ -4,10 +4,13 @@ namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\Feed\Feedable;
|
||||
use Spatie\Feed\FeedItem;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
|
||||
class Home extends Model
|
||||
class Home extends Model implements Feedable
|
||||
{
|
||||
protected $fillable = [
|
||||
'title', 'price', 'surface', 'garden_surface', 'rooms', 'energy',
|
||||
@@ -66,4 +69,24 @@ class Home extends Model
|
||||
Artisan::call('app:downloadimage ' . $home->id);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toFeedItem()
|
||||
{
|
||||
return FeedItem::create()
|
||||
->id($this->id)
|
||||
->title($this->title)
|
||||
->summary($this->excerpt())
|
||||
->author('Shikiryu')
|
||||
->updated($this->created_at)
|
||||
->link(\route('public.view', ['slug' => $this->slug]))
|
||||
;
|
||||
}
|
||||
|
||||
public static function getFeedItems()
|
||||
{
|
||||
return self::where('slug', '!=', null)->limit(20)->get();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user