New feature visibility - public/draft (#10)
* New feature visibility - public/draft * fix bg for dark mode
This commit is contained in:
@@ -21,7 +21,7 @@ class PublicFormController extends Controller
|
||||
|
||||
public function show(Request $request, string $slug)
|
||||
{
|
||||
$form = Form::whereSlug($slug)->firstOrFail();
|
||||
$form = Form::whereSlug($slug)->whereVisibility('public')->firstOrFail();
|
||||
if ($form->workspace == null) {
|
||||
// Workspace deleted
|
||||
return $this->error([
|
||||
|
||||
@@ -40,7 +40,7 @@ class AnswerFormRequest extends FormRequest
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return !$this->form->is_closed && !$this->form->max_number_of_submissions_reached;
|
||||
return !$this->form->is_closed && !$this->form->max_number_of_submissions_reached && $this->form->visibility === 'public';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
|
||||
'title' => 'required|string|max:60',
|
||||
'description' => 'nullable|string|max:2000',
|
||||
'tags' => 'nullable|array',
|
||||
'visibility' => ['required',Rule::in(Form::VISIBILITY)],
|
||||
|
||||
// Notifications
|
||||
'notifies' => 'boolean',
|
||||
|
||||
@@ -42,6 +42,7 @@ class FormResource extends JsonResource
|
||||
'can_be_indexed' => $this->can_be_indexed,
|
||||
'password' => $this->password,
|
||||
'tags' => $this->tags,
|
||||
'visibility' => $this->visibility,
|
||||
'notification_emails' => $this->notification_emails,
|
||||
'slack_webhook_url' => $this->slack_webhook_url,
|
||||
] : [];
|
||||
|
||||
@@ -20,6 +20,7 @@ class Form extends Model
|
||||
const DARK_MODE_VALUES = ['auto', 'light', 'dark'];
|
||||
const THEMES = ['default', 'simple', 'notion'];
|
||||
const WIDTHS = ['centered', 'full'];
|
||||
const VISIBILITY = ['public', 'draft'];
|
||||
|
||||
use HasFactory, HasSlug, SoftDeletes;
|
||||
|
||||
@@ -45,6 +46,7 @@ class Form extends Model
|
||||
'title',
|
||||
'description',
|
||||
'tags',
|
||||
'visibility',
|
||||
|
||||
// Customization
|
||||
'theme',
|
||||
|
||||
Reference in New Issue
Block a user