This repository has been archived by the owner on Nov 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from epigra/CU-9mr1tm
CU-9mr1tm - Add core structure and api endpoint
- Loading branch information
Showing
21 changed files
with
325 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
return [ | ||
/* | ||
* Reload the entire page on save. Useful when updating any Nova UI related settings. | ||
*/ | ||
|
||
'reload_page_on_save' => false, | ||
|
||
]; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Epigra\NovaSettings\DTO\NovaSetting; | ||
|
||
use Carbon\Carbon; | ||
use Epigra\Core\DTO\Base\BaseDTO; | ||
use Illuminate\Validation\Rule; | ||
|
||
/** | ||
* Class NovaSettingDTO | ||
*/ | ||
class NovaSettingDTO extends BaseDTO | ||
{ | ||
/** | ||
* SlideDTO constructor. | ||
* @param array $parameters | ||
*/ | ||
public function __construct(array $parameters = []) | ||
{ | ||
parent::__construct($parameters, self::class); | ||
} | ||
|
||
/** | ||
* @var int | ||
*/ | ||
public int $id; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public string $key; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public string $value; | ||
|
||
public function mapToDTO($dto, array $originalData): BaseDTO | ||
{ | ||
return parent::mapToDTO($dto, $originalData); // TODO: Change the autogenerated stub | ||
} | ||
|
||
/** | ||
* @param array $parameters | ||
* @param bool $updateMode | ||
* @return array | ||
*/ | ||
public function validate(array $parameters, bool $updateMode) | ||
{ | ||
return $this->validator($parameters, [ | ||
//'title' => 'required|string|max:255', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Epigra\NovaSettings\Http\Controllers\Api; | ||
|
||
use Epigra\Core\Controller\BaseApiController; | ||
use Epigra\NovaSettings\DTO\NovaSetting\NovaSettingDTO; | ||
use Epigra\NovaSettings\Services\NovaSetting\NovaSettingServiceInterface; | ||
use Illuminate\Http\Request; | ||
|
||
class SettingsApiController extends BaseApiController | ||
{ | ||
public function __construct(NovaSettingServiceInterface $service) | ||
{ | ||
$this->service = $service; | ||
$this->dtoClass = NovaSettingDTO::class; | ||
} | ||
|
||
public function findByKey(string $key) | ||
{ | ||
$result = $this->service->findByKey($key); | ||
return $this->ok($result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Epigra\NovaSettings\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class NovaSetting extends Model | ||
{ | ||
protected $table = "settings"; | ||
|
||
protected $fillable = [ | ||
'key', | ||
'value' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Epigra\NovaSettings\Providers; | ||
|
||
use Epigra\NovaSettings\Repositories\NovaSetting\NovaSettingRepository; | ||
use Epigra\NovaSettings\Repositories\NovaSetting\NovaSettingRepositoryInterface; | ||
use Epigra\NovaSettings\Services\NovaSetting\NovaSettingService; | ||
use Epigra\NovaSettings\Services\NovaSetting\NovaSettingServiceInterface; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class RepositoryServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
//repositories | ||
$this->app->bind(NovaSettingRepositoryInterface::class, NovaSettingRepository::class); | ||
|
||
//services | ||
$this->app->bind(NovaSettingServiceInterface::class, NovaSettingService::class); | ||
} | ||
|
||
/** | ||
* Bootstrap services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Epigra\NovaSettings\Providers; | ||
|
||
use Epigra\Core\Providers\BaseRouteServiceProvider; | ||
|
||
class RouteServiceProvider extends BaseRouteServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
$this->setModuleName('NovaSettings'); | ||
parent::boot(); | ||
} | ||
} | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Epigra\NovaSettings\Repositories\NovaSetting; | ||
|
||
use Epigra\NovaSettings\Models\NovaSetting; | ||
use Epigra\Core\Repositories\Base\BaseEloquentRepository; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Collection; | ||
|
||
class NovaSettingRepository extends BaseEloquentRepository implements NovaSettingRepositoryInterface | ||
{ | ||
/** | ||
* SlideRepository constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(NovaSetting::class); | ||
} | ||
|
||
/** | ||
* @inherit | ||
*/ | ||
public function findByKey(string $key): ?Model | ||
{ | ||
return $this->model::where('key', $key) | ||
->first(); | ||
} | ||
|
||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/Repositories/NovaSetting/NovaSettingRepositoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Epigra\NovaSettings\Repositories\NovaSetting; | ||
|
||
use Epigra\NovaSettings\Models\NovaSetting; | ||
use Epigra\Core\Repositories\Base\BaseRepositoryInterface; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Collection; | ||
|
||
interface NovaSettingRepositoryInterface extends BaseRepositoryInterface | ||
{ | ||
/** | ||
* Returns a setting by key. | ||
* @param string $key | ||
* @return ?Model | ||
*/ | ||
public function findByKey(string $key): ?Model; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Tool API Routes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here is where you may register API routes for your tool. These routes | ||
| are loaded by the ServiceProvider of your tool. They are protected | ||
| by your tool's "Authorize" middleware by default. Now, go build! | ||
| | ||
*/ | ||
|
||
Route::namespace('\Epigra\NovaSettings\Http\Controllers')->group(function () { | ||
Route::prefix('nova-vendor/nova-settings')->group(function () { | ||
Route::get('/settings', 'SettingsController@get'); | ||
Route::post('/settings', 'SettingsController@save'); | ||
}); | ||
|
||
Route::delete('/nova-api/nova-settings/settings/field/{fieldName}', 'SettingsController@deleteImage'); | ||
}); | ||
|
||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Epigra\NovaSettings\Services\NovaSetting; | ||
|
||
use Epigra\NovaSettings\DTO\NovaSetting\NovaSettingDTO; | ||
use Epigra\NovaSettings\Repositories\NovaSetting\NovaSettingRepositoryInterface; | ||
use Epigra\Core\Services\Base\BaseService; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class NovaSettingService extends BaseService implements NovaSettingServiceInterface | ||
{ | ||
/** | ||
* @var NovaSettingRepositoryInterface | ||
*/ | ||
private NovaSettingRepositoryInterface $repository; | ||
|
||
|
||
/** | ||
* NovaSettingService constructor. | ||
* @param NovaSettingRepositoryInterface $repository | ||
*/ | ||
public function __construct(NovaSettingRepositoryInterface $repository) | ||
{ | ||
parent::__construct($repository, NovaSettingDTO::class); | ||
$this->repository = $repository; | ||
} | ||
|
||
/** | ||
* @inherit | ||
*/ | ||
public function findByKey(string $key): ?Model | ||
{ | ||
return $this->repository->findByKey($key); | ||
} | ||
} |
Oops, something went wrong.