@@ -19,11 +19,11 @@ |
||
| 19 | 19 | public function percentage($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): int |
| 20 | 20 | { |
| 21 | 21 | $count = File::forResource($activityInstance->id, $moduleInstance->id)->count(); |
| 22 | - $needed = ( $settings['number_of_files'] ?? 1); |
|
| 22 | + $needed = ($settings['number_of_files'] ?? 1); |
|
| 23 | 23 | |
| 24 | - $percentage = (int) round(($count/$needed) * 100, 0); |
|
| 24 | + $percentage = (int) round(($count / $needed) * 100, 0); |
|
| 25 | 25 | |
| 26 | - if($percentage > 100) { |
|
| 26 | + if ($percentage > 100) { |
|
| 27 | 27 | return 100; |
| 28 | 28 | } |
| 29 | 29 | return $percentage; |
@@ -23,11 +23,11 @@ |
||
| 23 | 23 | $count = File::forResource($activityInstance->id, $moduleInstance->id())->get()->filter(function(File $file) use ($settings) { |
| 24 | 24 | return $file->status === $settings['status']; |
| 25 | 25 | })->count(); |
| 26 | - $needed = ( $settings['number_of_files'] ?? 1); |
|
| 26 | + $needed = ($settings['number_of_files'] ?? 1); |
|
| 27 | 27 | |
| 28 | - $percentage = (int) round(($count/$needed) * 100, 0); |
|
| 28 | + $percentage = (int) round(($count / $needed) * 100, 0); |
|
| 29 | 29 | |
| 30 | - if($percentage > 100) { |
|
| 30 | + if ($percentage > 100) { |
|
| 31 | 31 | return 100; |
| 32 | 32 | } |
| 33 | 33 | return $percentage; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $this->authorize('file.destroy'); |
| 54 | 54 | |
| 55 | - if((int) $file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 55 | + if ((int) $file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 56 | 56 | throw new AuthorizationException(); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $this->authorize('file.index'); |
| 70 | 70 | |
| 71 | - if((int) $file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 71 | + if ((int) $file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 72 | 72 | throw new AuthorizationException(); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $this->authorize('file.update'); |
| 81 | 81 | |
| 82 | - if((int) $file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 82 | + if ((int) $file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 83 | 83 | throw new AuthorizationException(); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function index(Request $request, Activity $activity, ModuleInstance $moduleInstance, File $file) |
| 22 | 22 | { |
| 23 | 23 | $this->authorize('comment.index'); |
| 24 | - if ((int)$file->activity_instance_id !== (int)app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 24 | + if ((int) $file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 25 | 25 | throw new AuthorizationException(); |
| 26 | 26 | } |
| 27 | 27 | return $file->comments; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $this->authorize('comment.destroy'); |
| 47 | 47 | |
| 48 | - if ((int)$comment->file->activity_instance_id !== (int)app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 48 | + if ((int) $comment->file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 49 | 49 | throw new AuthorizationException(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $this->authorize('comment.update'); |
| 62 | 62 | |
| 63 | - if ((int)$comment->file->activity_instance_id !== (int)app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 63 | + if ((int) $comment->file->activity_instance_id !== (int) app(ActivityInstanceResolver::class)->getActivityInstance()->id) { |
|
| 64 | 64 | throw new AuthorizationException(); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | $this->authorize('view-page'); |
| 13 | 13 | |
| 14 | - return view(alias() . '::participant'); |
|
| 14 | + return view(alias().'::participant'); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | \ No newline at end of file |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | public function authorize($ability, $arguments = []) |
| 18 | 18 | { |
| 19 | 19 | return $this->baseAuthorize( |
| 20 | - alias() . '.' . $ability, |
|
| 20 | + alias().'.'.$ability, |
|
| 21 | 21 | $arguments |
| 22 | 22 | ); |
| 23 | 23 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | { |
| 17 | 17 | $this->authorize('admin.file.download'); |
| 18 | 18 | |
| 19 | - if(Storage::exists($file->path)) { |
|
| 19 | + if (Storage::exists($file->path)) { |
|
| 20 | 20 | return Storage::download($file->path, $file->filename, [ |
| 21 | 21 | 'X-Vapor-Base64-Encode' => 'True' |
| 22 | 22 | ]); |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use BristolSU\Module\UploadFile\Models\File; |
| 4 | 4 | use Faker\Generator as Faker; |
| 5 | 5 | |
| 6 | -$factory->define(File::class, function (Faker $faker) { |
|
| 6 | +$factory->define(File::class, function(Faker $faker) { |
|
| 7 | 7 | return [ |
| 8 | 8 | 'title' => $faker->sentence, |
| 9 | 9 | 'description' => $faker->sentence, |
@@ -14,10 +14,10 @@ discard block |
||
| 14 | 14 | 'uploaded_by' => function() { |
| 15 | 15 | return factory(\BristolSU\ControlDB\Models\User::class)->create()->id(); |
| 16 | 16 | }, |
| 17 | - 'module_instance_id' => function () { |
|
| 17 | + 'module_instance_id' => function() { |
|
| 18 | 18 | return factory(\BristolSU\Support\ModuleInstance\ModuleInstance::class)->create()->id; |
| 19 | 19 | }, |
| 20 | - 'activity_instance_id' => function () { |
|
| 20 | + 'activity_instance_id' => function() { |
|
| 21 | 21 | return factory(\BristolSU\Support\ActivityInstance\ActivityInstance::class)->create()->id; |
| 22 | 22 | }, |
| 23 | 23 | 'tags' => $faker->randomElements(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], 4) |
@@ -256,7 +256,7 @@ |
||
| 256 | 256 | )->withField( |
| 257 | 257 | Field::checkList('allowed_extensions')->label('Allowed file types')->hint('Which file types can be uploaded?') |
| 258 | 258 | ->listBox(true)->values($this->app['config']->get($this->alias() . '.file_types')) |
| 259 | - ->default(['doc', 'docx', 'odt', 'rtf', 'txt', 'csv', 'ppt', 'pptx', 'pdf', 'xls']) |
|
| 259 | + ->default(['doc', 'docx', 'odt', 'rtf', 'txt', 'csv', 'ppt', 'pptx', 'pdf', 'xls']) |
|
| 260 | 260 | ) |
| 261 | 261 | )->withGroup( |
| 262 | 262 | Group::make('Status Changes')->withField( |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | public function baseDirectory() |
| 195 | 195 | { |
| 196 | - return __DIR__ . '/..'; |
|
| 196 | + return __DIR__.'/..'; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | public function register() |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | Route::bind('uploadfile_file', function($id) { |
| 218 | 218 | $file = File::findOrFail($id); |
| 219 | - if(request()->route('module_instance_slug') && (int) $file->module_instance_id === request()->route('module_instance_slug')->id()) { |
|
| 219 | + if (request()->route('module_instance_slug') && (int) $file->module_instance_id === request()->route('module_instance_slug')->id()) { |
|
| 220 | 220 | return $file; |
| 221 | 221 | } |
| 222 | 222 | throw (new ModelNotFoundException)->setModel(File::class); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $currentActivityInstance = app(ActivityInstanceResolver::class)->getActivityInstance(); |
| 229 | 229 | $fileActivityInstance = $file->activityInstance(); |
| 230 | - if($currentActivityInstance->resource_type === $fileActivityInstance->resource_type |
|
| 230 | + if ($currentActivityInstance->resource_type === $fileActivityInstance->resource_type |
|
| 231 | 231 | && (int) $currentActivityInstance->resource_id === (int) $fileActivityInstance->resource_id) { |
| 232 | 232 | return $file; |
| 233 | 233 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | Route::bind('uploadfile_file_status', function($id) { |
| 238 | 238 | $fileStatus = FileStatus::findOrFail($id); |
| 239 | - if(request()->route('module_instance_slug') && (int) $fileStatus->file->module_instance_id === request()->route('module_instance_slug')->id()) { |
|
| 239 | + if (request()->route('module_instance_slug') && (int) $fileStatus->file->module_instance_id === request()->route('module_instance_slug')->id()) { |
|
| 240 | 240 | return $fileStatus; |
| 241 | 241 | } |
| 242 | 242 | throw (new ModelNotFoundException)->setModel(FileStatus::class); |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | Route::bind('uploadfile_comment', function($id) { |
| 246 | 246 | $comment = Comment::findOrFail($id); |
| 247 | - if(request()->route('module_instance_slug') && (int) $comment->file->module_instance_id === request()->route('module_instance_slug')->id()) { |
|
| 247 | + if (request()->route('module_instance_slug') && (int) $comment->file->module_instance_id === request()->route('module_instance_slug')->id()) { |
|
| 248 | 248 | return $comment; |
| 249 | 249 | } |
| 250 | 250 | throw (new ModelNotFoundException)->setModel(Comment::class); |
@@ -264,20 +264,20 @@ discard block |
||
| 264 | 264 | Group::make('New Documents')->withField( |
| 265 | 265 | Field::input('document_title')->inputType('text')->label('Default document title')->hint('This will be the default title of a new file')->default('Document') |
| 266 | 266 | )->withField( |
| 267 | - Field::switch('multiple_files')->label('Multiple Files')->hint('Should multiple files be able to be uploaded at the same time?') |
|
| 267 | + Field::switch ('multiple_files')->label('Multiple Files')->hint('Should multiple files be able to be uploaded at the same time?') |
|
| 268 | 268 | ->textOn('Allow')->textOff('Do not allow')->default(true) |
| 269 | 269 | )->withField( |
| 270 | 270 | Field::checkList('allowed_extensions')->label('Allowed file types')->hint('Which file types can be uploaded?') |
| 271 | - ->listBox(true)->values($this->app['config']->get($this->alias() . '.file_types')) |
|
| 271 | + ->listBox(true)->values($this->app['config']->get($this->alias().'.file_types')) |
|
| 272 | 272 | ->default(['doc', 'docx', 'odt', 'rtf', 'txt', 'csv', 'ppt', 'pptx', 'pdf', 'xls']) |
| 273 | 273 | ) |
| 274 | 274 | )->withGroup( |
| 275 | 275 | Group::make('Status Changes')->withField( |
| 276 | 276 | Field::input('initial_status')->inputType('select')->label('Initial Status')->hint('What status should all new files have?') |
| 277 | - ->default('Awaiting Approval')->values($this->app['config']->get($this->alias() . '.statuses')) |
|
| 277 | + ->default('Awaiting Approval')->values($this->app['config']->get($this->alias().'.statuses')) |
|
| 278 | 278 | )->withField( |
| 279 | 279 | Field::checkList('statuses')->label('Available Statuses')->hint('A list of available statuses') |
| 280 | - ->listBox(true)->values($this->app['config']->get($this->alias() . '.statuses')) |
|
| 280 | + ->listBox(true)->values($this->app['config']->get($this->alias().'.statuses')) |
|
| 281 | 281 | ) |
| 282 | 282 | )->withGroup( |
| 283 | 283 | Group::make('Tags')->withField( |