first commit
This commit is contained in:
53
app/Models/Articolo.php
Normal file
53
app/Models/Articolo.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Articolo extends Model
|
||||
{
|
||||
protected $table = 'articoli';
|
||||
|
||||
protected $fillable = [
|
||||
'codice_articolo',
|
||||
'ciclo',
|
||||
'diametro',
|
||||
'descrizione',
|
||||
'posizione',
|
||||
'quantita',
|
||||
'tipo_lavorazione',
|
||||
'materiale_lavorare',
|
||||
'maximum_thickness',
|
||||
'speed_rpm',
|
||||
'feed',
|
||||
'max_thrust_a',
|
||||
'min_torque_a',
|
||||
'quantita_fori',
|
||||
'qr_code',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'quantita' => 'integer',
|
||||
'speed_rpm' => 'integer',
|
||||
'feed' => 'decimal:2',
|
||||
'quantita_fori' => 'integer',
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::created(function ($articolo) {
|
||||
if (empty($articolo->qr_code)) {
|
||||
// Formato: id-timestamp (es: 42-1737235200)
|
||||
$articolo->qr_code = $articolo->id . '-' . time();
|
||||
$articolo->saveQuietly();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getQrUrlAttribute(): string
|
||||
{
|
||||
return $this->qr_code;
|
||||
}
|
||||
}
|
||||
48
app/Models/User.php
Normal file
48
app/Models/User.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user