本文整理汇总了PHP中app\Group::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::save方法的具体用法?PHP Group::save怎么用?PHP Group::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Group
的用法示例。
在下文中一共展示了Group::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateGroups
public static function updateGroups(Request $request)
{
$titles = $request::get('title');
$ids = $request::get('id');
$deleteId = $request::get('delete');
$newtitle = $request::get('newtitle');
$i = 0;
if ($ids) {
foreach ($ids as $id) {
$group = Group::find($id);
$group->title = $titles[$i];
if (isset($deleteId[$i]) && $deleteId[$i] == $id) {
$group->delete();
} else {
$group->save();
}
$i++;
}
}
if ($newtitle) {
$group = new Group();
$group->title = $newtitle;
$group->save();
}
return true;
}
示例2: axsave
public function axsave(Request $request)
{
//
$response = array('status' => 'success', 'msg' => 'OK!');
$rules = array('fname' => 'required', 'fremark' => 'required', 'femail' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
$response['status'] = "warning";
$response['msg'] = $validator->messages()->toJson();
return response()->json($response);
} else {
try {
$gid = Input::get('fid');
if ($gid != 'Neu') {
$group = Group::find($gid);
} else {
$group = new Group();
}
$group->name = Input::get('fname');
$group->remark = Input::get('fremark');
$group->email = Input::get('femail');
//$user = \App\User::find(1) ;
$group->manager()->associate(Input::get('fmanager'));
$group->save();
} catch (\Illuminate\Database\QueryException $e) {
$response['status'] = "danger";
$response['msg'] = "Database error: " . $e->getMessage();
return response()->json($response);
}
//return Response::json( $response );
return response()->json($response);
}
//validatorf
}
示例3: addGp
public function addGp($name, $courseId)
{
$gp = new Group();
$gp->name = $name;
$gp->course_id = $courseId;
$gp->save();
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$group = new Group();
$group->name = 'Projects';
$group->officer_id = 1;
$group->save();
$group->members()->attach(1);
}
示例5: createTestGroup
private static function createTestGroup()
{
$group = new Group();
$group->name = 'Test123';
$group->scout_group = 'Test_group123';
$group->age_group = 'sudenpennut';
$group_id = $group->save();
return $group_id;
}
示例6: store
/**
* Store a newly created group in storage.
*
* @Post("/")
* @Transaction(
* @Request({"name": "Heist Organizers", "officer_id": 1}),
* @Response(201, body={{"id": 2, "name": "Heist Organizers",
* "officer_id": 1, "officer_url": "/officers/1",
* "url": "/groups/2"}}),
* @Response(422, body={"name": {"The name is already taken."},
* "officer_id": {"The officer id does not exist."}})
* )
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|unique:groups,name', 'officer_id' => 'required|exists:officers,id']);
$group = new Group();
$group->name = $request->input('name');
$group->officer_id = $request->input('officer_id');
$group->save();
return new JsonResponse($group, Response::HTTP_CREATED);
}
示例7: createGroup
public function createGroup(CreateGroupRequest $requests)
{
$group = new Group();
$group->user_id = Auth::id();
$group->name = $requests->name;
$group->status = 1;
$group->save();
return '<div class="alert alert-success" role="alert">List Created</div>';
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'regex:/[A-Za-z0-9\\ \\_\\,\\-\\.]+/|max:255']);
$newGroup = new Group();
$newGroup->name = $request->input('name');
$newGroup->save();
$msg = "Added new group!";
return redirect('group')->with('message', $msg);
}
示例9: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(Group $group, Request $request)
{
$validator = Validator::make($request->all(), ['name' => 'sometimes|required', 'open' => 'sometimes|required|boolean', 'service_provider' => 'sometimes|required|boolean']);
$group->name = $request->name ? $request->name : $group->name;
$group->open = $request->open ? (bool) $request->open : $group->open;
$group->service_provider = $request->service_provider ? (bool) $request->service_provider : $group->service_provider;
if ($group->save()) {
return $this->respondWithItem($group, new GroupTransformer());
}
}
示例10: createGroup
public function createGroup(Request $request)
{
$user = Auth::user();
$group = new Group();
$group->gname = $request->input('gname');
$group->user_id = $user->id;
$group->save();
$group->members()->attach(array($user->id));
//Adds user as member of group
return Redirect::action('PagesController@dashboard');
}
示例11: testGroupCanBeDeleted
public function testGroupCanBeDeleted()
{
$this->logIn();
session()->set('admin', 1);
$group = new Group();
$group->name = 'RyhmäA';
$group->scout_group = 'Lippulaiset';
$group->age_group = 'Vuotiaat';
$group->save();
$this->visit('/groups/1')->press('Poista')->seePageIs('/groups')->dontSee('RyhmäA');
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$group = new Group();
$group->group_name = $request['group_name'];
$group->admin_id = Auth::user()->induser_id;
$group->save();
$groupuser = new Groups_users();
$groupuser->group_id = $group->id;
$groupuser->user_id = Auth::user()->induser_id;
$group->adminUser()->save($groupuser);
return redirect('/group/' . $group->id);
// return $group;
}
示例13: store
public function store()
{
$input = Input::all();
$input = $input['group'];
$validator = Validator::make($input, ['name' => 'required', 'description' => 'required', 'sport_id' => 'required']);
if ($validator->fails()) {
return $this->respondNotFound($validator->errors());
}
$group = new Group();
$group->name = $input['name'];
$group->description = $input['description'];
$group->sport_id = $input['sport_id'];
$group->save();
return $this->setStatusCode(200)->respond(["group" => $this->groupTransformer->transform($group), "message" => "succesfully created the group"]);
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(AddGroupRequest $request)
{
$group = new Group();
/*$v = Validator::make($request->all(), [
"groupname" => "required|min:3|max:255|unique:groups",
]);
if ($v->fails()){
return $v->messages()->toJson();
}*/
$group->groupname = $request->get('groupname');
$group->description = $request->get('description');
$group->save();
return redirect()->route('groups.index')->with('messageOk', 'Add group successfully!');
}
示例15: testUserCanBeRemovedFromTheGroup
public function testUserCanBeRemovedFromTheGroup()
{
$this->logIn();
$group = new Group();
$group->name = 'TestiRyhmä';
$group->scout_group = 'Lippukunta';
$group->age_group = 'Ikäryhmä';
$group->save();
$user = new User();
$user->id = '23';
$user->membernumber = '2312334212';
$user->firstname = 'Liisa';
$user->lastname = 'Saarenmaa';
$user->save();
$this->visit('/groups/1/users')->press('Lisää ryhmän jäsen')->see('Liisa')->press('Poista')->dontSee('Poista');
}