Last active
March 5, 2019 22:49
-
-
Save alcir-junior-caju/c755dae1bebe603b00937af7eecdb5a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Widgets; | |
use App\Post; | |
use Illuminate\Support\Str; | |
use TCG\Voyager\Widgets\BaseDimmer; | |
use Illuminate\Support\Facades\Auth; | |
class Posts extends BaseDimmer | |
{ | |
/** | |
* The configuration array. | |
* | |
* @var array | |
*/ | |
protected $config = []; | |
/** | |
* Treat this method as a controller action. | |
* Return view() or other content to display. | |
*/ | |
public function run() | |
{ | |
$count = Post::count(); | |
$string = 'Publicações'; | |
return view('voyager::dimmer', array_merge($this->config, [ | |
'icon' => 'voyager-file-text', | |
'title' => "{$count} {$string}", | |
'text' => "Tem {$count} publicações no seu banco de dados. Clique no botão abaixo para ver todas as Publicações.", | |
'button' => [ | |
'text' => 'Ver todas as publicações', | |
'link' => route('voyager.posts.index'), | |
], | |
'image' => voyager_asset('images/widget-backgrounds/03.jpg'), | |
])); | |
} | |
/** | |
* Determine if the widget should be displayed. | |
* | |
* @return bool | |
*/ | |
public function shouldBeDisplayed() | |
{ | |
return Auth::user()->can('browse', app(Post::class)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment