-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from laravelcm/admin-stats
Admin stats
- Loading branch information
Showing
38 changed files
with
627 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Cpanel; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
|
||
class AnalyticsController extends Controller | ||
{ | ||
public function __invoke() | ||
{ | ||
return view('cpanel.analytics'); | ||
} | ||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace App\Widgets; | ||
|
||
use App\Models\User; | ||
use Arrilot\Widgets\AbstractWidget; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class MostActiveUsersPerWeek extends AbstractWidget | ||
{ | ||
/** | ||
* The configuration array. | ||
* | ||
* @var array | ||
*/ | ||
protected $config = []; | ||
|
||
/** | ||
* The number of seconds before each reload. | ||
* | ||
* @var int|float | ||
*/ | ||
public $reloadTimeout = 60 * 60 * 24 * 2; // 2 days | ||
|
||
/** | ||
* The number of minutes before cache expires. | ||
* False means no caching at all. | ||
* | ||
* @var int|float|bool | ||
*/ | ||
public $cacheTime = 0; | ||
|
||
/** | ||
* Treat this method as a controller action. | ||
* Return view() or other content to display. | ||
*/ | ||
public function run(): View | ||
{ | ||
$users = User::with('activities') | ||
->withCount('activities') | ||
->verifiedUsers() | ||
->whereHas('activities', function (Builder $query) { | ||
return $query->whereBetween('created_at', [ | ||
now()->startOfWeek(), | ||
now()->endOfWeek() | ||
]); | ||
}) | ||
->orderByDesc('activities_count') | ||
->limit(5) | ||
->get(); | ||
|
||
return view('widgets.most_active_users_per_week', [ | ||
'config' => $this->config, | ||
'users' => $users, | ||
]); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Widgets; | ||
|
||
use App\Models\Article; | ||
use Arrilot\Widgets\AbstractWidget; | ||
use Illuminate\Contracts\View\View; | ||
|
||
class MostLikedPostsPerWeek extends AbstractWidget | ||
{ | ||
/** | ||
* The configuration array. | ||
* | ||
* @var array | ||
*/ | ||
protected $config = []; | ||
|
||
/** | ||
* The number of seconds before each reload. | ||
* | ||
* @var int|float | ||
*/ | ||
public $reloadTimeout = 60 * 60 * 24 * 2; // 2 days | ||
|
||
/** | ||
* The number of minutes before cache expires. | ||
* False means no caching at all. | ||
* | ||
* @var int|float|bool | ||
*/ | ||
public $cacheTime = 0; | ||
|
||
/** | ||
* Treat this method as a controller action. | ||
* Return view() or other content to display. | ||
*/ | ||
public function run(): View | ||
{ | ||
$articles = Article::published() | ||
->popular() | ||
->limit(5) | ||
->get(); | ||
|
||
return view('widgets.most_liked_posts_per_week', [ | ||
'config' => $this->config, | ||
'articles' => $articles, | ||
]); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace App\Widgets; | ||
|
||
use App\Models\Article; | ||
use Arrilot\Widgets\AbstractWidget; | ||
use CyrildeWit\EloquentViewable\Support\Period; | ||
use Illuminate\Contracts\View\View; | ||
|
||
class MostViewedPostsPerWeek extends AbstractWidget | ||
{ | ||
/** | ||
* The configuration array. | ||
* | ||
* @var array | ||
*/ | ||
protected $config = []; | ||
|
||
/** | ||
* The number of seconds before each reload. | ||
* | ||
* @var int|float | ||
*/ | ||
public $reloadTimeout = 60 * 60 * 24 * 2; // 2 days | ||
|
||
/** | ||
* The number of minutes before cache expires. | ||
* False means no caching at all. | ||
* | ||
* @var int|float|bool | ||
*/ | ||
public $cacheTime = 90; | ||
|
||
/** | ||
* Treat this method as a controller action. | ||
* Return view() or other content to display. | ||
*/ | ||
public function run(): View | ||
{ | ||
$articles = Article::withViewsCount(Period::create(now()->startOfWeek(), now()->endOfWeek())) | ||
->published() | ||
->orderByDesc('views_count') | ||
->orderByDesc('published_at') | ||
->limit(5) | ||
->get(); | ||
|
||
return view('widgets.most_viewed_posts_per_week', [ | ||
'config' => $this->config, | ||
'articles' => $articles, | ||
]); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Widgets; | ||
|
||
use App\Models\Article; | ||
use Arrilot\Widgets\AbstractWidget; | ||
use Illuminate\Contracts\View\View; | ||
|
||
class RecentPostsPerWeek extends AbstractWidget | ||
{ | ||
/** | ||
* The configuration array. | ||
* | ||
* @var array | ||
*/ | ||
protected $config = []; | ||
|
||
/** | ||
* Treat this method as a controller action. | ||
* Return view() or other content to display. | ||
*/ | ||
public function run(): View | ||
{ | ||
$articles = Article::recent() | ||
->whereBetween('created_at', [now()->startOfWeek(), now()->endOfWeek()]) | ||
->limit(5) | ||
->get(); | ||
|
||
return view('widgets.recent_posts_per_week', [ | ||
'config' => $this->config, | ||
'articles' => $articles, | ||
]); | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.