ifox
02/14/2023, 6:31 PMifox
02/14/2023, 6:32 PMjefsev
02/14/2023, 6:34 PMjefsev
02/14/2023, 6:34 PMjefsev
02/14/2023, 7:49 PMifox
02/14/2023, 8:30 PMgetNestedSlug
?dakaalim
02/15/2023, 6:08 AMthingasd
02/15/2023, 6:47 AMdakaalim
02/15/2023, 6:55 AMBA7YA
02/15/2023, 8:24 AMjefsev
02/15/2023, 9:25 AMjefsev
02/15/2023, 9:27 AMclass PageController extends BaseModuleController
{
protected $moduleName = 'pages';
public $permalinkBase = '';
protected $indexOptions = [
'reorder' => true,
];
protected $nestedItemsDepth = 4;
protected function form($id, $item = null):array
{
$item = $this->repository->getById($id, $this->formWith, $this->formWithCount);
$this->permalinkBase = $item->ancestorsSlug;
return parent::form($id, $item);
}
}
ifox
02/15/2023, 10:28 AMifox
02/15/2023, 10:35 AMifox
02/15/2023, 10:36 AMjefsev
02/15/2023, 10:47 AMjefsev
02/15/2023, 12:12 PMkerkness
02/15/2023, 1:14 PM// mimic format of admin PUT request
$ta['name'] = $data[0];
$ta['active'] = 1; // seems required for translations
$ta['summary'] = $data[5]; // translatable input
// Block content doesn't get created
$ta['blocks'][] = [
'id' => now(),
'content' => $data[7],
'type' => "a17-block-app-text",
'is_repeater' => false,
'editor_name' => 'default'
];
$twillArtist = TwillArtist::create($ta);
$twillArtist->setSlugs();
$twillArtist->save();
kalle
02/15/2023, 1:20 PMprepareFieldsBeforeSave
. That method is called multiple times, firstly on the form save and for every block after. You can try with the Log
facade to log that or Ray if you use it. Dont dd
, it wont reach blocks.ifox
02/15/2023, 1:53 PMifox
02/15/2023, 1:54 PMblockable_id
and blockable_type
valueskerkness
02/15/2023, 2:37 PMkerkness
02/15/2023, 3:39 PM$twillArtist = TwillArtist::create($ta);
$twillArtist->setSlugs();
$twillArtist->save();
$block = [
'content' => ['content' => ['en' => '<p>THIS IS SOMETHING</p>']],
'type' => "app-text",
'position' => 1,
'editor_name' => 'default',
'blockable_id' => $twillArtist->id,
'blockable_type' => TwillArtist::class,
];
$blocked = Block::create($block);
ifox
02/15/2023, 3:41 PMkerkness
02/15/2023, 3:43 PMkerkness
02/15/2023, 3:56 PMgetMorphClass
method. I'll do this for my larger package as well as I use polymorph relationships on a bunch of modelsVadimG
02/15/2023, 7:44 PMOlivier
02/16/2023, 3:47 PMdakaalim
02/17/2023, 10:17 AMfabiancz
02/19/2023, 11:20 AM