Lucius Vorenus
04/21/2023, 1:34 PMifox
04/21/2023, 3:42 PMLucius Vorenus
04/21/2023, 6:49 PMLucius Vorenus
04/21/2023, 6:58 PM<?php
/**
* @return Form
* TODO: update Wysiwyg type to tiptap when super and sub scripts enabled.
*/
public function getForm(): Form
{
return Form::make([
Input::make()
->name('title')
->label('Title')
->note('Text: max 200 characters')
->placeholder('Definitely need this!')
->maxLength(200)
->required(),
Wysiwyg::make()
->name('summary')
->label('Summary (Use as first para)')
->note('Text: prob 3-5 sentences. Used as summary in related article blocks etc')
->type('quill')
->toolbarOptions(['bold', 'italic', 'underline',
['script' => 'super'], ['script' => 'sub']])
->required(),
Input::make()
->name('author')
->label('Author')
->note('Articles always have an author, whether you or an alias!')
->maxLength(100)
->required(),
Input::make()
->name('reading-time')
->label('Approximate Reading time (mins)')
->note('Min:3, Max:20')
->type('number')
->min(3)
->max(20)
->required(),
Medias::make()
->name('cover')
->label('Cover Image')
->fieldNote('Used at the top of the article')
->required(),
Input::make()
->name('attribution')
->label('Attribution')
->note('Use of photos from sources (even free ones, except your own) requires an attribution.')
]);
}
}
Lucius Vorenus
04/21/2023, 7:00 PMLucius Vorenus
04/21/2023, 7:06 PMLucius Vorenus
04/21/2023, 7:10 PMifox
04/21/2023, 8:22 PM$article->title
.
Now, if you want to keep your current approach, you could do something as simple as:
$article->blocks->first()->content->summary
. But it's not robust to rely on the CMS user always putting the header block as the first block. So you could also do: $article->blocks->where('type', 'header')->first()->content->summary
. But then if the user puts 2 header blocks, what happens? I'm purposefully mentioning all this because this should help you understand why this information is not something you want to use a block for.ifox
04/21/2023, 8:22 PMsummary
and author
, directly accessible, not deeply nested under a specific block.ifox
04/21/2023, 8:26 PMifox
04/21/2023, 8:27 PMifox
04/21/2023, 8:27 PMifox
04/21/2023, 8:27 PMLucius Vorenus
04/22/2023, 7:45 AMLucius Vorenus
04/22/2023, 7:54 AM