@Tikit

Как отправить дату в нужном формате в базу данных используя Carbon?

Здравствуйте, помогите разобраться с этим вопросом. Есть у меня "Календарь" на него повесил v-model="verification to". Когда выбираю дату например "21.06.2023"и отправляю в базу данных то выдаёт 500 ошибку, где написано "verification to: "2023-06-20T18:00:00.000Z". Помогите понять, как использовать "Carbon", для отправки даты в Базу данных в нужном формате?

Календарь
<Calendar v-model="verification_to" dateFormat=" yy.mm. dd " />


Код
<script>
import { ref } from "vue";
const date = ref();

export default {
    name: "EditPoverkaComponent",
    data() {
        return {
            id: null, 
            name: null,
            organ: null, 
            price: null, 
            certificate: null, 
            verification_from: null, 
            verification_to: null, 
            comment: null, 
            Instrumentation_id: null, 
        }
    },
    mounted() {
        this.getReceiving();
    },
    methods: {
        Add() { 
            axios.post('/api/Instrumentations/pov/', {
                id: this.id,
                name: this.name,
                organ: this.organ,
                price: this.price,
                certificate: this.certificate,
                verification_from: this.verification_from,
                verification_to: this.verification_to,
                comment: this.comment,
                Instrumentation_id: this.Instrumentation_id
            }) 
                .then(res => {
                    this.id = null
                    // this.name = null
                    this.organ = null
                    this.price = null
                    this.certificate = null
                    this.verification_from = null
                    this.verification_to = null
                    this.comment = null
                    // this.Instrumentation_id = null

                })
        },
        getReceiving() {
            axios.get('/api/Instrumentations/' + this.$route.params.id)
                .then(res => {
                    this.Instrumentation_id = res.data.data.id
                    this.name = res.data.data.name
                })
        },
    }
}
</script>


Контроллер
class VerificationController extends Controller
{
   public function __invoke(VerificationRequest $request)
   {
       $data = $request->validated();
       Verification::create ($data);
       return response([]);
   }
}


Модель
class Verification extends Model
{
    use HasFactory;
    protected $guarded = false;
    protected $table = 'verifications';
}
  • Вопрос задан
  • 66 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы