Created API endpoints
This commit is contained in:
45
app/Models/Answer.php
Normal file
45
app/Models/Answer.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Answer extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'updated_at',
|
||||
'created_at',
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'choice',
|
||||
'text',
|
||||
'respondent_id',
|
||||
'question_id',
|
||||
'questionchoice_id'
|
||||
];
|
||||
|
||||
public function question()
|
||||
{
|
||||
return $this->belongsTo(Question::class);
|
||||
}
|
||||
|
||||
public function questionchoice()
|
||||
{
|
||||
return $this->belongsTo(Questionchoice::class);
|
||||
}
|
||||
|
||||
public function respondent()
|
||||
{
|
||||
return $this->belongsTo(Respondent::class);
|
||||
}
|
||||
}
|
||||
27
app/Models/Category.php
Normal file
27
app/Models/Category.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'updated_at',
|
||||
'created_at',
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'creator_id');
|
||||
}
|
||||
}
|
||||
42
app/Models/Question.php
Normal file
42
app/Models/Question.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Question extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'updated_at',
|
||||
'created_at',
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
public function section()
|
||||
{
|
||||
return $this->belongsTo(Section::class);
|
||||
}
|
||||
|
||||
public function choices()
|
||||
{
|
||||
return $this->hasMany(Questionchoice::class);
|
||||
}
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function answers()
|
||||
{
|
||||
return $this->hasMany(Answer::class);
|
||||
}
|
||||
}
|
||||
27
app/Models/Questionchoice.php
Normal file
27
app/Models/Questionchoice.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Questionchoice extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'updated_at',
|
||||
'created_at',
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
public function question()
|
||||
{
|
||||
return $this->belongsTo(Question::class);
|
||||
}
|
||||
}
|
||||
45
app/Models/Questionnaire.php
Normal file
45
app/Models/Questionnaire.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Questionnaire extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'updated_at',
|
||||
'released_at',
|
||||
'created_at',
|
||||
'closed_at',
|
||||
'reviewed_at',
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
public function sections()
|
||||
{
|
||||
return $this->hasMany(Section::class);
|
||||
}
|
||||
|
||||
public function questions()
|
||||
{
|
||||
return $this->hasManyThrough(Question::class, Section::class);
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
27
app/Models/Respondent.php
Normal file
27
app/Models/Respondent.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Respondent extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'updated_at',
|
||||
'created_at',
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
}
|
||||
42
app/Models/Section.php
Normal file
42
app/Models/Section.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Section extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'updated_at',
|
||||
'created_at',
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
public function questionnaire()
|
||||
{
|
||||
return $this->belongsTo(Questionnaire::class);
|
||||
}
|
||||
|
||||
public function questions()
|
||||
{
|
||||
return $this->hasMany(Question::class);
|
||||
}
|
||||
|
||||
public function choices()
|
||||
{
|
||||
return $this->hasManyThrough(Choice::class, Question::class);
|
||||
}
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'updated_at',
|
||||
'created_at',
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
use Notifiable;
|
||||
|
||||
protected $table = "users";
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user