本文整理汇总了PHP中Action::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Action::where方法的具体用法?PHP Action::where怎么用?PHP Action::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Action
的用法示例。
在下文中一共展示了Action::where方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::table('permissions')->delete();
$roles = array();
$roles[0] = Role::where('name', '=', 'admin')->first()->id;
$roles[1] = Role::where('name', '=', 'moderator')->first()->id;
$resources = Resource::all();
$actions = array();
$actions[0] = Action::where('name', '=', 'manage')->first()->id;
/*
$actions[0] = Action::where('name','=','create')->first()->id;
$actions[1] = Action::where('name','=','read')->first()->id;
$actions[2] = Action::where('name','=','update')->first()->id;
$actions[3] = Action::where('name','=','delete')->first()->id
*/
$data = array();
foreach ($roles as $role) {
foreach ($resources as $resource) {
foreach ($actions as $action) {
$data[] = array('role_id' => $role, 'type' => $role == $roles[0] || $resource->name != 'role' && $resource->name != 'auth' ? 'allow' : 'deny', 'action_id' => $action, 'resource_id' => $resource->id);
}
}
}
DB::table('permissions')->insert($data);
}
示例2: checkAction
/**
* [checkData description]
* @param [type] $data [description]
* @return [type] [description]
*/
public function checkAction($action)
{
$rs = Action::where('action_name', '=', $action)->count();
if (isset($rs)) {
return $rs >= 1 ? false : true;
}
}
示例3: canUse
public function canUse($item1, $item2)
{
// is it useable
$useable = Action::where("item_1", $item1)->firstOrFail();
$useable = $useable->item_2;
if ($useable == $item2) {
return true;
} else {
return false;
}
}
示例4: hasPermission
/**
* hasPermissions
*
*/
public function hasPermission($action, $resource)
{
$action_id = Action::where('name', '=', $action)->first()->id;
$resource_id = Resource::where('name', '=', $resource)->first()->id;
foreach ($this->roles as $role) {
foreach ($role->permissionsAllowed as $permission) {
if ($permission->action_id == $action_id && $permission->resource_id == $resource_id) {
return true;
}
}
}
return false;
}
示例5: postUpdate
public function postUpdate($group_id)
{
Allow::permission($this->module['group'], 'groups');
$json_request = array('status' => FALSE, 'responseText' => '', 'responseErrorText' => '', 'redirect' => FALSE);
if (!Request::ajax()) {
App::abort(404);
}
if (!($group = Group::find($group_id))) {
$json_request['responseText'] = 'Запрашиваемая группа не найдена!';
return Response::json($json_request, 400);
}
$validation = Validator::make(Input::all(), Group::$rules_update);
if ($validation->passes()) {
## Update group
$group->name = mb_strtolower(Input::get('name'));
$group->desc = Input::get('desc');
$group->dashboard = Input::get('dashboard');
$group->start_url = Input::get('start_url');
$group->save();
$group->touch();
## Update actions
Action::where('group_id', $group_id)->delete();
if (is_array(Input::get('actions')) && count(Input::get('actions'))) {
foreach (Input::get('actions') as $module_name => $actions) {
foreach ($actions as $a => $act) {
$action = new Action();
$action->group_id = $group_id;
$action->module = $module_name;
$action->action = $act;
$action->status = 1;
$action->save();
}
}
}
$json_request['responseText'] = 'Группа обновлена';
#$json_request['responseText'] = print_r($group_id, 1);
#$json_request['responseText'] = print_r($group, 1);
#$json_request['responseText'] = print_r(Input::get('actions'), 1);
#$json_request['responseText'] = print_r($group->actions(), 1);
#$json_request['redirect'] = link::auth('groups');
$json_request['status'] = TRUE;
} else {
$json_request['responseText'] = 'Неверно заполнены поля';
$json_request['responseErrorText'] = implode($validation->messages()->all(), '<br />');
}
return Response::json($json_request, 200);
}
示例6: getStatMonthByWeeks
public function getStatMonthByWeeks()
{
$in = Input::only('qlink');
$out = array();
$rules = array('qlink' => 'required | alpha_num');
$vd = Validator::make($in, $rules);
if ($vd->fails()) {
return;
}
$cid = Church::where('qlink', $in['qlink'])->pluck('id');
$church = Church::where('qlink', $in['qlink'])->first();
if ($cid) {
$actions = array_fill(1, 5, '');
foreach (Action::where('cid', $cid)->groupMonthByWeeks() as $k => $v) {
foreach ($v as $key => $value) {
$actions[$k]++;
}
}
$users = array_fill(1, 5, '');
foreach (UserChurch::where('cid', $cid)->groupMonthByWeeks() as $k => $v) {
foreach ($v as $key => $value) {
$users[$k]++;
}
}
$out['statistic_actions_month_by_weeks'] = array_values($actions);
$out['statistic_users_month_by_weeks'] = array_values($users);
}
return Response::json($out);
}
示例7: delAction
/**
* [delAction description]
* @param [type] $id [description]
* @return [type] [description]
*/
public function delAction($id)
{
Action::where('id', '=', $id)->delete();
return Redirect::to('action')->with('success', 'การกระทำรหัส = ' . $id . ' ลบทิ้งสำเร็จ');
}