本文整理汇总了PHP中app\Department::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Department::create方法的具体用法?PHP Department::create怎么用?PHP Department::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Department
的用法示例。
在下文中一共展示了Department::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Create level 0 : member
Level::create(['level' => 0, 'name' => 'membre']);
// Create level 1 : band_creator
Level::create(['level' => 1, 'name' => 'manager']);
// Create level 2 : teacher
Level::create(['level' => 2, 'name' => 'professeur']);
// Create level 3 : admin
Level::create(['level' => 3, 'name' => 'admin']);
// Create level 10 : webmaster
Level::create(['level' => 10, 'name' => 'webmaster']);
// Create departement : "aucun"
Department::create(['name' => 'Aucun', 'short_name' => 'Aucun']);
// Create user : Webmaster (lvl 10)
User::create(['first_name' => 'Webmaster', 'last_name' => 'Webmaster', 'email' => 'webm@ster', 'school_year' => 0, 'department_id' => 1, 'password' => bcrypt('webmastercmt'), 'level_id' => 5, 'slug' => 'webmaster-webmaster-1']);
Category::create(['name' => 'Aucune']);
Category::create(['name' => 'Autre']);
Category::create(['name' => 'Présentation']);
Category::create(['name' => 'Création de groupe']);
Category::create(['name' => 'Recherche de groupe']);
Category::create(['name' => 'Échange/Vente']);
//Creation basic instruments :
$instruments = ['autre', 'guitare', 'piano', 'basse', 'chant', 'flûte', 'violon', 'contrebasse', 'clarinette', 'saxophone', 'batterie', 'violoncelle', 'guitare électrique', 'flûte traversière', 'trompette', 'cor', 'trombone', 'tuba'];
$this->create_instrument($instruments);
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$data = $request->except('_token');
Department::create($data);
return back();
}
示例3: importDept
public function importDept($destfile)
{
$this->count['dept->success'] = 0;
$this->count['dept->failed'] = 0;
Excel::load($destfile, function ($reader) {
$rules = ['name' => 'required|unique_with:departments,company_id,costcent', 'company_id' => 'required|exists:companies,id', 'costcent' => 'required'];
$sheetsCount = $reader->getSheetCount();
for ($i = 0; $i < $sheetsCount; $i++) {
$sheets = $reader->getSheet($i)->toArray();
$company_name = $reader->getSheet($i)->getTitle();
$dept['company_id'] = Company::where('name', $company_name)->value('id');
$sheetCount = count($sheets);
for ($j = 6; $j < $sheetCount; $j++) {
$dept['name'] = trim($sheets[$j][1]);
$dept['costcent'] = trim($sheets[$j][10]);
$dept['description'] = $dept['name'];
$dept_v = \Validator::make($dept, $rules);
if ($dept_v->passes()) {
Department::create($dept);
$this->count['dept->success'] += 1;
} else {
$this->count['dept->failed'] += 1;
}
}
}
//END
});
return $this->count;
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
foreach (range(1, 10) as $index) {
Department::create(['title' => $faker->company]);
}
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('departments')->delete();
Department::create(['title' => 'Администрация']);
Department::create(['title' => 'Отдел 1']);
Department::create(['title' => 'Отдел 2']);
Department::create(['title' => 'Отдел 3']);
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
DB::table('Departments')->delete();
$departments = array(['department_name' => 'department of electrical and power engineering', 'faculty_id' => '1'], ['department_name' => 'department of electrical and telcom engineering', 'faculty_id' => '1'], ['department_name' => 'department of computer science', 'faculty_id' => '2']);
foreach ($departments as $department) {
Department::create($department);
}
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(DepartmentRequest $request)
{
try {
Department::create($request->all());
Flash::success('The Department has been created.');
return redirect()->route('department.index');
} catch (Exception $e) {
Flash::error('The Department could not be created.');
}
}
示例8: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
if (Request::isMethod('get')) {
$this->data['items'] = Department::get();
return view('pages.department.create', $this->data);
} elseif (Request::isMethod('post')) {
$department = Department::create(Input::all());
return redirect('department');
}
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
if ($this->validator($request->all())->fails()) {
flash()->error('There is something wrong with the inputs.');
return redirect()->back();
} else {
Department::create($request->all());
flash()->success("Department successfully added!");
return redirect()->back();
}
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
Flash::error('Impossible d\'ajouter ce département.');
return Redirect::back()->withErrors($validator->errors());
}
$dep = Department::create(['name' => $request->name, 'short_name' => $request->short_name]);
Modification::create(['table' => 'departments', 'user_id' => Auth::user()->id, 'message' => 'added department ' . $request->name . ' (' . $request->short_name . ')']);
Flash::success('Le département a bien été créé !');
return redirect('admin/departments');
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\DepartmentRequest $request
* @return \Illuminate\Http\Response
*/
public function store(Requests\DepartmentRequest $request)
{
DB::transaction(function () use($request) {
$department = Department::create(['keyword' => $request->get('keyword'), 'url' => $request->get('url'), 'image' => $request->file('image')->getClientOriginalName(), 'theme_background_color' => $request->get('theme_background_color'), 'theme_color' => $request->get('theme_color'), 'sort' => $request->get('sort'), 'active' => $request->get('active')]);
$this->addDepartmentLangs($request, $department);
$request->file('image')->move('images/', $request->file('image')->getClientOriginalName());
if (!File::exists('papers/' . $department->keyword)) {
File::makeDirectory('papers/' . $department->keyword);
}
Cache::forget('departments');
});
return redirect(action('Admin\\DepartmentController@index'))->with('success', 'saved');
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
Department::create($request->input());
foreach (BusinessPlan::lists('id') as $bid) {
$newGoal = new Goat();
$newGoal->type = 'G';
$newGoal->parent_id = null;
$newGoal->description = $request['name'] . " Goals";
$newGoal->priority = 0;
$newGoal->complete = false;
$newGoal->goal_type = 'D';
$newGoal->due_date = null;
$newGoal->budget = 0;
$newGoal->bid = $bid;
$newGoal->save();
}
return redirect('admin/depts');
}
示例13: addDepartment
/**
* Add a department
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function addDepartment(Request $request)
{
$dCode = $request['dCode'];
$dName = $request['dName'];
Department::create(['dCode' => $dCode, 'dName' => $dName]);
return redirect()->back()->with('status', 'Success');
}
示例14: store
public function store(DepartmentRequest $request, Department $department)
{
$department->create($request->all());
return redirect('/configuration#department')->withSuccess(config('constants.ADDED'));
}
示例15: store
/**
* Store a newly created department in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(SaveDepartmentRequest $request)
{
Department::create(['code' => $request->code, 'name' => $request->name]);
$departments = Department::all();
return view('layouts.viewDepartments', ['departments' => $departments]);
}