public function fileConvertAndUpdate() { $dir = "../files/"; $num = 0; $documents_group = scandir($dir); foreach ($documents_group as $key => $value) { if ($value != "." && $value != "..") { $handler = new handler($dir, $value); if ($handler->getFileType() != NULL) { try { $document = Document::create(array('path' => $handler->getPath(), 'fileName' => $handler->getFileName(), 'fileType' => $handler->getFileType(), 'systemName' => $handler->getSystemName(), 'airlineName' => $handler->getAirlineName(), 'ticketNumber' => $handler->getTicketNumber(), 'dateString' => $handler->getDateString(), 'orderOfDay' => $handler->getOrderOfDay(), 'fileContent' => $handler->getFileContent(), 'dateOfFile' => $handler->getDateOfFile(), 'paxName' => $handler->getPaxName(), 'rloc' => $handler->getRloc(), 'ticketsType' => $handler->getTicketsType())); $document->save(); $num++; rename($dir . $value, "../done/" . $value); } catch (Exception $e) { $response['info'] = "fail"; $boolean = false; echo $e; } } } } //echo $num." files have been converted."; die; return $num; }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Document::create([]); } }
public function run() { $faker = Faker::create(); $array = array(['path' => 'uploads/documents/dummy.pdf', 'documentable_id' => '1', 'documentable_type' => 'page'], ['path' => 'uploads/documents/dummy.pdf', 'documentable_id' => '1', 'documentable_type' => 'page']); foreach ($array as $item) { Document::create($item); } }
public function postAdd() { $document = Document::create(Input::all()); $document->user_id = Auth::user()->id; $user = User::find($document->user_id); $organization = User::find($document->user_id)->organization(); $user->organization->last_document_number++; $user->organization->save(); $document->document_number = $user->organization->last_document_number; $document->save(); return Redirect::action('DocumentsController@getView', [$document->id]); }
/** * Store a newly created document in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Document::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } if (Input::hasFile('file')) { $uploaded_file = Input::file('file'); $extension = $uploaded_file->getClientOriginalExtension(); $filename = Input::get('name') . '.' . $extension; $destinationPath = public_path() . DIRECTORY_SEPARATOR . 'uploads/documents'; $uploaded_file->move($destinationPath, $filename); $data['file'] = $filename; Document::create($data); return Redirect::route('admin.documents.index')->with("successMessage", "Dokumen berhasil ditambahkan"); } }
public function run() { DB::table('documents')->delete(); Document::create(array('title' => 'AGM 2015 Agenda', 'type' => 'meeting', 'filename' => 'agm-2015-agenda', 'filetype' => 'pdf', 'owner' => 'Laurie Everest')); Document::create(array('title' => 'AGM 2014 Minutes', 'type' => 'meeting', 'filename' => 'agm-2014-minutes', 'filetype' => 'pdf', 'owner' => 'Laurie Everest')); }
public function __construct() { $this->group = static::getGroup(); // обращается к статичному методу дочернего класса } public static function create() { return new static(); // создаёт обьект доченего класса } static function getGroup() { return "default"; } } class User extends DomainObject { } class Document extends DomainObject { static function getGroup() { return "document"; } } class SpreadSheet extends Document { } var_dump(User::create()); var_dump(Document::create()); var_dump(SpreadSheet::create());
} else { $assignees = array(); } if (!in_array($_POST['assign'], $assignees)) { $assignees[] = $_POST['assign']; } for ($i = 0; $i < count($assignees); $i++) { echo (new User($assignees[$i]))->getName(); if ($i != count($assignees) - 1) { echo ', '; } } } else { if ($do == 'create') { extract($_POST); $document = Document::create($subject, $body, $clearance, $prefix, $_SESSION['user']->getID(), $assignees); /* Mail the new assignees */ $ids = explode(',', $assignees); $users = array(); for ($i = 0; $i < count($ids); $i++) { $users[] = new User($ids[$i]); } $message = 'You have been assigned to document <b>' . $document->getPrefix()->getPrefixAbbrev() . $document->getID() . '</b> by <b><i>' . $_SESSION['user']->getName() . '</i></b><br />'; $message .= 'Login to <a href="http://irin.eotir.com">IRIN</a> to look at the document.'; $subject = 'Document Assignment'; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= "From: IR Information Network <*****@*****.**>" . "\r\n"; foreach ($users as $user) { if (!in_array($user, $document->getAssignees())) { $to = $user->getEmail();
<?php Route::get('documents/create', function () { if (!($user = Auth::user())) { return array('error' => 'You must be logged in to create a document.'); } $input = Input::all(); $rules = array('snippet_id' => 'required|exists:snippets,id', 'title' => 'required|max:255', 'syntax' => 'alpha', 'data' => 'required'); $validated = Validator::make($input, $rules); if ($validated->fails()) { return array('error' => $validated->errors); } $snippet = Snippet::get($input['snippet_id']); if (isset($snippet->documents[$input['title']])) { return array('error' => array('title' => 'This snippet already has a document of that name')); } if (!isset($input['syntax'])) { $input['syntax'] = substr($input['title'], strpos($input['title'], '.') + 1); } if ($id = Document::create($input['snippet_id'], $input)) { return Redirect::to('documents/' . $id); } });
<?php abstract class DomainObject { public static function create() { return new static(); } } class User extends DomainObject { } class Document extends DomainObject { } print_r(Document::create());
$document = Document::fromDatabase($_POST['documentID']); Snapshot::create($document, json_decode(stripslashes($_POST['documentData']), true), $_POST['timestamp']); break; case 'loadSnapshot': $document = Document::fromDatabase($_POST['documentID']); echo json_encode(Snapshot::getData($document, $_POST['snapshotID'])); break; case 'deleteDocument': $document = Document::fromDatabase($_POST['id']); $document->delete(); break; case 'loadDocuments': echo json_encode(Document::getList(Document::FORMAT_JSON)); break; case 'createDocument': $document = Document::create($_POST['name']); echo $document->getId(); break; case 'renameDocument': $document = Document::fromDatabase($_POST['id']); $document->rename($_POST['newname']); break; case 'copyDocument': $document = Document::fromDatabase($_POST['id']); $newdoc = $document->copy($_POST['copyname']); echo json_encode($newdoc->toJSON()); break; case 'exportDocument': $document = Document::fromDatabase($_POST['id']); header("Content-Type: text/plain"); header("Content-Disposition: attachment; filename=\"" . $document->getName() . ".vonline\"");
<?php abstract class DomainObject { } class User extends DomainObject { public static function create() { return new User(); } } class Document extends DomainObject { public static function create() { return new Document(); } } $document = Document::create(); print_r($document);
function ajax_add($project_id = null) { $this->Email->from = "*****@*****.**"; $this->set("current", "assign"); $this->set('closeModalbox', false); if (!empty($this->data)) { $this->Task->create(); $this->data['Task']['creator_id'] = $this->currentUser['id']; if ($this->Task->save($this->data)) { $user = new User(); $user->recursive = 0; $assigned = $user->findById($this->data['Task']['user_id']); $this->Email->from = "*****@*****.**"; $this->Email->to = $assigned['User']['email']; $this->Email->subject = "JAVAN : You are Assigned a Task"; $this->Email->send("You are assigned task {$this->data['Task']['name']} : {$this->data['Task']['description']}. Please login to for more information http://internal.javan.web.id/"); $this->Session->setFlash(__('The Task has been saved', true)); if (!$this->RequestHandler->isAjax()) { // redirect back to index page $this->redirect($this->referer()); } if (isset($this->data['files'])) { mkdir(WWW_ROOT . 'files/tasks/' . $this->Task->id); $doc = new Document(); foreach ($this->data['files'] as $file) { $doc->create(); $path = WWW_ROOT . 'files/tasks/' . $this->Task->id . '/' . $file; rename(WWW_ROOT . 'files/tmp/' . $file, $path); $d['Document']['task_id'] = $this->Task->id; $d['Document']['filename'] = $file; $d['Document']['fullpath'] = $path; $doc->save($d); } } // else $this->set('closeModalbox', true); } else { $this->Session->setFlash(__('The Task could not be saved. Please, try again.', true)); } } if ($project_id) { $this->Task->Project->recursive = 0; $project = $this->Task->Project->read(null, $project_id); $this->set("project", $project); $this->set("project_id", $project_id); } $users = $this->Task->User->find('list', array('conditions' => array('User.id !=' => $this->currentUser['id']))); $projects = $this->Task->Project->find('list'); $this->set(compact('users', 'projects')); }
<?php abstract class DomainObject { public static function create() { return new self(); } } class User extends DomainObject { } class Document extends DomainObject { } Document::create();
/** * @param array $attributes */ public function loadRelated(array $attributes) { parent::loadRelated($attributes); if (isset($attributes['from'])) { $this->from = User::create($attributes['from']); } if (isset($attributes['chat'])) { $this->chat = isset($attributes['chat']->title) ? GroupChat::create($attributes['chat']) : User::create($attributes['chat']); } if (isset($attributes['forward_from'])) { $this->forward_from = User::create($attributes['forward_from']); } if (isset($attributes['forward_from_chat'])) { $this->forward_from_chat = Chat::create($attributes['forward_from_chat']); } if (isset($attributes['reply_to_message'])) { $this->reply_to_message = Message::create($attributes['reply_to_message']); } if (isset($attributes['entities'])) { $this->entities = array_map(function ($entity) { return MessageEntity::create($entity); }, $attributes['entities']); } if (isset($attributes['audio'])) { $this->audio = Audio::create($attributes['audio']); } if (isset($attributes['document'])) { $this->document = Document::create($attributes['document']); } if (isset($attributes['photo'])) { $this->photo = array_map(function ($photo) { return PhotoSize::create($photo); }, $attributes['photo']); } if (isset($attributes['sticker'])) { $this->sticker = Sticker::create($attributes['sticker']); } if (isset($attributes['video'])) { $this->video = Video::create($attributes['video']); } if (isset($attributes['voice'])) { $this->voice = Voice::create($attributes['voice']); } if (isset($attributes['contact'])) { $this->contact = Contact::create($attributes['contact']); } if (isset($attributes['location'])) { $this->location = Location::create($attributes['location']); } if (isset($attributes['venue'])) { $this->venue = Venue::create($attributes['venue']); } if (isset($attributes['new_chat_member'])) { $this->new_chat_member = User::create($attributes['new_chat_member']); } if (isset($attributes['left_chat_member'])) { $this->left_chat_member = new User($attributes['left_chat_member']); } if (isset($attributes['new_chat_photo'])) { $this->new_chat_photo = array_map(function ($photo) { return PhotoSize::create($photo); }, $attributes['new_chat_photo']); } }
/** * @param \Elastica\Document|array $data * * @return $this */ public function setUpsert($data) { $document = Document::create($data); $this->_upsert = $document; return $this; }
public function run() { Document::create(array('id' => 1, 'name' => 'Default')); }