Skip to content

Commit

Permalink
Merge commit '058949f8ce4a3d3387078368e13ae9163cf4ac13' as 'Modules/S…
Browse files Browse the repository at this point in the history
…etting'
  • Loading branch information
nWidart committed Sep 9, 2016
1 parent 7a96299 commit 2abfbc7
Show file tree
Hide file tree
Showing 5,103 changed files with 2,035 additions and 931,865 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
27 changes: 0 additions & 27 deletions .env.example

This file was deleted.

4 changes: 0 additions & 4 deletions .gitattributes

This file was deleted.

13 changes: 0 additions & 13 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/vendor
/node_modules
/public/storage
Homestead.yaml
Homestead.json
.env
.idea/
.php_cs.cache
vendor/
composer.lock
Modules/
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: php

php:
- 7
- 5.6
- hhvm

env:
- LARAVEL_VERSION="~5.1" TESTBENCH_VERSION="~3.1"

before_script:
- travis_retry composer install --no-interaction --prefer-source

script: phpunit

sudo: false

notifications:
slack: asgardcms:85rIXCjkamzxitmc0opndGga
email:
- [email protected]
- [email protected]

matrix:
allow_failures:
- php: hhvm
13 changes: 13 additions & 0 deletions Blade/Facades/SettingDirective.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Modules\Setting\Blade\Facades;

use Illuminate\Support\Facades\Facade;

final class SettingDirective extends Facade
{
protected static function getFacadeAccessor()
{
return 'setting.setting.directive';
}
}
39 changes: 39 additions & 0 deletions Blade/SettingDirective.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Modules\Setting\Blade;

final class SettingDirective
{
/**
* @var string
*/
private $settingName;
/**
* @var string
*/
private $locale;
/**
* @var string Default value
*/
private $default;

/**
* @param $arguments
*/
public function show($arguments)
{
$this->extractArguments($arguments);

return setting($this->settingName, $this->locale, $this->default);
}

/**
* @param array $arguments
*/
private function extractArguments(array $arguments)
{
$this->settingName = array_get($arguments, 0);
$this->locale = array_get($arguments, 1);
$this->default = array_get($arguments, 2);
}
}
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions Contracts/Setting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Modules\Setting\Contracts;

interface Setting
{
/**
* Determine if the given configuration value exists.
*
* @param string $key
* @return bool
*/
public function has($key);

/**
* Get the specified configuration value in the given language
*
* @param string $key
* @param string $locale
* @param mixed $default
* @return string
*/
public function get($key, $locale = null, $default = null);

/**
* Set a given configuration value.
*
* @param string $key
* @param mixed $value
* @return \Modules\Setting\Entities\Setting
*/
public function set($key, $value);
}
34 changes: 34 additions & 0 deletions Database/Migrations/2014_10_14_200250_create_settings_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('setting__settings', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name');
$table->string('plainValue')->nullable();
$table->boolean('isTranslatable');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('setting__settings');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateSettingTranslationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('setting__setting_translations', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('setting_id')->unsigned();
$table->string('locale')->index();
$table->string('value');
$table->text('description')->nullable();
$table->unique(['setting_id', 'locale']);
$table->foreign('setting_id')->references('id')->on('setting__settings')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('setting__setting_translations');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class MakeSettingsValueTextField extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up()
{
Schema::table('setting__settings', function (Blueprint $table) {
$table->text('plainValue')->string('plainValue')->change();
});
Schema::table('setting__setting_translations', function (Blueprint $table) {
$table->text('value')->string('value')->change();
});
}

/**
* Reverse the migrations.
* @return void
*/
public function down()
{
Schema::table('setting__settings', function (Blueprint $table) {
$table->string('plainValue')->text('plainValue')->change();
});
Schema::table('setting__setting_translations', function (Blueprint $table) {
$table->string('value')->text('value')->change();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class MakeSettingsNameUnique extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up()
{
Schema::table('setting__settings', function (Blueprint $table) {
$table->unique('name', 'setting__settings_name_unique');
$table->index('name', 'setting__settings_name_index');
});
}

/**
* Reverse the migrations.
* @return void
*/
public function down()
{
Schema::table('setting__settings', function (Blueprint $table) {
$table->dropUnique('setting__settings_name_unique');
$table->dropIndex('setting__settings_name_index');
});
}
}
37 changes: 37 additions & 0 deletions Database/Seeders/SettingDatabaseSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Modules\Setting\Database\Seeders;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Modules\Setting\Repositories\SettingRepository;

class SettingDatabaseSeeder extends Seeder
{
/**
* @var SettingRepository
*/
private $setting;

public function __construct(SettingRepository $setting)
{
$this->setting = $setting;
}

/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();

$data = [
'core::template' => 'Flatly',
'core::locales' => ['en'],
];

$this->setting->createOrUpdate($data);
}
}
File renamed without changes.
15 changes: 15 additions & 0 deletions Entities/Setting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Modules\Setting\Entities;

use Dimsav\Translatable\Translatable;
use Illuminate\Database\Eloquent\Model;

class Setting extends Model
{
use Translatable;

public $translatedAttributes = ['value', 'description'];
protected $fillable = ['name', 'value', 'description', 'isTranslatable', 'plainValue'];
protected $table = 'setting__settings';
}
12 changes: 12 additions & 0 deletions Entities/SettingTranslation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Modules\Setting\Entities;

use Illuminate\Database\Eloquent\Model;

class SettingTranslation extends Model
{
public $timestamps = false;
protected $fillable = ['value', 'description'];
protected $table = 'setting__setting_translations';
}
Loading

0 comments on commit 2abfbc7

Please sign in to comment.