本文整理汇总了PHP中app\models\Group类的典型用法代码示例。如果您正苦于以下问题:PHP Group类的具体用法?PHP Group怎么用?PHP Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Delete the specified group
*
* @param Group $group
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \Exception
*/
public function destroy(Group $group)
{
$this->authorize('edit_users');
$group->delete();
flash()->success('Group Deleted', 'The group has been removed');
return redirect('group');
}
示例2: destroy
/**
* @param Group $Group
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function destroy(Group $Group)
{
if ($count = $Group->users->count()) {
return redirect(route('admin.groups.list'))->with('error', "В группе есть пользователи ({$count})");
}
$Group->delete();
return redirect(route('admin.groups.list'));
}
示例3: addGroupUser
/**
* 项目添加用户
*
* @param $projectId
* @param $userId
* @return bool
*/
public static function addGroupUser($projectId, $userId)
{
// 是否已在组内
$exists = Group::find()->where(['project_id' => $projectId, 'user_id' => $userId])->count();
if ($exists) {
return true;
}
$group = new Group();
$group->attributes = ['project_id' => $projectId, 'user_id' => $userId];
return $group->save();
}
示例4: up
/**
* Run the migrations.
*/
public function up()
{
Schema::create('groups', function ($table) {
$table->increments('id');
$table->string('name');
$table->string('address1');
$table->string('address2');
$table->string('city');
$table->string('state');
$table->string('postal_code');
$table->string('phone_number');
$table->string('display_name');
$table->enum('status', Group::getStatuses());
$table->timestamps();
$table->softDeletes();
});
Schema::create('group_members', function ($table) {
$table->increments('id');
$table->integer('group_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->enum('role', Group::getRoles());
$table->timestamps();
$table->softDeletes();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('group_id')->references('id')->on('groups')->onDelete('cascade');
});
}
示例5: all
public function all($params)
{
$params['order'] = isset($params['order']) ? $params['order'] : ['display_name|ASC'];
$groups = Group::select("groups.*");
$groups = parent::execute($groups, $params);
return $groups;
}
示例6: actionSubcat
public function actionSubcat()
{
$out = [];
$isEmpty = true;
if (isset($_POST['depdrop_parents'])) {
$parents = $_POST['depdrop_parents'];
if ($parents != null) {
$cat_id = $parents[0];
$out = Group::getDropDownList($cat_id);
//$out = [['id'=>'1', 'name'=>$cat_id],['id'=>'2', 'name'=>json_encode(Group::getDropDownList($cat_id))]];
$isEmpty = false;
$selected = '';
if (!empty($_POST['depdrop_params'])) {
$params = $_POST['depdrop_params'];
$selected = $params[0];
// get the value of input-type-1
$param2 = $params[1];
// get the value of input-type-2
}
echo Json::encode(['output' => $out, 'selected' => $selected]);
}
}
if ($isEmpty) {
echo Json::encode(['output' => [['id' => '1', 'name' => '<sub-cat-name1>'], ['id' => '2', 'name' => '<sub-cat-name2>']], 'selected' => '']);
}
}
示例7: delete
public function delete($id)
{
if (Group::destroy($id)) {
return redirect()->back()->with('msg', 'Группа удалена');
}
return redirect()->back()->with('warning', 'Не удалось удалить');
}
示例8: portfolioItem
public function portfolioItem($groupLink, $id)
{
$group = Group::where('link', '=', $groupLink)->firstOrFail();
$portfolios = PortfolioRepository::byGroup($groupLink);
$view = Agent::isTablet() || Request::has('t') ? 'tablet.portfolio_item' : (Agent::isMobile() || Request::has('m') ? 'mobile.portfolio_item' : 'index.portfolio_item');
return view($view, array('group' => $group, 'portfolios' => $portfolios, 'id' => $id, 'title' => $group->title . ' | TWIGA'));
}
示例9: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$data['groups'] = Group::orderBy('groupname')->get();
$data['setting'] = Setting::find($id);
$data['themes'] = array('cerulean' => 'cerulean', 'cosmo' => 'cosmo', 'cyborg' => 'cyborg', 'darkly' => 'darkly', 'flatly' => 'flatly', 'journal' => 'journal', 'lumen' => 'lumen', 'paper' => 'paper', 'readable' => 'readable', 'sandstone' => 'sandstone', 'simplex' => 'simplex', 'slate' => 'slate', 'spacelab' => 'spacelab', 'superhero' => 'superhero', 'united' => 'united', 'yeti' => 'yeti');
return View::make('settings.edit', $data);
}
示例10: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit(User $User)
{
$this->data['Roles'] = Role::all();
$this->data['Groups'] = Group::all();
$this->data['User'] = $User;
return view('admin.users.edit', $this->data);
}
示例11: actionSubmit
/**
* 提交任务
*
* @param $projectId
* @return string
*/
public function actionSubmit($projectId = null)
{
$task = new Task();
if ($projectId) {
$conf = Project::find()->where(['id' => $projectId, 'status' => Project::STATUS_VALID])->one();
}
if (\Yii::$app->request->getIsPost()) {
if (!$conf) {
throw new \Exception('未知的项目,请确认:)');
}
$group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
if (!$group) {
throw new \Exception('非该项目成员,无权限');
}
if ($task->load(\Yii::$app->request->post())) {
// 是否需要审核
$status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
$task->user_id = $this->uid;
$task->project_id = $projectId;
$task->status = $status;
if ($task->save()) {
$this->redirect('/task/');
}
}
}
if ($projectId) {
return $this->render('submit', ['task' => $task, 'conf' => $conf]);
}
// 成员所属项目
$projects = Project::find()->leftJoin(Group::tableName(), '`group`.project_id=project.id')->where(['project.status' => Project::STATUS_VALID, '`group`.user_id' => $this->uid])->asArray()->all();
return $this->render('select-project', ['projects' => $projects]);
}
示例12: run
public function run()
{
$adminEmail = Config::get('madison.seeder.admin_email');
$adminPassword = Config::get('madison.seeder.admin_password');
// Login as admin to create docs
$credentials = array('email' => $adminEmail, 'password' => $adminPassword);
Auth::attempt($credentials);
$admin = Auth::user();
$group = Group::where('id', '=', 1)->first();
// Create first doc
$docSeedPath = app_path() . '/database/seeds/example.md';
if (file_exists($docSeedPath)) {
$content = file_get_contents($docSeedPath);
} else {
$content = "New Document Content";
}
$docOptions = array('title' => 'Example Document', 'content' => $content, 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP);
$document = Doc::createEmptyDocument($docOptions);
//Set first doc as featured doc
$featuredSetting = new Setting();
$featuredSetting->meta_key = 'featured-doc';
$featuredSetting->meta_value = $document->id;
$featuredSetting->save();
// Create second doc
$docSeedPath = app_path() . '/database/seeds/example2.md';
if (file_exists($docSeedPath)) {
$content = file_get_contents($docSeedPath);
} else {
$content = "New Document Content";
}
$docOptions = array('title' => 'Second Example Document', 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP);
$document = Doc::createEmptyDocument($docOptions);
}
示例13: putVerify
public function putVerify($groupId)
{
$this->beforeFilter('admin');
$newGroup = (object) Input::all();
if (!Group::isValidStatus($newGroup->status)) {
throw new \Exception("Invalid value for verify request");
}
$group = Group::where('id', '=', $groupId)->first();
if (!$group) {
throw new \Exception("Invalid Group");
}
$group->status = $newGroup->status;
DB::transaction(function () use($group) {
$group->save();
switch ($group->status) {
case Group::STATUS_ACTIVE:
$group->createRbacRules();
break;
case Group::STATUS_PENDING:
$group->destroyRbacRules();
break;
}
});
return Response::json($group);
}
示例14: run
public function run()
{
$total = [];
foreach (Group::find()->all() as $key => $group) {
$total[$group->name] = GroupClient::find()->where(['groups_id' => $group->id])->count();
}
return $this->render('groups/index', ['group' => new Group(), 'total' => $total]);
}
示例15: findModel
/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Group::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}