Allow users to create private form templates (#210)
* Allow users to create private form templates * Improve back-end efficiency --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -14,6 +14,7 @@ class Template extends Model
|
||||
use HasFactory, HasSlug;
|
||||
|
||||
protected $fillable = [
|
||||
'creator_id',
|
||||
'name',
|
||||
'slug',
|
||||
'description',
|
||||
@@ -41,6 +42,15 @@ class Template extends Model
|
||||
'publicly_listed' => false,
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'share_url',
|
||||
];
|
||||
|
||||
public function getShareUrlAttribute()
|
||||
{
|
||||
return url('/form-templates/'.$this->slug);
|
||||
}
|
||||
|
||||
public function setDescriptionAttribute($value)
|
||||
{
|
||||
// Strip out unwanted html
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Http\Controllers\SubscriptionController;
|
||||
use App\Models\Forms\Form;
|
||||
use App\Models\Template;
|
||||
use App\Notifications\ResetPassword;
|
||||
use App\Notifications\VerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -140,6 +141,11 @@ class User extends Authenticatable implements JWTSubject
|
||||
return $this->hasMany(Form::class,'creator_id');
|
||||
}
|
||||
|
||||
public function formTemplates()
|
||||
{
|
||||
return $this->hasMany(Template::class, 'creator_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* =================================
|
||||
* Oauth Related
|
||||
|
||||
Reference in New Issue
Block a user