本文整理汇总了PHP中app\models\Project::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::save方法的具体用法?PHP Project::save怎么用?PHP Project::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Project
的用法示例。
在下文中一共展示了Project::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Project model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Project();
if ($model->load(Yii::$app->request->post())) {
$model->status = R::PROJECT_CREATED;
$model->deadline = date('Y-m-d', strtotime($model->deadline));
$model->create_time = time();
$model->update_time = time();
$model->save();
if (isset($_POST['stage_name'])) {
$stage_name = $_POST['stage_name'];
$stage_description = $_POST['stage_description'];
$stage_deadline = $_POST['stage_deadline'];
$stage_who = $_POST['stage_who'];
foreach ($stage_name as $k => $v) {
$stage = new Stage();
$stage->name = $v;
$stage->description = $stage_description[$k];
$stage->deadline = strtotime($stage_deadline[$k]);
$stage->user_id = $stage_who[$k];
$stage->project_id = $model->id;
$stage->status = R::STAGE_CREATED;
$stage->create_time = time();
$stage->update_time = time();
$stage->save();
}
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例2: actionCreate
public function actionCreate()
{
$project = new Project();
if ($project->load(Yii::$app->request->post()) && $project->save()) {
Yii::$app->getSession()->setFlash("success", 'The record was saved.');
return $this->redirect(["project/"]);
}
return $this->render("create", ["models" => ["project" => $project]]);
}
示例3: actionCreate
/**
* Creates a new Project model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Project();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: addProject
public function addProject(array $input)
{
$project = new Project();
$project->fill($input);
$project->save();
$this->linkToCurrentUser($project, $input);
$this->linkToFaculty($project, $input);
$this->linkToDraftStatus($project, $input);
return $project;
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$firstCondition = new Condition(['type' => 'if', 'field' => 'event.type', 'operator' => '==', 'value' => 'push']);
$firstCondition->save();
$splitter = new Splitter();
$splitter->save();
$firstSplit = new Split();
$firstSplit->save();
$secondSplit = new Split();
$secondSplit->save();
$secondCondition = new Condition(['type' => 'contains', 'field' => '', 'operator' => '==', 'value' => '']);
$secondCondition->save();
$firstAction = new Action(['type' => 'ssh']);
$host = new Host(['host' => 'ssh', 'port' => '22']);
$auth = new Auth();
$accountAuth = new AuthAccount();
$accountAuth->username = getenv('SSH_USERNAME');
$accountAuth->password = getenv('SSH_PASSWORD');
$accountAuth->save();
try {
$file = new File();
$keyAuth = new AuthKey();
$keyAuth->username = 'root';
$keyAuth->key = $file->get('.docker/builds/ssh/ssh_keys/id_rsa');
$keyAuth->key_public = $file->get('.docker/builds/ssh/ssh_keys/id_rsa.pub');
$keyAuth->save();
} catch (Illuminate\Filesystem\FileNotFoundException $exception) {
dump("SSH Key Not Found");
}
$auth->credentials()->associate($keyAuth);
$auth->save();
$host->auth()->associate($auth);
$host->save();
$firstAction->host()->associate($host);
$firstAction->save();
$firstAction->addCommand('touch testing');
$firstAction->addCommand('ls');
$secondAction = new Action();
$secondAction->save();
$secondAction->addCommand('composer install');
$secondCondition->successPipeable()->associate($secondAction)->save();
$firstSplit->pipeable()->associate($secondCondition);
$secondSplit->pipeable()->associate($firstAction);
$splitter->splits()->save($firstSplit);
$splitter->splits()->save($secondSplit);
$firstCondition->successPipeable()->associate($splitter)->save();
$project = new Project();
$project->name = 'example';
$project->group = 'exampleGroup';
$project->url = 'http://localhost/exampleGroup/example';
$project->project_id = 2;
$project->save();
$project->conditions()->save($firstCondition);
}
示例6: actionCreate
public function actionCreate()
{
if (\Yii::$app->user->isGuest) {
throw new ForbiddenHttpException('Access denied');
}
$model = new Project();
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['/project/view', 'id' => $model->getPrimaryKey()]);
}
return $this->render('create', ['model' => $model]);
}
示例7: actionCreateproject
public function actionCreateproject()
{
$projectModel = new Project();
$projectModel->attributes = $_POST['Project'];
$projectModel->startDate = date('Y-m-d', strtotime($_POST['Project']['startDate']));
$projectModel->endDate = date('Y-m-d', strtotime($_POST['Project']['endDate']));
$projectModel->delayedDeliveryDate = date('Y-m-d', strtotime($_POST['Project']['delayedDeliveryDate']));
if ($projectModel->save()) {
Yii::$app->getSession()->setFlash('success', 'Project has been added successfully');
return $this->redirect(['index']);
}
}
示例8: 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|unique:projects|max:255', 'description' => 'required', 'project_type_id' => 'required', 'image' => 'required']);
$image = ImageuploadFacade::upload($request->file('image'));
$project = new Project();
$project->name = $request->input('name');
$project->description = $request->input('description');
$project->client = $request->input('client');
$project->image = $image['basename'];
$project->image_ext = $image['original_extension'];
$project->project_type_id = $request->input('project_type_id');
$project->save();
return back();
}
示例9: createProject
/**
*
* @param $payer_email
* @param $description
* @param $rate
* @return Project
*/
public function createProject($payer_email, $description, $rate)
{
$project = new Project(['description' => $description, 'rate_per_hour' => $rate]);
// @TODO Check if the user was added as payer before!! :)
$payer = User::whereEmail($payer_email)->firstOrFail();
$payee = Auth::user();
$project->payer()->associate($payer);
$project->payee()->associate($payee);
$project->save();
//Pusher
$pusher = new Pusher(env('PUSHER_PUBLIC_KEY'), env('PUSHER_SECRET_KEY'), env('PUSHER_APP_ID'));
$data = ['payee_id' => Auth::user()->id, 'payer_id' => $payer->id, 'project' => $project, 'message' => Auth::user()->name . ' would like to start a new project with you, with the description \'' . $project->description . ',\' and at $' . $rate . '/hour. Is this ok?'];
$pusher->trigger('channel', 'insertProject', $data);
return $project;
}
示例10: store
public function store(CreateProjectRequest $request, Project $project)
{
//$obj = $project->create($request->all());
$project->user_id = $request->user_id;
$project->client_id = $request->clt_id;
$project->title = $request->title;
$project->slug = $request->slug;
$project->unit = $request->unit;
$project->tags = $request->tags;
$project->desc = $request->desc;
$project->authorized_users = $request->authorized_users;
$project->status = $request->status;
// dd($project->all());
$project->save();
return redirect()->route('projects.index');
}
示例11: actionCreate
/**
* Creates a new Project model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Project();
$user_id = User::find()->where("id=" . Yii::$app->user->id)->one()->id;
$manager_id = ProjectManager::find()->where("user_id=" . $user_id)->one()->id;
$model->manager_id = $manager_id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$vacancyValue = $_POST['Project']['vacancy'];
$newVacancy = new ProjectVacancy();
$newVacancy->project_id = $model->id;
$newVacancy->vacancy = $vacancyValue;
$newVacancy->save();
$degreesList = $_POST['Project']['degrees1'];
foreach ($degreesList as $value) {
$this->createStudentProfile($model->id, $value);
}
Yii::$app->getSession()->setFlash('success', 'El proyecto se ha creado exitosamente');
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例12: postUpdateproject
public function postUpdateproject(ProjectFormRequest $request)
{
$step = $request->get('step');
$secret_key = $request->get('_secret_key_');
if (empty($secret_key)) {
$project = new Project();
$project->fill($request->except('_token'));
$project->user_id = $request->input('user_id');
$project->slug = Str::slug($request->input('name'));
# Attach file with project
if ($request->hasFile('file_attachment')) {
$response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth]));
if (count($response) > 0) {
$project->file_attachment = $response[0];
}
}
# Attach file with project : End
if ($project->save()) {
$auto_id = $project->id;
//$secret_id = Crypt::encrypt($auto_id);
$request->session()->flash('alert-success', 'Project has been updated successfully');
$step = $step + 1;
Session::put('editfstep', $step);
Session::put('editfs_id', $auto_id);
return \Redirect::to('/project/projectedit');
} else {
Session::put('editfstep', $step);
$request->session()->flash('alert-warning', 'Error on project creation ! ');
return redirect()->back()->withInput();
}
} else {
$project_id = $secret_key;
if ($step == 1) {
$project = Project::find($project_id);
$project->fill($request->except('_token'));
$project->slug = Str::slug($request->input('name'));
if ($request->hasFile('file_attachment')) {
$response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth]));
if (count($response) > 0) {
$project->file_attachment = $response[0];
}
}
if ($project->save()) {
$request->session()->flash('alert-success', 'Project has been updated successfully');
$step = $step + 1;
Session::put('editfstep', $step);
return \Redirect::to('/project/projectedit');
}
}
if ($step == 2) {
$projectData = array();
$projectData['details_description'] = $request->get('details_description');
$projectData['address'] = $request->get('address');
$projectData['address_alternate'] = $request->get('address_alternate');
$projectData['city'] = $request->get('city');
$projectData['state'] = $request->get('state');
$projectData['country_id'] = $request->get('country_id');
$projectData['feed_url'] = $request->get('feed_url');
$projectData['pincode'] = $request->get('pincode');
$projectData['external_video_url'] = $request->get('external_video_url');
//$projectData['media_file_attachment'] = $request->get('media_file_attachment');
$projectData['media_file_short_note'] = $request->get('media_file_short_note');
if ($request->hasFile('media_file_attachment')) {
$response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'media_file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth]));
if (count($response) > 0) {
$projectData['media_file_attachment'] = $response[0];
}
}
if (Project::where('id', $project_id)->update($projectData)) {
$request->session()->flash('alert-success', 'Project has been updated successfully');
$step = $step + 1;
Session::put('editfstep', $step);
return \Redirect::to('/project/projectedit');
} else {
Session::put('editfstep', $step);
$request->session()->flash('alert-warning', 'Error on project creation ! ');
return redirect()->back()->withInput();
}
}
if ($step == 3) {
$projectData = array();
//dd( $request->all());
$reward_row_count = $request->get('reward_row_count');
$past_row_count = $request->get('past_row_count');
$pledge_amount = $request->get('pledge_amount');
$short_note = $request->get('short_note');
$user_limit = $request->get('user_limit');
$delevery_year = $request->get('delevery_year');
$delevery_month = $request->get('delevery_month');
$shipping_details = $request->get('shipping_details');
$present_id = $request->get('editid');
$file = $request->file('file_attachment');
$startcounter = $past_row_count + 1;
$endcounter = $reward_row_count - 1;
if (count($pledge_amount) > 0) {
$rewardsData = array();
for ($k = 0; $k <= $past_row_count; $k++) {
/* $reward = new Reward(); */
$rewaedid = $present_id[$k];
$reward = Reward::find($rewaedid);
//.........这里部分代码省略.........
示例13: store
public function store(array $input)
{
$project = new Project();
$project->fill($input);
$project->save();
$this->linkToFaculty($project, $input);
$this->linkToStatus($project, $input);
$this->linkToUser($project, $input);
return $project;
}
示例14: store
public function store($request)
{
$project = new Project();
$project->fill($request);
$project->save();
/**
* Membros
*/
foreach ($request['members'] as $user_id) {
$user = User::find($user_id);
$project->members()->save($user);
}
/**
* Categorias
*/
foreach ($request['categories'] as $category_id) {
$category = Category::find($category_id);
$project->categories()->save($category);
}
return $project;
}
示例15: make
/**
* Return a fresh instance of the model (called on `create()`).
*
* @return \Illuminate\Database\Eloquent\Model
*/
protected function make()
{
$model = new Project();
$model->save();
return $model;
}