本文整理汇总了PHP中app\Department::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Department::save方法的具体用法?PHP Department::save怎么用?PHP Department::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Department
的用法示例。
在下文中一共展示了Department::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$input = $request->all();
$department = new Department();
$department->name = $input['name'];
$department->save($request->all());
return redirect('/departments');
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$rule = ['department_name' => 'required | min:2', 'department_credit' => 'required', 'degree_id' => 'required'];
$this->validate($request, $rule);
$department = new Department($request->all());
$department->save();
return redirect('admin/department/create')->withStatus('Degree name saves successfully');
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(DepartmentsFormRequest $request)
{
//
$department = new Department();
$department->name = $request->name;
$department->save();
return \Redirect::route('manage.departments.index', array($department->id))->with('success', 'Your department has been created!');
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|unique:departments|max:255']);
$dept = new Department();
$dept->name = $request->name;
$dept->save();
flash()->success('Success!', 'Department created successfully');
return redirect('/departments');
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, ['txtName' => 'required', 'rActive' => 'required|in:0,1']);
$dep = new Department();
$dep->name = $request->txtName;
$dep->active = $request->rActive;
$dep->save();
return redirect()->route('admin.department.listDep')->with('message', 'Create Department success!');
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$departments = ['Unknown', 'City Administrator', 'Community Services', 'Corporate Services', 'Communications and Economic Development', 'Planning and Development', 'Public Safety', 'Public Works and Engineering'];
foreach ($departments as $name) {
$department = new Department();
$department->active = true;
$department->name = $name;
$department->save();
}
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('departments')->delete();
$department = new Department(['deptHeadId' => '1001', 'department' => 'Neurology']);
$department->save();
$department = new Department(['deptHeadId' => '1002', 'department' => 'Emergency Room']);
$department->save();
$department = new Department(['deptHeadId' => '1003', 'department' => 'ICU']);
$department->save();
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(DepartmentRequest $request)
{
$department = new Department();
$department->name = $request['name'];
$slug = preg_replace('/\\s+/', '-', $request['name']);
$department->slug = $slug;
$department->save();
\Session::flash('success', $request['name'] . ' has been successfully added!');
return redirect()->back();
}
示例9: store
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['name' => 'required|max:50|unique:departments']);
if ($validator->fails()) {
return Redirect::to('/admin/department')->withErrors($validator)->withInput();
}
$department = new Department();
$department->name = $request->name;
$department->save();
return Redirect::to('/admin/department');
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, ['name' => 'required|string']);
$duplicate = Department::where('name', $request->name)->first();
if ($duplicate) {
return response()->json(true);
}
$department = new Department();
$department->name = $request->name;
$department->save();
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(DepartmentRequest $request)
{
$department = new Department();
$department->name = $request['name'];
$department->acronym = $request['acronym'];
$slug = preg_replace('/\\s+/', '-', $request['name']);
$department->slug = $slug;
$department->created_by = \Auth::user()->id;
$department->save();
\Session::flash('success', 'well done! Department ' . $request['name'] . ' has been successfully added!');
return redirect()->back();
}
示例12: registerdepartment
public function registerdepartment()
{
$messages = array('departmentcode.required' => 'Code is required', 'departmentcode.min' => 'Code must be at least 4 characters', 'departmentcode.unique' => 'This department is already registered', 'departmentcode.max' => 'Code must be at most 8 characters', 'departmentname.required' => 'Department name is required');
$validator = Validator::make(Input::all(), ['departmentcode' => 'required|min:4|max:8|unique:departments,code', 'departmentname' => 'required'], $messages);
if ($validator->fails()) {
return redirect('adddepartment')->withInput()->withErrors($validator);
}
$department = new Department();
$department->code = Input::get('departmentcode');
$department->name = Input::get('departmentname');
$department->total_rooms = Input::get('departmentrooms');
$department->save();
return view('layouts.adddepartment')->with('registermsg', 'Department added successfully');
}
示例13: postCreate
public function postCreate()
{
$rules = array('name' => 'required|min:6|max:100', 'address' => 'required|min:6|max:100', 'weight_limit' => 'required', 'city_id' => 'required', 'phone' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::route('new-department')->withErrors($validator);
}
$department = new Department();
$department->name = Input::get('name');
$department->phone = Input::get('phone');
$department->adress = Input::get('address');
$department->city_id = intval(Input::get('city_id'));
$department->weight_limit = intval(Input::get('weight_limit'));
$department->save();
return Redirect::route('departments');
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// Get request inputs
$txtDepartmentName = $request->input('txtDepartmentName');
$data = array('txtDepartmentName' => $txtDepartmentName);
$rules = array('txtDepartmentName' => 'required|min:1|max:40|unique:department,name');
// Validate input
$reponse = Helper::validator($data, $rules, 'dashboard.settings.departments.index');
if (isset($reponse)) {
return $reponse;
}
// Create a new department
$department = new Department();
$department->name = $txtDepartmentName;
$department->save();
return redirect()->route('dashboard.settings.departments.index')->with('message', 'Department saved successfully');
}
示例15: store
public function store(DepartmentRequest $request)
{
$allWorker = DB::table('department_worker')->get(['user_id']);
$duplicateWorker = [];
$leader = $request->department_leader;
$departmentUsers = $request->department_worker;
array_push($departmentUsers, $request->department_leader);
$departmentUsers = array_unique($departmentUsers);
foreach ($allWorker as $aw) {
if (in_array($aw->user_id, $request->department_worker)) {
array_push($duplicateWorker, $aw->user_id);
}
}
if (!empty($duplicateWorker)) {
$users = User::whereIn('id', $duplicateWorker)->select(DB::raw('CONCAT(first_name," ",last_name) as full_name'))->get();
$usersString = '';
foreach ($users as $u) {
$usersString .= $u->full_name . ',';
}
return response()->json(['messages' => $usersString . ' Kişileri Başka Bir Departmana Bağlıdır.'], 422);
} else {
foreach ($departmentUsers as $key => $value) {
$value == $leader ? $departmentUsers[$key] = ['user_id' => $value, 'is_senior' => 1] : ($departmentUsers[$key] = ['user_id' => $value, 'is_senior' => 0]);
}
$this->permissionSection(function () use($request, $departmentUsers) {
DB::transaction(function () use($request, $departmentUsers) {
$department = new Department();
$department->slug = $request->slug_name;
$department->name = $request->department_name;
$department->save();
$department->worker()->sync($departmentUsers);
});
}, 'wts.department.create');
return response()->json($this->storeResponseMessage);
}
}