本文整理汇总了PHP中app\models\Project::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::create方法的具体用法?PHP Project::create怎么用?PHP Project::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Project
的用法示例。
在下文中一共展示了Project::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$input = Request::all();
$input['user_id'] = Auth::User()->id;
$validation = Project::validate($input);
if ($validation->fails()) {
$message = $validation->messages()->first();
return Response()->json(ResponseManager::getError('', 10, $message));
}
$project = Project::create($input);
if ($project) {
// if (array_key_exists('users', $input)) {
// foreach ($input['users'] as $user) {
// $data = ['project_id' => $project['id'], 'user_id' => $user['id'], 'email' => $user['email']];
// ProjectUser::create($data);
// $email['email'] = $user['email'];
// $email['user'] = $user['name'];
// $email['msg'] = $input['message'];
// $email['pname'] = $project['name'];
// $email['code'] = base64_encode($email['email'] . '-' . $project['id']);
// Mail::send('emails.invite', $email, function( $message ) use ($email) {
// $message->to($email['email'])->subject(Auth::User()->name . ' want to add you to ' . $email['pname']);
// });
// }
// }
$message = 'Added Successfully.';
return Response()->json(ResponseManager::getResult($project, 10, $message));
} else {
$message = 'Something went wrong. Please try again.';
return Response()->json(ResponseManager::getError('', 10, $message));
}
}
示例2: store
/**
* Store a newly created resource in storage.
* POST /projects
*
* @return Response
*/
public function store($society, ProjectsRequest $request)
{
$project = Project::create($request->all());
$project->society_id = $society;
$project->save();
return Redirect::route('society.projects.edit', array($society, $project->id))->with('okmessage', 'New project has been added');
}
示例3: 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, $this->rules);
$input = $this->filter_project_input();
$project = Project::create($input);
return Redirect::route('projects.show', $project->slug)->with('flash_success', 'Projeto criado ');
}
示例4: run
public function run()
{
DB::table('projects')->delete();
$collection = [['project_types_id' => 1, 'project_statuses_id' => 4, 'disassemblers_id' => 1, 'creator_id' => 2, 'company_id' => 5, 'directory_path' => 'starfleet_academy/2015/37833_N195UA/', 'sales_id' => 7, 'project_start_date' => '2015-12-07', 'asset_arrival_date' => '2015-12-25', 'projected_completion_date' => '2016-01-10'], ['project_types_id' => 1, 'project_statuses_id' => 4, 'disassemblers_id' => 1, 'creator_id' => 2, 'directory_path' => 'starfleet_academy/2015/', 'company_id' => 5, 'sales_id' => 7, 'project_start_date' => '2015-12-07', 'asset_arrival_date' => '2015-12-25', 'projected_completion_date' => '2016-01-10'], ['project_types_id' => 1, 'project_statuses_id' => 3, 'disassemblers_id' => 1, 'creator_id' => 2, 'directory_path' => 'starfleet_academy/2015/', 'company_id' => 5, 'sales_id' => 7, 'project_start_date' => '2015-12-07', 'asset_arrival_date' => '2015-12-25', 'projected_completion_date' => '2016-01-10'], ['project_types_id' => 1, 'project_statuses_id' => 2, 'disassemblers_id' => 1, 'creator_id' => 2, 'directory_path' => 'starfleet_academy/2015/', 'company_id' => 5, 'sales_id' => 7, 'project_start_date' => '2015-12-07', 'asset_arrival_date' => '2015-12-25', 'projected_completion_date' => '2016-01-10'], ['project_types_id' => 1, 'project_statuses_id' => 1, 'disassemblers_id' => 1, 'creator_id' => 2, 'directory_path' => 'starfleet_academy/2015/', 'company_id' => 5, 'sales_id' => 7, 'project_start_date' => '2015-12-07', 'asset_arrival_date' => '2015-12-25', 'projected_completion_date' => '2016-01-10']];
foreach ($collection as $record) {
Project::create($record);
}
}
示例5: createProject
protected function createProject()
{
$bSuccess = Project::create(['projectName' => $this->request->name, 'description' => $this->request->desc, 'userId' => Auth::user()->id, 'status' => 'open']);
if ($bSuccess) {
$oProject = ['oProject' => Project::getProject(), 'message' => 'Project successfully created.'];
return response()->json($oProject);
}
}
示例6: create
protected function create($values)
{
$data = [];
foreach ($this->structure as $i => $key) {
$data[$key] = $values[$i];
}
Project::create($data);
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$img = $request->input('project');
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$img = base64_decode($img);
$url = 'assets/projects/projects' . time() . '.png';
file_put_contents($url, $img);
$project = Project::create(['url' => $url, 'user_id' => \Auth::user()->id]);
}
示例8: update
public function update($id)
{
// save updated
$record = $this->records->find($id);
if (!$record) {
Project::create(Input::all());
return $this->respond($record);
}
$record->fill(Input::all())->save();
return $this->respond($record);
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->middleware('auth');
if ($user = auth()->user()) {
$this->validate($request, $this->rules);
$input = $this->filter_project_input();
$input['slug'] = $this->makeSlugFromTitle($input['name']);
$project = Project::create($input);
$project->members()->attach($user->id, ['role' => 'owner']);
return Redirect::route('projects.show', $project->slug)->with('flash_success', 'Projeto criado.');
} else {
return Redirect::route('home')->with('flash_danger', 'Operação não permitida.');
}
}
示例10: add
public function add()
{
$data = Input::all();
unset($data['_token']);
$rules = array('name' => 'required|min:5|max:30', 'key' => 'required|min:16|max:255', 'ip' => 'required|min:7|max:255', 'manage' => 'required|min:5|max:30|exists:users,username', 'description' => 'sometimes|max:255', 'star_switch' => 'required|Integer', 'edit_switch' => 'required|Integer', 'quote_switch' => 'required|Integer', 'level_top_num' => 'required_if:quote_switch,1|Integer', 'level_bot_num' => 'required_if:quote_switch,1|Integer', 'page_num' => 'required|Integer', 'status' => 'required|Integer');
$valid = Validator::make($data, $rules);
if ($valid->fails()) {
return Redirect::to('msg')->withInput()->with('jump_sec', 3)->withErrors($valid);
} else {
$p = new Project();
$ok = $p->create($data);
return Redirect::to('msg')->withInput()->with('jump_sec', 3)->with('jump_url', URL::to('admin/project_list'))->with('message', "id: {$ok->id} name: {$ok->name} 添加成功!");
}
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['name' => 'required', 'status' => 'required|in:draft,accepted,pending,refused,command,billing', 'quotation_price' => 'integer', 'quotation_date' => 'date', 'customer_id' => 'required|integer']);
if ($validator->fails()) {
return response()->json($validator->errors()->all(), 400);
}
try {
$customer = Customer::findOrFail($request->input('customer_id'));
} catch (Exception $e) {
return response()->json('Le client n\'existe pas.', 404);
}
$project = Project::create(['name' => $request->get('name'), 'status' => $request->get('status'), 'quotation_price' => $request->get('quotation_price'), 'quotation_date' => $request->get('quotation_date'), 'customer_id' => $request->get('customer_id'), 'user_id' => Auth::user()->id]);
return $project;
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
//测试运行逻辑是否成功
/*$data = $request->all();
return $data;*/
//判断是否登陆
if (Auth::guest()) {
return redirect('/auth/login');
}
$default = array('status' => '1', 'img_url' => '/image/project_img/project_item.jpg');
$date = $request->all() + $default;
//dd($date);//测试数据正确性
Project::create($date);
return redirect('/feature/project');
//
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(ProjectRequest $request)
{
$input = $request->except($this->image);
$input['start_date'] = Carbon\Carbon::parse($request->get('start_date'))->format('Y-m-d');
$input['end_date'] = Carbon\Carbon::parse($request->get('end_date'))->format('Y-m-d');
$input[$this->image] = Project::upload_projectfile($request, $this->image);
$input['added_by'] = Auth::user()->id;
$project = Project::create($input);
$timeline['object_type'] = 1;
$timeline['object_id'] = $project->id;
$timeline['action'] = 'create';
$timeline['description'] = '<a href="javascript:;">' . $input['name'] . '</a> project has been created by ' . Auth::user()->first_name . ' ' . Auth::user()->last_name . '.';
Timeline::create($timeline);
Session::flash($this->success, Lang::get('ruban.project.created'));
return Redirect::route('ruban.projects.index');
}
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Project::truncate();
Timer::truncate();
$faker = Faker::create();
$john = User::where('name', 'John')->first();
$payee_john = Payee::find($john->id);
$payer_john = Payer::find($john->id);
$jenny = User::where('name', 'Jenny')->first();
$jane = User::where('name', 'Jane')->first();
$bob = User::where('name', 'Bob')->first();
$payee_bob = Payee::find($bob->id);
/**
* John is payee
*/
// dd($faker->randomElement([1,2,3]));
// dd($faker->randomElement($payee_john->payers()->lists('id')));
// dd($payee_john->payers()->lists('id')->all());
foreach (range(0, 2) as $index) {
$project = Project::create(['payee_id' => $john->id, 'payer_id' => $faker->randomElement($payee_john->payers()->lists('id')->all()), 'description' => $faker->word, 'rate_per_hour' => 40, 'status' => 'confirmed']);
$this->createTimersForProject($project);
}
//Create a project with Jenny as payer
$project = Project::create(['payee_id' => $john->id, 'payer_id' => $jenny->id, 'description' => $faker->word, 'rate_per_hour' => 40, 'status' => 'confirmed']);
$this->createTimersForProject($project);
/**
* John is payer
*/
foreach (range(0, 2) as $index) {
$project = Project::create(['payee_id' => $faker->randomElement($payer_john->payees()->lists('id')->all()), 'payer_id' => $john->id, 'description' => $faker->word, 'rate_per_hour' => 1, 'status' => 'confirmed']);
$this->createTimersForProject($project);
}
/**
* Bob is payee
*/
foreach (range(0, 4) as $index) {
$project = Project::create(['payee_id' => $bob->id, 'payer_id' => $jenny->id, 'description' => $faker->word, 'rate_per_hour' => 40, 'status' => 'confirmed']);
$this->createTimersForProject($project);
}
/**
* Jenny is payee
*/
foreach (range(0, 2) as $index) {
$project = Project::create(['payee_id' => $jenny->id, 'payer_id' => $john->id, 'description' => $faker->word, 'rate_per_hour' => 10, 'status' => 'confirmed']);
$this->createTimersForProject($project);
}
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(ProjectsRequest $request)
{
$project = Project::create($request->except('tags'));
$project->tags = implode(',', $request->input('tags'));
$project->user_id = Auth::user()->id;
if ($request->file('photo')) {
$fileName = $project->id . "." . $request->file('photo')->getClientOriginalExtension();
$request->file('photo')->move(base_path() . '/storage/app/images/', $fileName);
$project->photo = '/storage/app/images/' . $fileName;
$img = Image::make(base_path() . $project->photo);
$img->resize(250, null, function ($constraint) {
$constraint->aspectRatio();
});
$img->save(base_path() . '/storage/app/images/' . $fileName);
}
$project->save();
return redirect()->route('projects.index');
}