add recent() call to BaseRepository
This commit is contained in:
parent
9566da84a5
commit
622e099b97
@ -24,7 +24,46 @@
|
||||
</option>
|
||||
<option name="migratedIntoUserSpace" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="LongInheritanceChainInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="PhpSignatureMismatchDuringInheritanceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="SecurityAdvisoriesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="optionConfiguration">
|
||||
<list>
|
||||
<option value="behat/behat" />
|
||||
<option value="composer/composer" />
|
||||
<option value="friendsofphp/php-cs-fixer" />
|
||||
<option value="humbug/humbug" />
|
||||
<option value="infection/infection" />
|
||||
<option value="jakub-onderka/php-parallel-lint" />
|
||||
<option value="johnkary/phpunit-speedtrap" />
|
||||
<option value="mockery/mockery" />
|
||||
<option value="pdepend/pdepend" />
|
||||
<option value="phan/phan" />
|
||||
<option value="phing/phing" />
|
||||
<option value="phpmd/phpmd" />
|
||||
<option value="phpro/grumphp" />
|
||||
<option value="phpspec/phpspec" />
|
||||
<option value="phpspec/prophecy" />
|
||||
<option value="phpstan/phpstan" />
|
||||
<option value="phpunit/dbunit" />
|
||||
<option value="phpunit/phpunit" />
|
||||
<option value="povils/phpmnd" />
|
||||
<option value="satooshi/php-coveralls" />
|
||||
<option value="sebastian/phpcpd" />
|
||||
<option value="slevomat/coding-standard" />
|
||||
<option value="squizlabs/php_codesniffer" />
|
||||
<option value="symfony/debug" />
|
||||
<option value="symfony/phpunit-bridge" />
|
||||
<option value="symfony/var-dumper" />
|
||||
<option value="vimeo/psalm" />
|
||||
<option value="yiisoft/yii2-debug" />
|
||||
<option value="yiisoft/yii2-gii" />
|
||||
<option value="zendframework/zend-debug" />
|
||||
<option value="zendframework/zend-test" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="optionConfigurationMigrated" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||
<option name="processCode" value="true" />
|
||||
<option name="processLiterals" value="true" />
|
||||
|
@ -11,9 +11,15 @@ class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
public function view($template, $vars=[])
|
||||
/**
|
||||
* Display a view but pull it from the active skin
|
||||
* @param string $template
|
||||
* @param array $vars
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function view(string $template, array $vars=[])
|
||||
{
|
||||
$tpl = 'layouts/'.config('phpvms.skin').'/'.$template;
|
||||
$tpl = 'layouts/' . config('phpvms.skin') . '/' . $template;
|
||||
return view($tpl, $vars);
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,31 @@
|
||||
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Repositories\PirepRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Controllers\AppBaseController;
|
||||
|
||||
use App\Models\Pirep;
|
||||
use App\Models\User;
|
||||
|
||||
|
||||
class DashboardController extends AppBaseController
|
||||
{
|
||||
private $pirepRepo, $userRepo;
|
||||
|
||||
public function __construct(
|
||||
PirepRepository $pirepRepo,
|
||||
UserRepository $userRepo
|
||||
) {
|
||||
$this->pirepRepo = $pirepRepo;
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$pireps = Pirep::orderBy('created_at', 'desc')->take(5)->get();
|
||||
$users = User::orderBy('created_at', 'desc')->take(5)->get();
|
||||
$pireps = $this->pirepRepo->recent();
|
||||
$users = $this->userRepo->recent();
|
||||
|
||||
return $this->view('dashboard.index', [
|
||||
'user' => Auth::user(),
|
||||
|
@ -38,4 +38,15 @@ abstract class BaseRepository extends \Prettus\Repository\Eloquent\BaseRepositor
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return N most recent items, sorted by created_at
|
||||
* @param int $count
|
||||
* @param string $sort_by created_at (default) or updated_at
|
||||
* @return mixed
|
||||
*/
|
||||
public function recent($count = 5, $sort_by = 'created_at')
|
||||
{
|
||||
return $this->orderBy($sort_by, 'desc')->paginate($count);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user