Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Apply fixes from StyleCI (#4912)
Browse files Browse the repository at this point in the history
  • Loading branch information
emptynick authored Apr 29, 2020
1 parent 3d9690d commit 0c113a4
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class MakeSettingsValueNullable extends Migration
{
Expand Down
2 changes: 1 addition & 1 deletion routes/voyager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

Route::get($dataType->slug.'/order', $breadController.'@order')->name($dataType->slug.'.order');
Route::post($dataType->slug.'/action', $breadController.'@action')->name($dataType->slug.'.action');
Route::post($dataType->slug.'/order', $breadController.'@update_order')->name($dataType->slug.'.update_order');;
Route::post($dataType->slug.'/order', $breadController.'@update_order')->name($dataType->slug.'.update_order');
Route::get($dataType->slug.'/{id}/restore', $breadController.'@restore')->name($dataType->slug.'.restore');
Route::get($dataType->slug.'/relation', $breadController.'@relation')->name($dataType->slug.'.relation');
Route::post($dataType->slug.'/remove', $breadController.'@remove_media')->name($dataType->slug.'.media.remove');
Expand Down
6 changes: 5 additions & 1 deletion src/Database/Schema/ForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public static function make(array $foreignKey)
}

$doctrineForeignKey = new DoctrineForeignKey(
$localColumns, $foreignTable, $foreignColumns, $name, $options
$localColumns,
$foreignTable,
$foreignColumns,
$name,
$options
);

if (isset($localTable)) {
Expand Down
14 changes: 7 additions & 7 deletions src/Http/Controllers/ContentTypes/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function handle()
$resize_width = null;
$resize_height = null;
if (isset($this->options->resize) && (
isset($this->options->resize->width) || isset($this->options->resize->height)
)) {
isset($this->options->resize->width) || isset($this->options->resize->height)
)) {
if (isset($this->options->resize->width)) {
$resize_width = $this->options->resize->width;
}
Expand Down Expand Up @@ -75,17 +75,17 @@ function (Constraint $constraint) {
}

$image = InterventionImage::make($file)
->orientate()
->orientate()
->resize(
$thumb_resize_width,
$thumb_resize_height,
function (Constraint $constraint) {
$thumb_resize_width,
$thumb_resize_height,
function (Constraint $constraint) {
$constraint->aspectRatio();
if (isset($this->options->upsize) && !$this->options->upsize) {
$constraint->upsize();
}
}
)->encode($file->getClientOriginalExtension(), $resize_quality);
)->encode($file->getClientOriginalExtension(), $resize_quality);
} elseif (isset($thumbnails->crop->width) && isset($thumbnails->crop->height)) {
$crop_width = $thumbnails->crop->width;
$crop_height = $thumbnails->crop->height;
Expand Down
12 changes: 6 additions & 6 deletions src/Http/Controllers/ContentTypes/MultipleImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function handle()
$resize_height = null;

if (isset($this->options->resize) && (
isset($this->options->resize->width) || isset($this->options->resize->height)
)) {
isset($this->options->resize->width) || isset($this->options->resize->height)
)) {
if (isset($this->options->resize->width)) {
$resize_width = $this->options->resize->width;
}
Expand Down Expand Up @@ -83,15 +83,15 @@ function (Constraint $constraint) {
$image = InterventionImage::make($file)
->orientate()
->resize(
$thumb_resize_width,
$thumb_resize_height,
function (Constraint $constraint) {
$thumb_resize_width,
$thumb_resize_height,
function (Constraint $constraint) {
$constraint->aspectRatio();
if (isset($this->options->upsize) && !$this->options->upsize) {
$constraint->upsize();
}
}
)->encode($file->getClientOriginalExtension(), $resize_quality);
)->encode($file->getClientOriginalExtension(), $resize_quality);
} elseif (isset($this->options->thumbnails) && isset($thumbnails->crop->width) && isset($thumbnails->crop->height)) {
$crop_width = $thumbnails->crop->width;
$crop_height = $thumbnails->crop->height;
Expand Down
6 changes: 4 additions & 2 deletions src/Http/Controllers/VoyagerBreadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public function create(Request $request, $table)
$dataType = Voyager::model('DataType')->whereName($table)->first();

$data = $this->prepopulateBreadInfo($table);
$data['fieldOptions'] = SchemaManager::describeTable((isset($dataType) && strlen($dataType->model_name) != 0)
$data['fieldOptions'] = SchemaManager::describeTable(
(isset($dataType) && strlen($dataType->model_name) != 0)
? DB::getTablePrefix().app($dataType->model_name)->getTable()
: DB::getTablePrefix().$table
);
Expand Down Expand Up @@ -121,7 +122,8 @@ public function edit($table)

$dataType = Voyager::model('DataType')->whereName($table)->first();

$fieldOptions = SchemaManager::describeTable((strlen($dataType->model_name) != 0)
$fieldOptions = SchemaManager::describeTable(
(strlen($dataType->model_name) != 0)
? DB::getTablePrefix().app($dataType->model_name)->getTable()
: DB::getTablePrefix().$dataType->name
);
Expand Down
4 changes: 1 addition & 3 deletions src/Http/Controllers/VoyagerCompassController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use Exception;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

class VoyagerCompassController extends Controller
{
Expand Down Expand Up @@ -71,7 +69,7 @@ public function index(Request $request)
$args = (isset($args)) ? ' '.$args : '';

try {
Artisan::call($command . $args);
Artisan::call($command.$args);
$artisan_output = Artisan::output();
} catch (Exception $e) {
$artisan_output = $e->getMessage();
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/VoyagerMediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ public function upload(Request $request)
($thumbnail_data->height ?? null),
function ($constraint) {
$constraint->aspectRatio();
}, ($thumbnail_data->position ?? 'center')
},
($thumbnail_data->position ?? 'center')
);
} elseif ($type == 'crop') {
$thumbnail = $thumbnail->crop(
Expand Down
6 changes: 4 additions & 2 deletions src/Models/DataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public function updateDataType($requestData, $throw = false)
}

if ($this->fill($requestData)->save()) {
$fields = $this->fields((strlen($this->model_name) != 0)
$fields = $this->fields(
(strlen($this->model_name) != 0)
? DB::getTablePrefix().app($this->model_name)->getTable()
: DB::getTablePrefix().Arr::get($requestData, 'name')
);
Expand Down Expand Up @@ -213,7 +214,8 @@ public function fieldOptions()
// Get ordered BREAD fields
$orderedFields = $this->rows()->pluck('field')->toArray();

$_fieldOptions = SchemaManager::describeTable((strlen($this->model_name) != 0)
$_fieldOptions = SchemaManager::describeTable(
(strlen($this->model_name) != 0)
? app($this->model_name)->getTable()
: $this->name
)->toArray();
Expand Down
3 changes: 2 additions & 1 deletion src/Providers/VoyagerDummyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ private function registerPublishableResources()
public function registerConfigs()
{
$this->mergeConfigFrom(
dirname(__DIR__).'/../publishable/config/voyager_dummy.php', 'voyager'
dirname(__DIR__).'/../publishable/config/voyager_dummy.php',
'voyager'
);
}
}
4 changes: 3 additions & 1 deletion src/Traits/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ public static function scopeWhereTranslation($query, $field, $operator, $value =
$self = new static();
$table = $self->getTable();

return $query->whereIn($self->getKeyName(), Translation::where('table_name', $table)
return $query->whereIn(
$self->getKeyName(),
Translation::where('table_name', $table)
->where('column_name', $field)
->where('value', $operator, $value)
->when(!is_null($locales), function ($query) use ($locales) {
Expand Down
3 changes: 2 additions & 1 deletion src/VoyagerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ private function registerPublishableResources()
public function registerConfigs()
{
$this->mergeConfigFrom(
dirname(__DIR__).'/publishable/config/voyager.php', 'voyager'
dirname(__DIR__).'/publishable/config/voyager.php',
'voyager'
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/CompassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testCanExecuteCommand()

$response = $this->post(route('voyager.compass.index'), [
'command' => 'make:model',
'args' => 'TestModel'
'args' => 'TestModel',
]);
$this->assertStringContainsString('Model created successfully.', $response->response->content());
}
Expand All @@ -66,7 +66,7 @@ public function testCannotExecuteUnknownCommand()

$response = $this->post(route('voyager.compass.index'), [
'command' => 'unknown:command',
'args' => 'AnArgument'
'args' => 'AnArgument',
]);
$this->assertStringContainsString('The command "unknown:command" does not exist.', $response->response->content());
}
Expand Down
1 change: 0 additions & 1 deletion tests/DisabledTestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace TCG\Voyager\Tests;

use Exception;
use Illuminate\Foundation\Exceptions\Handler;

class DisabledTestException extends Handler
Expand Down

0 comments on commit 0c113a4

Please sign in to comment.