2021-08-10 12:09:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
2023-09-06 17:24:53 +02:00
|
|
|
/**
|
|
|
|
|
* @property integer $id Id.
|
|
|
|
|
* @property string $answer Answer.
|
|
|
|
|
* @property integer $question_id Foreign key Question.
|
|
|
|
|
* @property-read \Illuminate\Support\Carbon $created_at Created date.
|
|
|
|
|
* @property-read \Illuminate\Support\Carbon $updated_at Updated date.
|
|
|
|
|
*
|
|
|
|
|
* @property-read \App\Models\Question $question Question BelongsTo relation.
|
|
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<App\Models\Customer>
|
|
|
|
|
* $customers Customer BelongsToMany relation.
|
|
|
|
|
*/
|
2021-08-10 12:09:49 +02:00
|
|
|
class Answer extends Model
|
|
|
|
|
{
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var string[]
|
|
|
|
|
*/
|
2021-08-10 12:09:49 +02:00
|
|
|
protected $fillable = [
|
2023-09-04 13:08:34 +02:00
|
|
|
'answer',
|
2021-08-10 12:09:49 +02:00
|
|
|
];
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
// * RELATIONS
|
|
|
|
|
|
2021-08-10 12:09:49 +02:00
|
|
|
/**
|
2023-09-06 17:24:53 +02:00
|
|
|
* Question BelongsTo relation.
|
2021-08-10 12:09:49 +02:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
|
*/
|
2023-09-06 17:24:53 +02:00
|
|
|
public function question(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
2021-08-10 12:09:49 +02:00
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Question::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-09-06 17:24:53 +02:00
|
|
|
* Customer belongsToMany relation.
|
2021-08-10 12:09:49 +02:00
|
|
|
*
|
2021-08-11 17:25:24 +02:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
2021-08-10 12:09:49 +02:00
|
|
|
*/
|
2023-09-06 17:24:53 +02:00
|
|
|
public function customers(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
2021-08-10 12:09:49 +02:00
|
|
|
{
|
2021-08-11 17:25:24 +02:00
|
|
|
return $this->belongsToMany(Customer::class, 'customer_answer');
|
2021-08-10 12:09:49 +02:00
|
|
|
}
|
|
|
|
|
}
|