Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
JhumanJ authored and actions-user committed Oct 12, 2021
1 parent 5489d02 commit c9c4b1d
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Jhumanj\LaravelModelStats\Http\Controllers;

use Illuminate\Http\JsonResponse;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/CustomCodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Jhumanj\LaravelModelStats\Http\Controllers;

use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Illuminate\Http\JsonResponse;
use Jhumanj\LaravelModelStats\Http\Middleware\CustomCodeEnabled;
use Jhumanj\LaravelModelStats\Services\Tinker;

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Jhumanj\LaravelModelStats\Http\Controllers;

use Illuminate\Http\JsonResponse;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\JsonResponse;
use Jhumanj\LaravelModelStats\Http\Requests\Dashboard\StoreRequest;
use Jhumanj\LaravelModelStats\Http\Requests\Dashboard\UpdateRequest;
use Jhumanj\LaravelModelStats\Models\Dashboard;
Expand Down
11 changes: 6 additions & 5 deletions src/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Jhumanj\LaravelModelStats\Http\Controllers;

use Schema;
use ReflectionClass;
use Illuminate\Container\Container;
use Illuminate\Contracts\View\View;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\File;
use Illuminate\Contracts\Foundation\Application;
use ReflectionClass;
use Schema;

class HomeController extends Controller
{
Expand Down Expand Up @@ -38,6 +38,7 @@ private function getModels(): Collection
$models = collect(File::allFiles(app_path()))
->map(function ($item) {
$path = $item->getRelativePathName();

return sprintf(
'\%s%s',
Container::getInstance()->getNamespace(),
Expand All @@ -57,7 +58,7 @@ private function getModels(): Collection
});


return $models->map(fn(string $class) => [
return $models->map(fn (string $class) => [
'class' => $class,
'fields' => $this->getClassFields($class),
])->sortByDesc('class')->values();
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Middleware/CustomCodeEnabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CustomCodeEnabled
*/
public function handle($request, $next)
{
if (!config('model-stats.allow_custom_code')) {
if (! config('model-stats.allow_custom_code')) {
return response([
'message' => 'Custom code not enabled.',
], 403);
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/Dashboard/StoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class StoreRequest extends FormRequest
public function rules(): array
{
return [
'name' => 'required|string|max:60',
'name' => 'required|string|max:60',
'description' => 'required',
];
}
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Requests/Dashboard/UpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class UpdateRequest extends FormRequest
public function rules(): array
{
return [
'name' => 'required|string|max:60',
'description' => 'required',
'body' => 'sometimes|required',
'name' => 'required|string|max:60',
'description' => 'required',
'body' => 'sometimes|required',
'body.widgets' => 'sometimes|array',
];
}
Expand Down
13 changes: 7 additions & 6 deletions src/Http/Requests/Widgets/DataRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class DataRequest extends FormRequest
public function rules(): array
{
return [
'model' => ['required', Rule::in($this->getModels())],
'aggregate_type' => ['required', Rule::in(static::ALLOWED_AGGREGATES_TYPES)],
'date_column' => 'required',
'date_from' => 'required|date_format:Y-m-d|before:date_to',
'date_to' => 'required|date_format:Y-m-d|after:date_from',
'model' => ['required', Rule::in($this->getModels())],
'aggregate_type' => ['required', Rule::in(static::ALLOWED_AGGREGATES_TYPES)],
'date_column' => 'required',
'date_from' => 'required|date_format:Y-m-d|before:date_to',
'date_to' => 'required|date_format:Y-m-d|after:date_from',
'aggregate_column' => [Rule::requiredIf(in_array($this->aggregate_type, self::AGGREGATES_TYPES_WITH_AGGREGATE_COLUMN, true))],
];
}
Expand All @@ -52,6 +52,7 @@ private function getModels(): Collection
$models = collect(File::allFiles(app_path()))
->map(function ($item) {
$path = $item->getRelativePathName();

return sprintf('\%s%s', Container::getInstance()
->getNamespace(), strtr(substr($path, 0, strrpos($path, '.')), '/', '\\'));
})->filter(function ($class) {
Expand All @@ -60,7 +61,7 @@ private function getModels(): Collection
if (class_exists($class)) {
$reflection = new \ReflectionClass($class);
$valid = $reflection->isSubclassOf(Model::class)
&& !$reflection->isAbstract();
&& ! $reflection->isAbstract();
}

return $valid;
Expand Down
1 change: 1 addition & 0 deletions src/LaravelModelStatsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function boot(): LaravelModelStatsServiceProvider
{
$this->registerPublishing();
$this->registerCommands();

return parent::boot();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Jhumanj\LaravelModelStats\Models;

use Illuminate\Support\Facades\Config;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Config;
use Jhumanj\LaravelModelStats\Database\Factories\DashboardFactory;

class Dashboard extends Model
Expand Down
8 changes: 4 additions & 4 deletions src/Services/Tinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

namespace Jhumanj\LaravelModelStats\Services;

use Exception;
use Carbon\Carbon;
use Exception;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Application;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Illuminate\Database\QueryException;
use Laravel\Tinker\ClassAliasAutoloader;
use Psy\Configuration;
use Psy\ExecutionLoopClosure;
Expand Down Expand Up @@ -59,8 +59,8 @@ public function execute(string $phpCode): string
if (($lastException instanceof QueryException)
&& Str::of($lastException->getMessage())
->contains(self::FAKE_WRITE_HOST)) {
return "For safety reasons, you can only query data with ModelStats. Write operations are forbidden.";
}
return "For safety reasons, you can only query data with ModelStats. Write operations are forbidden.";
}
}

// Make sure we have a result var
Expand Down

0 comments on commit c9c4b1d

Please sign in to comment.