在laravel/Framework9.1管理区使用兰花/crud 3.8和兰花/平台13.6自定义通知,我必须添加兰花AsSource特性来照亮\通知\DatabaseNotification类,这将使我有可能在兰花屏幕中使用这个类,因此我需要转换数据App\Model\兰花\DatabaseNotification(我从照明\通知\DatabaseNotification和添加了AsSource特性复制了这个类)。
use App\Models\orchid\DatabaseNotification; // My custom class
//use Illuminate\Notifications\DatabaseNotification;
class CustomAdminNotificationsScreen extends Screen
{
public function query(Request $request): iterable
{
/** @var Paginator $notifications */
$notifications = $request->user()
->notifications()
->where('type', DashboardMessage::class)
->paginate(10);
/// This data have Illuminate\\Notifications\\DatabaseNotification class claas时
$notifications->data 我有错误:
has Undefined property: Illuminate\Pagination\LengthAwarePaginator::$data我可以手动替换LengthAwarePaginator::$data吗?
如果有办法解决它呢?
谢谢!
发布于 2022-11-22 05:48:56
是的,您可以重新制作$request->user()->notifications() --在获取数据时只需使用它的模型:
DatabaseNotification::query()
->where('notifiable_id', Auth()->id())
->where('type', DashboardMessage::class)
->paginate(10);ps。我不太明白第二个问题,但试试看我先给出的答案。
https://stackoverflow.com/questions/74527916
复制相似问题