Skip to content

Instantly share code, notes, and snippets.

@alcir-junior-caju
Last active March 5, 2019 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alcir-junior-caju/c755dae1bebe603b00937af7eecdb5a2 to your computer and use it in GitHub Desktop.
Save alcir-junior-caju/c755dae1bebe603b00937af7eecdb5a2 to your computer and use it in GitHub Desktop.
<?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