Skip to content

Commit

Permalink
add kolossal-io/laravel-multiplex
Browse files Browse the repository at this point in the history
  • Loading branch information
secondnetwork committed Jan 18, 2024
1 parent 69a9334 commit a625d97
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 22 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"blade-ui-kit/blade-icons": "^1.5.3",
"illuminate/support": "^10.21",
"intervention/image": "^2.7.2 || ^3.1.0",
"kolossal-io/laravel-multiplex": "^1.0",
"laravel/folio": "^1.1.5",
"laravel/fortify": "^1.19.1",
"livewire/livewire": "^3.3.3",
Expand Down
6 changes: 3 additions & 3 deletions resources/views/components/nav-item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@


@php
$layout = $itemblocks->set->layout ?? '';
$alignment = $itemblocks->set->alignment ?? '';
$slider = $itemblocks->set->slider ?? '';
$layout = $itemblocks->layout ?? '';
$alignment = $itemblocks->alignment ?? '';
$slider = $itemblocks->slider ?? '';
@endphp
<nav-item class="flex items-center gap-2">
<span class="text-sm font-medium px-2.5 py-0.5 rounded bg-gray-300">Layout</span>
Expand Down
30 changes: 22 additions & 8 deletions src/Livewire/PagesData.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,26 @@ public function addoEmbed($blockId)

public function addBlock($blocktemplatesID, $name, $type, $iconclass = null)
{
// Layout *popout or full *** alignment* left or right

$blockTypeData = ['layout' => 'popout', 'alignment' => 'left', 'slider' => ''];

$tempBlock = Blocktemplates::where('id', $blocktemplatesID)->first();

$block = $this->page->blocks()->create([
'name' => $name,
'subgroup' => $this->blockgroupId,
'set' => $blockTypeData,
'status' => 'published',
'grid' => $tempBlock->grid ?? '1',
'iconclass' => $tempBlock->iconclass ?? $iconclass,
'type' => $type,
'order' => '999',
]);

$blockmeta = Block::find($block->id);
$blockmeta->saveMeta([
'layout' => 'popout',
'alignment' => 'left',
'slider' => ''
]);

if ($type == 'wysiwyg') {
Datafield::create([
'block_id' => $block->id,
Expand Down Expand Up @@ -278,16 +283,25 @@ public function updateGrid($id, $grid)
public function saveset($id, $set, $status)
{

$setblock = Block::findOrFail($id);
$setblock = Block::find($id);

if ($set == 'layout') {
$setblock->update(['set->layout' => $status]);
$setblock->deleteMeta('layout');
$setblock->saveMeta([
'layout' => $status,
]);
}
if ($set == 'alignment') {
$setblock->update(['set->alignment' => $status]);
$setblock->deleteMeta('alignment');
$setblock->saveMeta([
'alignment' => $status,
]);
}
if ($set == 'slider') {
$setblock->update(['set->slider' => $status]);
$setblock->deleteMeta('slider');
$setblock->saveMeta([
'slider' => $status
]);
}

$this->resetPageComponent();
Expand Down
28 changes: 20 additions & 8 deletions src/Livewire/PostsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,25 @@ public function selectitem($action, $itemId, $fieldOrPageName = null, $blockgrou

public function addBlock($blocktemplatesID, $name, $type, $grid = null, $iconclass = null)
{
// Layout *popout or full *** alignment* left or right

$blockTypeData = ['layout' => 'popout', 'alignment' => 'left', 'slider' => ''];

$tempBlock = Blocktemplates::where('id', $blocktemplatesID)->first();
$block = $this->post->blocks()->create([
'name' => $name,
'subgroup' => $this->blockgroupId,
'set' => $blockTypeData,

'status' => 'published',
'iconclass' => $tempBlock->iconclass ?? $iconclass,
'type' => $type,
'order' => '999',
]);

$blockmeta = Block::find($block->id);
$blockmeta->saveMeta([
'layout' => 'popout',
'alignment' => 'left',
'slider' => ''
]);

if ($type == 'wysiwyg') {
Datafield::create([
'block_id' => $block->id,
Expand Down Expand Up @@ -244,16 +250,22 @@ public function updateGrid($id, $grid)
public function saveset($id, $set, $status)
{

$setblock = Block::findOrFail($id);
$setblock = Block::find($id);

if ($set == 'layout') {
$setblock->update(['set->layout' => $status]);
$setblock->saveMeta([
'layout' => $status,
]);
}
if ($set == 'alignment') {
$setblock->update(['set->alignment' => $status]);
$setblock->saveMeta([
'alignment' => $status,
]);
}
if ($set == 'slider') {
$setblock->update(['set->slider' => $status]);
$setblock->saveMeta([
'slider' => $status
]);
}

$this->resetPageComponent();
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Kolossal\Multiplex\HasMeta;

class Block extends Model
{
use HasFactory;
use HasMeta;

protected $guarded = [];

protected $casts = ['set' => 'object'];

public static function boot()
{
parent::boot();
Expand Down
2 changes: 2 additions & 0 deletions src/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Kolossal\Multiplex\HasMeta;

class Page extends Model
{
use HasFactory;
use SoftDeletes;
use HasMeta;

protected $casts = [
'content' => 'array',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function up()
$table->string('blockable_id');
$table->string('blockable_type');
$table->string('subgroup')->nullable();
$table->text('set')->nullable();
$table->string('name');
$table->string('type');
$table->string('status')->nullable();
Expand Down

0 comments on commit a625d97

Please sign in to comment.