Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

[Bug] Issues on "backpack/calendar-operation" #1035

Closed ShariqAyaz closed 4 months ago

ShariqAyaz commented 5 months ago

Bug report

What I did

By book it suppose to bind database fields with Calender key-value pair

What I expected to happen

It suppose to bind my actual field names with Calender keys.

    protected function getCalendarFieldsMap()
    {
        return [
            **'title' => 'status',** // this one
            'start' => 'start',
            'end' => 'end',
            'background_color' => 'background_color',
            'text_color' => 'text_color',
            'all_day' => 'all_day',
        ];
    }

What happened

Is saying Undefined

image

What I've already tried to fix it

Is it a bug in the latest version of Backpack?


### PHP VERSION:
8.2.19

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, apcu, bcmath, bz2, calendar, ctype, curl, dba, dom, enchant, mbstring, FFI, fileinfo, ftp, gd, gettext, gmp, i360, iconv, igbinary, imagick, imap, intl, exif, mongodb, msgpack, mysqli, odbc, pdo_dblib, PDO_Firebird, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, redis, shmop, SimpleXML, soap, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, xmlreader, xmlrpc, xmlwriter, xsl, zip, memcached, Zend OPcache

### LARAVEL VERSION:
10.48.8.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.4
backpack/calendar-operation: 1.0.5
backpack/crud: 6.7.12
backpack/generators: v4.0.5
backpack/permissionmanager: 7.2.1
backpack/pro: 2.2.3
backpack/theme-coreuiv4: 1.1.1
jcastroa87 commented 5 months ago

Hello @ShariqAyaz

Can you share your model, migration and some values of "status" column.

Cheers.

ShariqAyaz commented 5 months ago

mot_bookings_202406141642___s.csv Model:

<?php

namespace App\Models;

use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class MOTBooking extends Model
{
    use CrudTrait;
    use HasFactory;

    protected $fillable = [
        'branch_id',
        'title',
        'vehicle_registration',
        'vehicle_chassis',
        'vehicle_color',
        'date_of_appointment',
        'start',
        'end',
        'customer_name',
        'customer_contact',
        'customer_email',
        'status',
        'notes',
        'background_color',
        'text_color',
        'all_day',
    ];

    protected $table = 'mot_bookings';

    public function branch()
    {
        return $this->belongsTo(Branch::class);
    }

    public function getRouteKeyName()
    {
        return 'vehicle_registration';
    }

    public function scopePending($query)
    {
        return $query->where('status', 'pending');
    }

    public function scopeCompleted($query)
    {
        return $query->where('status', 'completed');
    }

    public function scopeCancelled($query)
    {
        return $query->where('status', 'cancelled');
    }

    public function isPending()
    {
        return $this->status === 'pending';
    }

    public function isCompleted()
    {
        return $this->status === 'completed';
    }

    public function isCancelled()
    {
        return $this->status === 'cancelled';
    }

    public function markAsCompleted()
    {
        $this->status = 'completed';
        $this->save();
    }

    public function markAsCancelled()
    {
        $this->status = 'cancelled';
        $this->save();
    }
}

migration:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{

    public function up(): void
    {
        Schema::create('mot_bookings', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('branch_id')->nullable(false);
            $table->foreign('branch_id')->references('id')->on('branches')->onDelete('restrict');
            $table->string('title')->nullable()->default('MOT Booking');
            $table->dateTime('date_of_appointment')->default(now());
            $table->dateTime('start')->nullable();
            $table->dateTime('end')->nullable();
            $table->string('vehicle_registration');
            $table->string('vehicle_chassis')->nullable();
            $table->string('vehicle_color')->nullable();
            $table->boolean('all_day')->nullable(true)->default(false);
            $table->string('customer_name');
            $table->string('customer_contact');
            $table->string('customer_email');
            $table->enum('status', ['pending', 'available', 'completed', 'cancelled'])->default('available');
            $table->text('notes')->nullable(true);
            $table->string('background_color')->default('white');
            $table->string('text_color')->default('black');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('mot_bookings');
    }
};
ShariqAyaz commented 5 months ago

mot_bookings_202406141642___s.csv

jcastroa87 commented 4 months ago

Hello @ShariqAyaz i check this in my side and bind is working correctly, you can check my answer here

Cheers.

jcastroa87 commented 4 months ago

I will close this issue, we can continue here because is the same report and was answer.

Cheers.