orderByDesc

This commit is contained in:
Benjamin Takats
2023-01-22 12:24:28 +01:00
parent c01e17b629
commit 19d9cfde22
2 changed files with 11 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ class ArticleOverview extends Component
->where('type', 'markdown_article') ->where('type', 'markdown_article')
->whereHas('createdBy.roles', ->whereHas('createdBy.roles',
fn($query) => $query->where('roles.name', 'news-editor')) fn($query) => $query->where('roles.name', 'news-editor'))
->orderByDesc('created_at')
->get(), ->get(),
])->layout('layouts.app', [ ])->layout('layouts.app', [
'SEOData' => new SEOData( 'SEOData' => new SEOData(

View File

@@ -14,6 +14,7 @@ class LibraryPolicy extends BasePolicy
* Determine whether the user can view any models. * Determine whether the user can view any models.
* *
* @param \App\Models\User $user * @param \App\Models\User $user
*
* @return \Illuminate\Auth\Access\Response|bool * @return \Illuminate\Auth\Access\Response|bool
*/ */
public function viewAny(User $user) public function viewAny(User $user)
@@ -26,6 +27,7 @@ class LibraryPolicy extends BasePolicy
* *
* @param \App\Models\User $user * @param \App\Models\User $user
* @param \App\Models\Library $library * @param \App\Models\Library $library
*
* @return \Illuminate\Auth\Access\Response|bool * @return \Illuminate\Auth\Access\Response|bool
*/ */
public function view(User $user, Library $library) public function view(User $user, Library $library)
@@ -37,11 +39,14 @@ class LibraryPolicy extends BasePolicy
* Determine whether the user can create models. * Determine whether the user can create models.
* *
* @param \App\Models\User $user * @param \App\Models\User $user
*
* @return \Illuminate\Auth\Access\Response|bool * @return \Illuminate\Auth\Access\Response|bool
*/ */
public function create(User $user) public function create(User $user)
{ {
return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__); return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__)
&& Library::query()
->count() < 8;
} }
/** /**
@@ -49,6 +54,7 @@ class LibraryPolicy extends BasePolicy
* *
* @param \App\Models\User $user * @param \App\Models\User $user
* @param \App\Models\Library $library * @param \App\Models\Library $library
*
* @return \Illuminate\Auth\Access\Response|bool * @return \Illuminate\Auth\Access\Response|bool
*/ */
public function update(User $user, Library $library) public function update(User $user, Library $library)
@@ -61,6 +67,7 @@ class LibraryPolicy extends BasePolicy
* *
* @param \App\Models\User $user * @param \App\Models\User $user
* @param \App\Models\Library $library * @param \App\Models\Library $library
*
* @return \Illuminate\Auth\Access\Response|bool * @return \Illuminate\Auth\Access\Response|bool
*/ */
public function delete(User $user, Library $library) public function delete(User $user, Library $library)
@@ -73,6 +80,7 @@ class LibraryPolicy extends BasePolicy
* *
* @param \App\Models\User $user * @param \App\Models\User $user
* @param \App\Models\Library $library * @param \App\Models\Library $library
*
* @return \Illuminate\Auth\Access\Response|bool * @return \Illuminate\Auth\Access\Response|bool
*/ */
public function restore(User $user, Library $library) public function restore(User $user, Library $library)
@@ -85,6 +93,7 @@ class LibraryPolicy extends BasePolicy
* *
* @param \App\Models\User $user * @param \App\Models\User $user
* @param \App\Models\Library $library * @param \App\Models\Library $library
*
* @return \Illuminate\Auth\Access\Response|bool * @return \Illuminate\Auth\Access\Response|bool
*/ */
public function forceDelete(User $user, Library $library) public function forceDelete(User $user, Library $library)