首页 \ 问答 \ 在GridView的滚动上滚动整个屏幕(Scrolling the whole screen on GridView's scroll)

在GridView的滚动上滚动整个屏幕(Scrolling the whole screen on GridView's scroll)

我有一个片段,在这个片段下面是一个容器(有时)包含一个GridWiew。 如何在GridView的滚动条上滚动整个屏幕?


I have a fragment and below this fragment a container which (sometimes) contains a GridWiew. How can I scroll the whole screen on GridView’s scroll?


原文:https://stackoverflow.com/questions/29513459
更新时间:2024-03-22 19:03

最满意答案

您可以为每个用户分别设置。 这将工作。 但是也很难维护,你可能需要写3次函数(登录,注销,CRUD等)。

但是,您可以使用授权创建单个项目。 开箱即用,Laravel为您提供了一种简单的方法,通过Gate授权和限制某些操作或通过Policy限制模型。 您也可以通过Middleware来限制URL。 看到你有3种不同的限制行为的方式。

我的个人偏好是Policy因为它与模型绑定。 您拥有权限列表并为每个角色分配权限,例如:'create_sys_admin'。 然后将此权限链接到“root_admin”角色。 所以在你的政策中你可以写:

public function createSysAdmin(User $user) {
    return $user->role->permissions->contains('create_sys_admin');
}

通过定义策略,我们可以检查控制器中的propser权限。 在控制器的任何功能中,您都可以检查适当的权限

if ( Auth::user()->cant('create_sys_admin', User::class) ) {
    return redirect()->back()->withErrors(['authorization' => 'You are not authorized to perform that action']);
}

那只是一种方式。 正如我之前所说的,你也有盖茨和中间件。 在这里阅读更多: https : //laravel.com/docs/5.4/authorization

如果你想要一些东西,你可以使用这个包: https//github.com/Zizaco/entrust


You could make separate setups for each users. That would work. But would also be difficult to maintain and you might have to write some functions 3 times (login, logout, CRUD, etc.).

However, you could create a single project using Authorizations. Out of the box, Laravel gives you an easy way to authorize and restrict some actions via Gate or restrict models via Policy. You could also restrict URLs via Middleware. See you have 3 different ways of restricting actions.

My personal preference is Policy because it's bound to the model. You have a list of permissions and give each role their permissions, eg.: 'create_sys_admin'. Then link this permission to the 'root_admin' role. so in your policy you can write:

public function createSysAdmin(User $user) {
    return $user->role->permissions->contains('create_sys_admin');
}

With the policy defined, we can check for propser permission in the controller. In any function in your controller you can always check for proper permissions

if ( Auth::user()->cant('create_sys_admin', User::class) ) {
    return redirect()->back()->withErrors(['authorization' => 'You are not authorized to perform that action']);
}

That was just one way. As I previously said, you have Gates and Middlewares as well. Read more here: https://laravel.com/docs/5.4/authorization

If you want something already made, you can use this package: https://github.com/Zizaco/entrust.

相关问答

更多
  • 这要么得到第一条记录 Auth::user()->roles->first()->name 或使用循环 @foreach(Auth::user()->roles as $role) {{ $role->name }} @endforeach either this to get the first record Auth::user()->roles->first()->name or use a loop @foreach(Auth::user()->roles as $role) ...
  • 您可以在现有模型对象上使用load函数来加载关系的数据。 $user->load('roles') return $user; You can use the load function on an existing model object to load a relationship's data. $user->load('roles') return $user;
  • 对于初学者,我会建议你重新设计你的数据模型。 您的用户模型是您的身份验证器,这就是它应该关注的一切。 它不应该是商店或供应商,或其他任何东西。 供应商和商店应该是独立的模型,它们拥有“用户”。 此刻你正在做的事情违反了SOLID,就像你在这里提到的大部分答案一样。 特别是O或Open for extension,关闭以进行修改。 例如,如果用户是商店和供应商? 如果稍后再添加分配器类型,该怎么办? 你必须回到那个模型并添加更多的if / else语句,更多类型的关系等等...... 相反,我会考虑拥有“店铺 ...
  • 您已使用auth过滤器,因此您应该在app/filters.php文件中检入auth过滤器: Route::filter('auth', function($route, $request) { // Login check (Default) if (Auth::guest()) return Redirect::guest('login'); // Admin check if(!in_array('admin', Auth::user()->roles->toArra ...
  • 您可以为每个用户分别设置。 这将工作。 但是也很难维护,你可能需要写3次函数(登录,注销,CRUD等)。 但是,您可以使用授权创建单个项目。 开箱即用,Laravel为您提供了一种简单的方法,通过Gate授权和限制某些操作或通过Policy限制模型。 您也可以通过Middleware来限制URL。 看到你有3种不同的限制行为的方式。 我的个人偏好是Policy因为它与模型绑定。 您拥有权限列表并为每个角色分配权限,例如:'create_sys_admin'。 然后将此权限链接到“root_admin”角色。 ...
  • 在您的User类中添加 public function roles() { return $this->belongsToMany('Role','assigned_roles'); } 然后,您可以获取特定用户的所有角色 $user = User::with('roles')->find(1); $roles = $user->roles; In your User class add public function roles() { return $this->belongsToM ...
  • 为什么不创建一个“CompositeRoleProvider”,并使用Path-To-Level类型约定来访问每个从属角色提供者。 您仍然必须创建多个角色提供者,但您的复合或顶级提供者会为您完成所有工作。 我打算用ProfileProvider做类似的事情 why not create a "CompositeRoleProvider" with a Path-To-Level typew convention for accessing each subordinate role provider. Yo ...
  • 要创建模型,只需使用以下内容: $user = User::create($attributes) 请注意,我之后没有调用get() 。 get()将执行返回Collection的查询。 我不确定你的Role模型是什么样的,但它现在应该可以正常工作。 To create a model simply use the following: $user = User::create($attributes) Notice that I did not call get() afterwords. get() ...
  • 是的,使用ASP.NET的内置角色功能将非常有用。 将特定用户添加到角色后, Roles.AddUserToRole("Joe", "Web Developer"); 应用逻辑很容易,例如: if (User.IsInRole("Web Developer")) { //Do something } 此外, RolePrincipal类非常适合访问各种其他与角色相关的方法,例如获取特定角色的所有成员。 Yes it will be useful to use inbuilt role functio ...
  • 我认为实现这一目标的最简单方法是通过自定义中间件定义。 检查默认的auth中间件并设计与此类似的新中间件。 只需用户登录,获取用户并检查他/她的角色。 如果他/她有管理员权限,则重定向到管理员页面等。 定义此中间件后,您可以修改路由并将此中间件附加到它们。 这将在此详细解释 I think the easiest way to achieve this is via custom middleware definition. Check the default auth middleware and des ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)