本文整理汇总了PHP中app\File::members方法的典型用法代码示例。如果您正苦于以下问题:PHP File::members方法的具体用法?PHP File::members怎么用?PHP File::members使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\File
的用法示例。
在下文中一共展示了File::members方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleCreate
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function handleCreate()
{
$user_id = Auth::id();
$user = User::find($user_id);
$user_name = $user->first_name;
$date = HelperController::convertCurrentTime();
$file = Input::file('file');
$extension = $file->getClientOriginalExtension();
// getting file extension
$fileName = $file->getClientOriginalName();
//$fileName= HelperController::explodefile($fileName);//explode the file name and file's extension and retrieve only file name
$path = '/files/' . $user_name . '/' . $date . '/' . $extension;
$destinationPath = public_path() . $path;
// upload path
$upload_success = $file->move($destinationPath, $fileName);
// uploading file to given path
if ($upload_success) {
$file_name_from_db = HelperController::checkFileName($fileName);
$file_path_from_db = HelperController::checkFilePath($path);
if ($fileName != $file_name_from_db && $path != $file_path_from_db) {
/*
* file data is stored in database
*
*/
$db_file = new File();
$db_file->file_name = $fileName;
$db_file->file_path = 'files/' . $user_name . '/' . $date . '/' . $extension;
$db_file->save();
$db_file->members()->attach($user_id);
//check file extension from extension collection
$ext_from_db = HelperController::checkExtension($extension);
if ($extension != $ext_from_db) {
$db_file_extension = new Extension();
$db_file_extension->file_extension = $extension;
$db_file_extension->save();
$db_file_extension->files()->attach($db_file);
} elseif ($extension == $ext_from_db) {
//$old_extension= Extension::where('file_extension','=',$extension)->first();
//$extension_id=$old_extension->id;
$ext_id = HelperController::getExtensionId($extension);
$db_file->extensions()->attach($ext_id);
}
}
return Response::json('success', 200);
} else {
return Response::json('error', 400);
}
//echo $file;
}