Closed ShariqAyaz closed 4 months ago
Hello @ShariqAyaz
Can you share your model, migration and some values of "status" column.
Cheers.
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');
}
};
Hello @ShariqAyaz i check this in my side and bind is working correctly, you can check my answer here
Cheers.
I will close this issue, we can continue here because is the same report and was answer.
Cheers.
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.
What happened
Is saying Undefined
What I've already tried to fix it
Is it a bug in the latest version of Backpack?