first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMetaDataTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('meta_data', function (Blueprint $table) {
$table->increments('id');
$table->morphs('entity');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('meta_data');
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMetaDataTranslationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('meta_data_translations', function (Blueprint $table) {
$table->increments('id');
$table->integer('meta_data_id')->unsigned();
$table->string('locale');
$table->string('meta_title')->nullable();
$table->text('meta_keywords')->nullable();
$table->text('meta_description')->nullable();
$table->unique(['meta_data_id', 'locale']);
$table->foreign('meta_data_id')->references('id')->on('meta_data')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('meta_data_translations');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DeleteMetaKeywordsColumnFromMetaDataTranslationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('meta_data_translations', function (Blueprint $table) {
$table->dropColumn('meta_keywords');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('meta_data_translations', function (Blueprint $table) {
$table->text('meta_keywords')->nullable()->after('meta_title');
});
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Modules\Meta\Eloquent;
use Modules\Meta\Entities\MetaData;
trait HasMetaData
{
/**
* The "booting" method of the trait.
*
* @return void
*/
public static function bootHasMetaData()
{
static::saved(function ($entity) {
$entity->saveMetaData(request('meta', []));
});
}
/**
* Get the meta for the entity.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function meta()
{
return $this->morphOne(MetaData::class, 'entity')->withDefault();
}
/**
* Save meta data for the entity.
*
* @param array $data
* @return \Illuminate\Database\Eloquent\Model
*/
public function saveMetaData($data = [])
{
$this->meta->fill([locale() => $data])->save();
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Modules\Meta\Entities;
use Modules\Support\Eloquent\Model;
use Modules\Support\Eloquent\Translatable;
class MetaData extends Model
{
use Translatable;
/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = ['translations'];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['entity_id', 'entity_type'];
/**
* The attributes that are translatable.
*
* @var array
*/
protected $translatedAttributes = ['meta_title', 'meta_description'];
public function getMetaKeywordsAttribute($keywords)
{
return is_array($keywords) ? $keywords : [];
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Modules\Meta\Entities;
use Modules\Support\Eloquent\TranslationModel;
class MetaDataTranslation extends TranslationModel
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['meta_title', 'meta_description'];
}

View File

@@ -0,0 +1,6 @@
<?php
return [
'meta_title' => 'Meta Title',
'meta_description' => 'Meta Description',
];

View File

@@ -0,0 +1,33 @@
@if ($entity->slug ?? false)
{{ Form::text('slug', trans('page::attributes.slug'), $errors, $entity, ['required' => true]) }}
@endif
<div class="form-group">
<label for="meta-title" class="col-md-3 control-label text-left">
{{ trans('meta::attributes.meta_title') }}
</label>
<div class="col-md-9">
<input type="text"
name="meta[meta_title]"
class="form-control"
id="meta-title"
value="{{ old("meta.meta_title", optional($entity->meta ?? null)->translate(locale())->meta_title ?? '') }}"
>
</div>
</div>
<div class="form-group">
<label for="meta-description" class="col-md-3 control-label text-left">
{{ trans('meta::attributes.meta_description') }}
</label>
<div class="col-md-9">
<textarea name="meta[meta_description]"
class="form-control"
id="meta-description"
rows="10"
cols="10"
>{{ old("meta.meta_description", optional($entity->meta ?? null)->translate(locale())->meta_description ?? '') }}</textarea>
</div>
</div>

View File

@@ -0,0 +1,27 @@
{
"name": "fleetcart/meta",
"description": "The FleetCart Meta Module.",
"authors": [
{
"name": "Envay Soft",
"email": "envaysoft@gmail.com"
}
],
"require": {
"php": "^8.0.2"
},
"autoload": {
"psr-4": {
"Modules\\Meta\\": ""
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev"
}

6
Modules/Meta/module.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Meta",
"alias": "meta",
"description": "Meta data management",
"priority": 110
}