-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 #2570 from CachetHQ/system-meta
Global Meta System
- Loading branch information
Showing
15 changed files
with
290 additions
and
14 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
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
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,80 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Cachet. | ||
* | ||
* (c) Alt Three Services Limited | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CachetHQ\Cachet\Models; | ||
|
||
use AltThree\Validator\ValidatingTrait; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* This is the meta model class. | ||
* | ||
* @author James Brooks <james@alt-three.com> | ||
*/ | ||
class Meta extends Model | ||
{ | ||
use ValidatingTrait; | ||
|
||
/** | ||
* The attributes that should be casted to native types. | ||
* | ||
* @var string[] | ||
*/ | ||
protected $casts = [ | ||
'id' => 'int', | ||
'key' => 'string', | ||
'value' => 'json', | ||
'meta_id' => 'int', | ||
'meta_type' => 'string', | ||
]; | ||
|
||
/** | ||
* The fillable properties. | ||
* | ||
* @var string[] | ||
*/ | ||
protected $fillable = [ | ||
'key', | ||
'value', | ||
'meta_id', | ||
'meta_type', | ||
]; | ||
|
||
/** | ||
* The validation rules. | ||
* | ||
* @var string[] | ||
*/ | ||
public $rules = [ | ||
'id' => 'nullable|int|min:1', | ||
'key' => 'required|string', | ||
'value' => 'nullable', | ||
'meta_id' => 'required|int', | ||
'meta_type' => 'required|string', | ||
]; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'meta'; | ||
|
||
/** | ||
* Get all of the owning meta models. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo | ||
*/ | ||
public function meta() | ||
{ | ||
return $this->morphTo(); | ||
} | ||
} |
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
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,46 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Cachet. | ||
* | ||
* (c) Alt Three Services Limited | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateMetaTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('meta', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('key')->index(); | ||
$table->string('value'); | ||
$table->integer('meta_id')->unsigned(); | ||
$table->string('meta_type'); | ||
$table->timestamps(); | ||
|
||
$table->index(['meta_id', 'meta_type']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('meta'); | ||
} | ||
} |
Oops, something went wrong.