本文整理匯總了PHP中Illuminate\Support\Facades\File::move方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::move方法的具體用法?PHP File::move怎麽用?PHP File::move使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\File
的用法示例。
在下文中一共展示了File::move方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getRename
/**
* @return string
*/
public function getRename()
{
$old_name = Input::get('file');
$new_name = Input::get('new_name');
$file_path = parent::getPath('directory');
$thumb_path = parent::getPath('thumb');
$old_file = $file_path . $old_name;
if (!File::isDirectory($old_file)) {
$extension = File::extension($old_file);
$new_name = str_replace('.' . $extension, '', $new_name) . '.' . $extension;
}
$new_file = $file_path . $new_name;
if (File::exists($new_file)) {
return Lang::get('laravel-filemanager::lfm.error-rename');
}
if (File::isDirectory($old_file)) {
File::move($old_file, $new_file);
return 'OK';
}
File::move($old_file, $new_file);
if ('Images' === $this->file_type) {
File::move($thumb_path . $old_name, $thumb_path . $new_name);
}
return 'OK';
}
示例2: getRename
/**
* @return string
*/
public function getRename()
{
$old_name = Input::get('file');
$new_name = trim(Input::get('new_name'));
$file_path = parent::getPath('directory');
$thumb_path = parent::getPath('thumb');
$old_file = $file_path . $old_name;
if (!File::isDirectory($old_file)) {
$extension = File::extension($old_file);
$new_name = str_replace('.' . $extension, '', $new_name) . '.' . $extension;
}
$new_file = $file_path . $new_name;
if (Config::get('lfm.alphanumeric_directory') && preg_match('/[^\\w-]/i', $new_name)) {
return Lang::get('laravel-filemanager::lfm.error-folder-alnum');
} elseif (File::exists($new_file)) {
return Lang::get('laravel-filemanager::lfm.error-rename');
}
if (File::isDirectory($old_file)) {
File::move($old_file, $new_file);
Event::fire(new FolderWasRenamed($old_file, $new_file));
return 'OK';
}
File::move($old_file, $new_file);
if ('Images' === $this->file_type) {
File::move($thumb_path . $old_name, $thumb_path . $new_name);
}
Event::fire(new ImageWasRenamed($old_file, $new_file));
return 'OK';
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param TemplateRequest $request
* @return Response
*/
public function store(TemplateRequest $request)
{
ini_set('max_execution_time', 0);
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
$file_path = storage_path('tmp/');
$orginal_name = $request->file('file')->getClientOriginalName();
if ($request->file('file')->move($file_path, $orginal_name)) {
Zipper::make($file_path . $orginal_name)->extractTo(storage_path('tmp'));
$template = (require_once storage_path('tmp/Template.php'));
$assets = File::move(storage_path('tmp/assets/' . $template['folder']), public_path('assets/' . $template['folder']));
$template_file = File::move(storage_path('tmp/' . $template['folder']), base_path('resources/views/' . $template['folder']));
if (!$assets || !$template_file) {
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
Flash::error('Tema Dosyası Yüklendi ama Dizinler Tasinamadi! Tüm İşlemleriniz İptal Edildi.');
return redirect()->route('admin.template.index');
}
$message = $this->template->create($template) ? ['success', 'Başarıyla Kaydedildi'] : ['error', 'Bir Hata Meydana Geldi ve Kaydedilemedi'];
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
Flash::$message[0]($message[1]);
if ($message[0] == "success") {
Logs::add('process', "Şablon Eklendi\n{$template['name']}");
} else {
Logs::add('errors', "Şablon Eklenemedi!");
}
return redirect()->route('admin.template.index');
}
}
示例4: fire
/**
* Execute the console command.
*/
public function fire()
{
$this->line('');
$this->info('Routes file: app/routes.php');
$message = 'This will rebuild routes.php with all of the packages that' . ' subscribe to the `toolbox.routes` event.';
$this->comment($message);
$this->line('');
if ($this->confirm('Proceed with the rebuild? [Yes|no]')) {
$this->line('');
$this->info('Backing up routes.php ...');
// Remove the last backup if it exists
if (File::exists('app/routes.bak.php')) {
File::delete('app/routes.bak.php');
}
// Back up the existing file
if (File::exists('app/routes.php')) {
File::move('app/routes.php', 'app/routes.bak.php');
}
// Generate new routes
$this->info('Generating routes...');
$routes = Event::fire('toolbox.routes');
// Save new file
$this->info('Saving new routes.php...');
if ($routes && !empty($routes)) {
$routes = $this->getHeader() . implode("\n", $routes);
File::put('app/routes.php', $routes);
$this->info('Process completed!');
} else {
$this->error('Nothing to save!');
}
// Done!
$this->line('');
}
}
示例5: setupLangDir
protected function setupLangDir()
{
$langDir = realpath(app_path() . '/../resources/lang');
if (File::exists("{$langDir}/en")) {
File::move("{$langDir}/en", "{$langDir}/en_GB");
}
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param TemplateRequest $request
* @return Response
*/
public function store(TemplateRequest $request)
{
ini_set('max_execution_time', 0);
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
$file_path = storage_path('tmp/');
$orginal_name = $request->file('file')->getClientOriginalName();
if ($request->file('file')->move($file_path, $orginal_name)) {
Zipper::make($file_path . $orginal_name)->extractTo(storage_path('tmp'));
$template = (require_once storage_path('tmp/Template.php'));
$assets = File::move(storage_path('tmp/assets/' . $template['folder']), public_path('assets/' . $template['folder']));
$template_file = File::move(storage_path('tmp/' . $template['folder']), base_path('resources/views/' . $template['folder']));
if (!$assets || !$template_file) {
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
Flash::error(trans('whole::http/controllers.templates_flash_1'));
return redirect()->route('admin.template.index');
}
$message = $this->template->create($template) ? ['success', trans('whole::http/controllers.templates_flash_2')] : ['error', trans('whole::http/controllers.templates_flash_3')];
File::delete(base_path('resources/views/Template.php'));
File::delete(storage_path('tmp/Template.php'));
File::deleteDirectory(storage_path('tmp/'));
Flash::$message[0]($message[1]);
if ($message[0] == "success") {
Logs::add('process', trans('whole::http/controllers.templates_log_1', ['name' => $template['name']]));
} else {
Logs::add('errors', trans('whole::http/controllers.templates_log_2'));
}
return redirect()->route('admin.template.index');
}
}
示例7: storeAttachment
public function storeAttachment()
{
$parameters = $this->request->route()->parameters();
$attachments = $this->request->input('attachments');
$attachmentsResponse = [];
foreach ($attachments as $attachment) {
$idAttachment = Attachment::max('id_016');
$idAttachment++;
// move file from temp file to attachment folder
File::move(public_path() . config($this->request->input('routesConfigFile') . '.tmpFolder') . '/' . $attachment['tmpFileName'], public_path() . config($this->request->input('routesConfigFile') . '.attachmentFolder') . '/' . $parameters['object'] . '/' . $parameters['lang'] . '/' . $attachment['fileName']);
$attachmentsResponse[] = Attachment::create(['id_016' => $idAttachment, 'lang_id_016' => $parameters['lang'], 'resource_id_016' => $this->request->input('resource'), 'object_id_016' => $parameters['object'], 'family_id_016' => null, 'library_id_016' => $attachment['library'], 'library_file_name_016' => $attachment['libraryFileName'], 'sorting_016' => null, 'name_016' => null, 'file_name_016' => $attachment['fileName'], 'mime_016' => $attachment['mime'], 'size_016' => filesize(public_path() . config($this->request->input('routesConfigFile') . '.attachmentFolder') . '/' . $parameters['object'] . '/' . $parameters['lang'] . '/' . $attachment['fileName']), 'type_id_016' => $attachment['type']['id'], 'type_text_016' => $attachment['type']['name'], 'width_016' => empty($attachment['width']) ? null : $attachment['width'], 'height_016' => empty($attachment['height']) ? null : $attachment['height'], 'data_016' => json_encode(['icon' => $attachment['type']['icon']])]);
}
$response = ['success' => true, 'attachments' => $attachmentsResponse];
return response()->json($response);
}
示例8: storeAttachments
/**
* Function to store attachment elements
*
* @access public
* @param \Illuminate\Support\Facades\Request $attachments
* @param string $lang
* @param string $routesConfigFile
* @param integer $objectId
* @param string $resource
* @return boolean
*/
public static function storeAttachments($attachments, $routesConfigFile, $resource, $objectId, $lang)
{
if (!File::exists(public_path() . config($routesConfigFile . '.attachmentFolder') . '/' . $objectId . '/' . $lang)) {
File::makeDirectory(public_path() . config($routesConfigFile . '.attachmentFolder') . '/' . $objectId . '/' . $lang, 0755, true);
}
foreach ($attachments as $attachment) {
$idAttachment = Attachment::max('id_016');
$idAttachment++;
$width = null;
$height = null;
if ($attachment->type->id == 1) {
list($width, $height) = getimagesize(public_path() . $attachment->folder . '/' . $attachment->tmpFileName);
}
// move file fom temp file to attachment folder
File::move(public_path() . $attachment->folder . '/' . $attachment->tmpFileName, public_path() . config($routesConfigFile . '.attachmentFolder') . '/' . $objectId . '/' . $lang . '/' . $attachment->fileName);
Attachment::create(['id_016' => $idAttachment, 'lang_id_016' => $lang, 'resource_id_016' => $resource, 'object_id_016' => $objectId, 'family_id_016' => empty($attachment->family) ? null : $attachment->family, 'library_id_016' => $attachment->library, 'library_file_name_016' => empty($attachment->libraryFileName) ? null : $attachment->libraryFileName, 'sorting_016' => $attachment->sorting, 'name_016' => empty($attachment->name) ? null : $attachment->name, 'file_name_016' => empty($attachment->fileName) ? null : $attachment->fileName, 'mime_016' => $attachment->mime, 'size_016' => filesize(public_path() . config($routesConfigFile . '.attachmentFolder') . '/' . $objectId . '/' . $lang . '/' . $attachment->fileName), 'type_id_016' => $attachment->type->id, 'type_text_016' => $attachment->type->name, 'width_016' => $width, 'height_016' => $height, 'data_016' => json_encode(['icon' => $attachment->type->icon])]);
}
}
示例9: getRename
/**
* @return string
*/
public function getRename()
{
$file_to_rename = Input::get('file');
$dir = Input::get('dir');
$new_name = Str::slug(Input::get('new_name'));
if ($dir == "/") {
if (File::exists(base_path() . "/" . $this->file_location . $new_name)) {
return "File name already in use!";
} else {
if (File::isDirectory(base_path() . "/" . $this->file_location . $file_to_rename)) {
File::move(base_path() . "/" . $this->file_location . $file_to_rename, base_path() . "/" . $this->file_location . $new_name);
return "OK";
} else {
$extension = File::extension(base_path() . "/" . $this->file_location . $file_to_rename);
$new_name = Str::slug(str_replace($extension, '', $new_name)) . "." . $extension;
File::move(base_path() . "/" . $this->file_location . $file_to_rename, base_path() . "/" . $this->file_location . $new_name);
if (Session::get('lfm_type') == "Images") {
// rename thumbnail
File::move(base_path() . "/" . $this->file_location . "thumbs/" . $file_to_rename, base_path() . "/" . $this->file_location . "thumbs/" . $new_name);
}
return "OK";
}
}
} else {
if (File::exists(base_path() . "/" . $this->file_location . $dir . "/" . $new_name)) {
return "File name already in use!";
} else {
if (File::isDirectory(base_path() . "/" . $this->file_location . $dir . "/" . $file_to_rename)) {
File::move(base_path() . "/" . $this->file_location . $dir . "/" . $file_to_rename, base_path() . "/" . $this->file_location . $dir . "/" . $new_name);
} else {
$extension = File::extension(base_path() . "/" . $this->file_location . $dir . "/" . $file_to_rename);
$new_name = Str::slug(str_replace($extension, '', $new_name)) . "." . $extension;
File::move(base_path() . "/" . $this->file_location . $dir . "/" . $file_to_rename, base_path() . "/" . $this->file_location . $dir . "/" . $new_name);
if (Session::get('lfm_type') == "Images") {
File::move(base_path() . "/" . $this->file_location . $dir . "/thumbs/" . $file_to_rename, base_path() . "/" . $this->file_location . $dir . "/thumbs/" . $new_name);
}
return "OK";
}
}
}
return true;
}
示例10: copyJumpstartAsset
/**
* @param string $sourceFile
* @param string $targetFile
* @param string $namespace
*/
private function copyJumpstartAsset($sourceFile, $targetFile, $namespace = 'App\\')
{
$fileName = basename($targetFile);
if ($this->shouldBackup && File::exists($targetFile)) {
$fileNameParts = explode('.', $fileName);
$newFileName = array_shift($fileNameParts) . '-original-' . Carbon::now('UTC')->format('Y-m-d_h:i:s') . '.' . implode('.', $fileNameParts);
File::move($targetFile, dirname($targetFile) . '/' . $newFileName);
$this->info("File '{$fileName}' already exists - renamed to '{$newFileName}'.");
} elseif (!File::exists(dirname($targetFile))) {
File::makeDirectory(dirname($targetFile), 0755, true, true);
}
if ($namespace == 'App\\') {
File::copy($sourceFile, $targetFile);
} else {
$sourceFileContent = File::get($sourceFile);
$targetFileContent = str_replace('namespace App\\', 'namespace ' . $namespace, $sourceFileContent);
File::put($targetFile, $targetFileContent);
}
$this->info("File '{$fileName}' copied.");
}
示例11: getRename
/**
* @return string
*/
function getRename()
{
$file_to_rename = Input::get('file');
$dir = Input::get('dir');
$new_name = Str::slug(Input::get('new_name'));
if ($dir == "/") {
if (File::exists(base_path() . "/" . Config::get('sfm.dir') . $new_name)) {
return Lang::get('filemanager::sfm.file_exists');
} else {
if (File::isDirectory(base_path() . "/" . Config::get('sfm.dir') . $file_to_rename)) {
File::move(base_path() . "/" . Config::get('sfm.dir') . $file_to_rename, base_path() . "/" . Config::get('sfm.dir') . $new_name);
return "OK";
} else {
$extension = File::extension(base_path() . "/" . Config::get('sfm.dir') . $file_to_rename);
$new_name = Str::slug(str_replace($extension, '', $new_name)) . "." . $extension;
if (@getimagesize(base_path() . "/" . Config::get('sfm.dir') . $file_to_rename)) {
// rename thumbnail
File::move(base_path() . "/" . Config::get('sfm.dir') . "/.thumbs/" . $file_to_rename, base_path() . "/" . Config::get('sfm.dir') . "/.thumbs/" . $new_name);
}
File::move(base_path() . "/" . Config::get('sfm.dir') . $file_to_rename, base_path() . "/" . Config::get('sfm.dir') . $new_name);
return "OK";
}
}
} else {
if (File::exists(base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $new_name)) {
return Lang::get('filemanager::sfm.file_exists');
} else {
if (File::isDirectory(base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $file_to_rename)) {
File::move(base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $file_to_rename, base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $new_name);
} else {
$extension = File::extension(base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $file_to_rename);
$new_name = Str::slug(str_replace($extension, '', $new_name)) . "." . $extension;
if (@getimagesize(base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $file_to_rename)) {
File::move(base_path() . "/" . Config::get('sfm.dir') . $dir . "/.thumbs/" . $file_to_rename, base_path() . "/" . Config::get('sfm.dir') . $dir . "/.thumbs/" . $new_name);
}
File::move(base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $file_to_rename, base_path() . "/" . Config::get('sfm.dir') . $dir . "/" . $new_name);
return "OK";
}
}
}
}
示例12: handle
/**
* Execute the command.
*/
public function handle()
{
$name = $this->argument('name');
$domain = $this->argument('domain');
$webExecution = $this->option('webExecution');
try {
$workingPath = base_path('../');
$outputFolder = strtolower(str_replace(' ', '-', $name . '-api'));
$this->writeStatus('Installing lumen and dependencies ...', $webExecution);
// Create project
(new Composer($workingPath))->createProject('laravel/lumen', '5.1.*', $outputFolder)->setWorkingPath($workingPath . $outputFolder)->requirePackage('dingo/api', '1.0.x@dev');
$this->writeStatus('Setting up lumen ...', $webExecution);
// Rename .env file
File::move($workingPath . $outputFolder . '/.env.example', $workingPath . $outputFolder . '/.env');
// Dingo config
File::append($workingPath . $outputFolder . '/.env', 'API_DOMAIN=' . $domain . PHP_EOL . 'API_STANDARDS_TREE=vnd' . PHP_EOL . 'API_SUBTYPE=' . strtolower(str_replace(' ', '', $name)) . PHP_EOL . 'API_VERSION=v1' . PHP_EOL . 'API_NAME="' . $name . '"' . PHP_EOL . 'API_CONDITIONAL_REQUEST=false' . PHP_EOL . 'API_STRICT=false' . PHP_EOL . 'API_DEFAULT_FORMAT=json' . PHP_EOL . 'API_DEBUG=true');
// Get lumen app file
$lumenAppFile = File::get($workingPath . $outputFolder . '/bootstrap/app.php');
// Get .env file
$lumenEnvFile = File::get($workingPath . $outputFolder . '/.env');
// Enable Dotenv
$lumenAppFile = str_replace('// Dotenv::load(__DIR__.\'/../\');', 'Dotenv::load(__DIR__.\'/../\');', $lumenAppFile);
// Enable Eloquent
$lumenAppFile = str_replace('// $app->withEloquent();', '$app->withEloquent();', $lumenAppFile);
// Add Dingo service provider
$registerServiceProviderPosition = strpos($lumenAppFile, 'Register Service Providers');
$lumenAppFile = substr($lumenAppFile, 0, $registerServiceProviderPosition + 322) . '$app->register(Dingo\\Api\\Provider\\LumenServiceProvider::class);' . substr($lumenAppFile, $registerServiceProviderPosition + 320);
// Database config
$lumenEnvFile = str_replace('DB_DATABASE=homestead', 'DB_DATABASE=' . env('DB_DATABASE', 'homestead'), $lumenEnvFile);
$lumenEnvFile = str_replace('DB_USERNAME=homestead', 'DB_USERNAME=' . env('DB_USERNAME', 'homestead'), $lumenEnvFile);
$lumenEnvFile = str_replace('DB_PASSWORD=secret', 'DB_PASSWORD=' . env('DB_PASSWORD', 'secret'), $lumenEnvFile);
File::put($workingPath . $outputFolder . '/.env', $lumenEnvFile);
File::put($workingPath . $outputFolder . '/bootstrap/app.php', $lumenAppFile);
} catch (\Exception $exception) {
$this->writeStatus('Error', $webExecution);
Log::error($exception->getMessage());
}
}
示例13: generate
public function generate()
{
/*GENERATE BASE CONTROLLER FOR NAMESPACE */
if (!FileSystem::exists($this->path . $this->pathname . '/BaseController.php')) {
$baseDistPath = realpath(__DIR__ . '/../Controllers/BaseController.php.dist');
$basePath = realpath(__DIR__ . '/../Controllers/') . '/BaseController.php';
$copy = FileSystem::copy($baseDistPath, $basePath);
$base = realpath(__DIR__ . '/../Controllers/BaseController.php');
$find = 'use App\\Http\\Controllers\\Controller;';
$replace = 'use ' . $this->getAppNamespace() . 'Http\\Controllers\\Controller;';
$find2 = 'namespace AppNamespace\\Http\\Controllers\\API;';
$replace2 = 'namespace ' . $this->getAppNamespace() . 'Http\\Controllers\\' . $this->pathname . ';';
FileSystem::put($base, str_replace($find2, $replace2, str_replace($find, $replace, file_get_contents($base))));
if (!FileSystem::isDirectory($this->path . $this->pathname)) {
FileSystem::makeDirectory($this->path . $this->pathname);
}
FileSystem::move($base, $this->path . $this->pathname . '/BaseController.php');
}
$prefix = $this->prefix ? $this->prefix . '/' : '';
$repository = File::make($this->filename)->setLicensePhpdoc(new LicensePhpdoc(self::PROJECT_NAME, self::AUTHOR_NAME, self::AUTHOR_EMAIL))->addFullyQualifiedName(new FullyQualifiedName(\Illuminate\Http\Request::class))->addFullyQualifiedName(new FullyQualifiedName($this->namespace . "BaseController"))->addFullyQualifiedName(new FullyQualifiedName($this->appNamespace . "Repositories\\" . $this->entity . "Repository as Repository"))->addFullyQualifiedName(new FullyQualifiedName($this->appNamespace . "Managers\\" . $this->entity . "Manager as Manager"))->setStructure(Object::make($this->namespace . $this->entity . $this->layer)->extend(new Object(BaseController::class))->addMethod(Method::make('__construct')->addArgument(new Argument('Repository', 'Repository'))->addArgument(new Argument('Manager', 'Manager'))->setBody(' return parent::__construct($Repository , $Manager);'))->addMethod(Method::make('index')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {get} /' . $prefix . snake_case(str_plural($this->entity)) . ' 1 Request all ' . snake_case(str_plural($this->entity)))->addLine('@apiVersion 1.0.0')->addLine('@apiName All' . str_plural($this->entity))->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiSuccess {Object[]} 0 ' . $this->entity . ' Object.')->addLine('@apiSuccess {Number} 0.id Id.')->addLine('@apiSuccess {DateTime} 0.created_at Created date.')->addLine('@apiSuccess {DateTime} 0.updated_at Last modification date.')->addEmptyLine()->addLine("@apiSuccessExample Success 200 Example")->addLine(" HTTP/1.1 200 OK")->addLine("[")->addLine(" {")->addLine(' id: 1,')->addLine(' created_at: ' . date('Y-m-d h:i:s') . ',')->addLine(' updated_at: ' . date('Y-m-d h:i:s'))->addLine(" },")->addLine(" {")->addLine(' id: 2,')->addLine(' created_at: ' . date('Y-m-d h:i:s') . ',')->addLine(' updated_at: ' . date('Y-m-d h:i:s'))->addLine(" }")->addLine("]")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine(" HTTP/1.1 404 Not Found")->addLine("{")->addLine(' error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->setBody(' return parent::index($Request);'))->addMethod(Method::make('show')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {get} /' . $prefix . snake_case(str_plural($this->entity)) . '/:id 2 Request a specific ' . snake_case($this->entity))->addLine('@apiVersion 1.0.0')->addLine('@apiName Get' . $this->entity)->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiParam (Url params) {Number} id ' . $this->entity . ' unique id.')->addEmptyLine()->addLine('@apiSuccess {Number} id Id.')->addLine('@apiSuccess {DateTime} created_at Created date.')->addLine('@apiSuccess {DateTime} updated_at Last modification date.')->addEmptyLine()->addLine("@apiSuccessExample {json} Success 200 Example")->addLine(" HTTP/1.1 200 OK")->addLine("{")->addLine(' id: 1,')->addLine(' created_at: ' . date('Y-m-d h:i:s') . ',')->addLine(' updated_at: ' . date('Y-m-d h:i:s'))->addLine("}")->addEmptyLine()->addLine("@apiError (EntityNotFound 404) {string} error The id of the " . snake_case($this->entity) . " was not found.")->addEmptyLine()->addLine("@apiErrorExample {json} EntityNotFound 404 Example")->addLine(" HTTP/1.1 404 Not Found")->addLine("{")->addLine(' error: Entity not found')->addLine("}")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine(" HTTP/1.1 404 Not Found")->addLine("{")->addLine(' error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->addArgument(new Argument('integer', 'id'))->setBody(' return parent::show($Request , $id);'))->addMethod(Method::make('store')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {post} /' . $prefix . snake_case(str_plural($this->entity)) . ' 3 Store a ' . snake_case($this->entity))->addLine('@apiVersion 1.0.0')->addLine('@apiName Store' . $this->entity)->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiParam (FormData) {String} name ' . $this->entity . ' name.')->addEmptyLine()->addLine('@apiSuccess (Success 201) {Number} id Id.')->addLine('@apiSuccess (Success 201) {DateTime} created_at Created date.')->addLine('@apiSuccess (Success 201) {DateTime} updated_at Last modification date.')->addEmptyLine()->addLine("@apiSuccessExample {json} Success 201 Example")->addLine(" HTTP/1.1 201 OK")->addLine("{")->addLine(' id: 1,')->addLine(' created_at: ' . date('Y-m-d h:i:s') . ',')->addLine(' updated_at: ' . date('Y-m-d h:i:s'))->addLine("}")->addEmptyLine()->addLine("@apiError (ValidationErrors 400) {array[]} name List of errors for name field.")->addLine("@apiError (ValidationErrors 400) {string} name.0 First error for name.")->addLine("@apiError (ValidationErrors 400) {string} name.1 Second error for name.")->addEmptyLine()->addLine("@apiErrorExample {json} ValidationErrors 400 Example")->addLine(" HTTP/1.1 400 Bad Request")->addLine("{")->addLine(' name: [')->addLine(' The name field is required')->addLine(" ]")->addLine("}")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine(" HTTP/1.1 404 Not Found")->addLine("{")->addLine(' error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->setBody(' return parent::store($Request);'))->addMethod(Method::make('update')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {put} /' . $prefix . snake_case(str_plural($this->entity)) . '/:id 4 Update a specific ' . snake_case($this->entity))->addLine('@apiVersion 1.0.0')->addLine('@apiName Update' . $this->entity)->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiParam (Url params) {Number} id ' . $this->entity . ' unique id.')->addLine('@apiParam (FormData) {String} name ' . $this->entity . ' name.')->addEmptyLine()->addLine('@apiSuccess {Number} id Id.')->addLine('@apiSuccess {DateTime} created_at Created date.')->addLine('@apiSuccess {DateTime} updated_at Last modification date.')->addEmptyLine()->addLine("@apiSuccessExample {json} Success 200 Example")->addLine(" HTTP/1.1 200 OK")->addLine("{")->addLine(' id: 1,')->addLine(' created_at: ' . date('Y-m-d h:i:s') . ',')->addLine(' updated_at: ' . date('Y-m-d h:i:s'))->addLine("}")->addEmptyLine()->addLine("@apiError (EntityNotFound 404) {string} error The id of the " . snake_case($this->entity) . " was not found.")->addEmptyLine()->addLine("@apiErrorExample {json} EntityNotFound 404 Example")->addLine(" HTTP/1.1 404 Not Found")->addLine("{")->addLine(' error: Entity not found')->addLine("}")->addEmptyLine()->addLine("@apiError (ValidationErrors 400) {array[]} name List of errors for name field.")->addLine("@apiError (ValidationErrors 400) {string} name.0 First error for name.")->addLine("@apiError (ValidationErrors 400) {string} name.1 Second error for name.")->addEmptyLine()->addLine("@apiErrorExample {json} ValidationErrors 400 Example")->addLine(" HTTP/1.1 400 Bad Request")->addLine("{")->addLine(' name: [')->addLine(' The name field is required')->addLine(" ]")->addLine("}")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine(" HTTP/1.1 404 Not Found")->addLine("{")->addLine(' error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->addArgument(new Argument('integer', 'id'))->setBody(' return parent::update($Request , $id);'))->addMethod(Method::make('destroy')->setPhpdoc(MethodPhpdoc::make()->setDescription(Description::make('@api {delete} /' . $prefix . snake_case(str_plural($this->entity)) . '/:id 5 Delete a specific ' . snake_case($this->entity))->addLine('@apiVersion 1.0.0')->addLine('@apiName Delete' . $this->entity)->addLine('@apiGroup ' . str_plural($this->entity))->addEmptyLine()->addLine('@apiParam (Url params) {Number} id ' . $this->entity . ' unique id.')->addEmptyLine()->addLine("@apiSuccessExample Success 204 Example")->addLine(" HTTP/1.1 204 OK")->addEmptyLine()->addLine("@apiError (EntityNotFound 404) {string} error The id of the " . snake_case($this->entity) . " was not found.")->addEmptyLine()->addLine("@apiErrorExample {json} EntityNotFound 404 Example")->addLine(" HTTP/1.1 404 Not Found")->addLine("{")->addLine(' error: Entity not found')->addLine("}")->addEmptyLine()->addLine("@apiError (ServerError 500) {string} error Server error.")->addEmptyLine()->addLine("@apiErrorExample {json} ServerError 500 Example")->addLine(" HTTP/1.1 404 Not Found")->addLine("{")->addLine(' error: Server error. Try again.')->addLine("}")))->addArgument(new Argument('Request', 'Request'))->addArgument(new Argument('integer', 'id'))->setBody(' return parent::destroy($Request , $id);')));
$prettyPrinter = Build::prettyPrinter();
$generatedCode = $prettyPrinter->generateCode($repository);
return $this->generateFile($generatedCode);
}
示例14: update
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\DepartmentRequest $request
* @param \App\Department $department
* @return \Illuminate\Http\Response
*/
public function update(Requests\DepartmentRequest $request, Department $department)
{
DB::transaction(function () use($department, $request) {
$oldKeyword = $department->keyword;
$data = ['keyword' => $request->get('keyword'), 'url' => $request->get('url'), 'theme_background_color' => $request->get('theme_background_color'), 'theme_color' => $request->get('theme_color'), 'sort' => $request->get('sort'), 'active' => $request->get('active')];
if ($request->file('image')) {
$data['image'] = $request->file('image')->getClientOriginalName();
File::delete('images/' . $department->image);
$request->file('image')->move('images/', $request->file('image')->getClientOriginalName());
}
$department->update($data);
$department->langs()->delete();
$this->addDepartmentLangs($request, $department);
if ($department->keyword != $oldKeyword) {
File::move('papers/' . $oldKeyword, 'papers/' . $department->keyword);
}
Cache::forget('departments');
});
return redirect(action('Admin\\DepartmentController@index'))->with('success', 'updated');
}
示例15: update
/**
* Update the specified resource in storage.
*
* @param Requests\PaperRequest $request
* @param Paper $paper
* @return \Illuminate\Http\Response
*/
public function update(Requests\PaperRequest $request, Paper $paper)
{
$this->paper->setPaper($paper);
$status = $request->get('status_id');
$reviewer = $request->get('reviewer_id') ?: null;
if (!$paper->reviewer_id && $reviewer) {
if ($request->get('status_id') < 2) {
$status = 2;
}
}
$department = Department::find($request->get('department_id'));
$this->paper->setUrl($department->keyword);
if (!in_array($request->get('category_id'), $department->categories->lists('id')->toArray())) {
return redirect()->back()->with('error', 'department-category');
}
if ($paper->department_id != $request->get('department_id')) {
#if department is changed files must be moved
$url = $this->paper->prefix();
$oldPath = $url . '/' . $paper->department->keyword . '/';
$newPath = $url . '/' . $department->keyword . '/';
File::move($oldPath . $paper->source, $newPath . $paper->source);
if ($paper->payment_source) {
File::move($oldPath . $paper->payment_source, $newPath . $paper->payment_source);
}
}
$paperData = ['department_id' => $department->id, 'category_id' => $request->get('category_id'), 'status_id' => $status, 'title' => $request->get('title'), 'description' => $request->get('description'), 'authors' => $request->get('authors'), 'user_id' => $request->get('user_id'), 'reviewer_id' => $reviewer, 'updated_at' => Carbon::now(), 'payment_description' => $request->get('payment_description')];
if ($request->file('paper')) {
$paperData['source'] = $this->paper->buildFileName();
$this->paper->deleteFile();
}
if ($request->file('payment_source')) {
$paperData['payment_source'] = $this->paper->buildInvoiceName();
$this->paper->deleteInvoice();
}
$this->paper->upload();
$oldReviewer = $paper->reviewer_id;
$paper->update($paperData);
if ($oldReviewer != $paper->reviewer_id) {
#reviewer changed
event(new ReviewerPaperSet($paper));
}
return redirect()->action('Admin\\PaperController@index')->with('success', 'updated');
}