alex123x5
alex123x5
FFilament
Created by alex123x5 on 11/28/2023 in #❓┊help
Call to undefined method App\Models\Appointment::name()
Hi all, I am trying to create a new appointment but I am getting the error that the method name() is undefined. I don't know where this is comming from. This is my source code: Model
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Appointment extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'phone',
'status',
'date',
'time',
'message',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'date' => 'date',
'time' => 'time',
'created_at' => 'datetime',
'updated_at' => 'datetime'
];

/**
* Get the services for the appointment.
*
* @return BelongsToMany
*/
public function services(): BelongsToMany
{
return $this->belongsToMany(Service::class, 'appointment_service');
}
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Appointment extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'phone',
'status',
'date',
'time',
'message',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'date' => 'date',
'time' => 'time',
'created_at' => 'datetime',
'updated_at' => 'datetime'
];

/**
* Get the services for the appointment.
*
* @return BelongsToMany
*/
public function services(): BelongsToMany
{
return $this->belongsToMany(Service::class, 'appointment_service');
}
}
AppointmentResource
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Fieldset::make()
->label(label: __(key: 'Client Details'))
->schema([
Forms\Components\TextInput::make(name: 'name')
->autofocus()
->required()
->columnSpan(span: 1)
->placeholder(placeholder: __(key: 'Name')),

Forms\Components\TextInput::make(name: 'email')
->required()
->type(type: 'email')
->columnSpan(span: 1)
->placeholder(placeholder: __(key: 'Email')),

Forms\Components\TextInput::make(name: 'phone')
->required()
->type(type: 'tel')
->columnSpan(span: 2)
->placeholder(placeholder: __(key: 'Phone')),
])->columns(),

Forms\Components\Fieldset::make()
->label(label: __(key: 'Appointment Details'))
->schema([
Forms\Components\Datepicker::make(name: 'date')
->required()
->columnSpan(span: 1)
->placeholder(placeholder: __(key: 'Date')),

Forms\Components\Timepicker::make(name: 'time')
->required()
->columnSpan(span: 1)
->placeholder(placeholder: __(key: 'Time')),

Forms\Components\CheckboxList::make(name: 'services')
->required()
->relationship(name: 'name', titleAttribute: 'name')
->options(Service::all()->pluck('name', 'id')->toArray())
->columnSpan(span: 2)
])->columns(),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Fieldset::make()
->label(label: __(key: 'Client Details'))
->schema([
Forms\Components\TextInput::make(name: 'name')
->autofocus()
->required()
->columnSpan(span: 1)
->placeholder(placeholder: __(key: 'Name')),

Forms\Components\TextInput::make(name: 'email')
->required()
->type(type: 'email')
->columnSpan(span: 1)
->placeholder(placeholder: __(key: 'Email')),

Forms\Components\TextInput::make(name: 'phone')
->required()
->type(type: 'tel')
->columnSpan(span: 2)
->placeholder(placeholder: __(key: 'Phone')),
])->columns(),

Forms\Components\Fieldset::make()
->label(label: __(key: 'Appointment Details'))
->schema([
Forms\Components\Datepicker::make(name: 'date')
->required()
->columnSpan(span: 1)
->placeholder(placeholder: __(key: 'Date')),

Forms\Components\Timepicker::make(name: 'time')
->required()
->columnSpan(span: 1)
->placeholder(placeholder: __(key: 'Time')),

Forms\Components\CheckboxList::make(name: 'services')
->required()
->relationship(name: 'name', titleAttribute: 'name')
->options(Service::all()->pluck('name', 'id')->toArray())
->columnSpan(span: 2)
])->columns(),
]);
}
7 replies
FFilament
Created by alex123x5 on 9/25/2023 in #❓┊help
Change placement of tenancies in top navigation
Hi, I want to move the team selector from when using multi-tenancy to the right. Is this possible or not?
2 replies
FFilament
Created by alex123x5 on 9/19/2023 in #❓┊help
Check if value is true, and check the checkbox on update
I have a multi tenancy setup. But when i want to edit an tenancy I want to have all checkboxes checked if they are true in the json object from the database. How can I do this?
CheckboxList::make('settings')
->options([
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'whatsapp' => 'WhatsApp',
'email' => 'Email',
'copy' => 'Copy',
])
->descriptions([
'twitter' => 'Enable sharing on Twitter (x)',
'linkedin' => 'Enable sharing on LinkedIn',
'whatsapp' => 'Enable sharing on WhatsApp',
'email' => 'Enable sharing on Email',
'copy' => 'Enable sharing through coping the link',
])
CheckboxList::make('settings')
->options([
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'whatsapp' => 'WhatsApp',
'email' => 'Email',
'copy' => 'Copy',
])
->descriptions([
'twitter' => 'Enable sharing on Twitter (x)',
'linkedin' => 'Enable sharing on LinkedIn',
'whatsapp' => 'Enable sharing on WhatsApp',
'email' => 'Enable sharing on Email',
'copy' => 'Enable sharing through coping the link',
])
{
"copy": false,
"email": false,
"twitter": true,
"linkedin": false,
"whatsapp": false
}
{
"copy": false,
"email": false,
"twitter": true,
"linkedin": false,
"whatsapp": false
}
So if in this example twitter is true, then I want to have the checkbox for twitter checked. Is this possible?
8 replies