Script erstellt
This commit is contained in:
48
app/Models/NailPolish.php
Executable file
48
app/Models/NailPolish.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NailPolish extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Die Tabelle, die dem Model zugeordnet ist.
|
||||
*/
|
||||
protected $table = 'nail_polishes';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'number',
|
||||
'manufacturer_id',
|
||||
'image_path',
|
||||
];
|
||||
|
||||
/**
|
||||
* Beziehung zu Benutzern
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'user_nail_polishes', 'nail_polish_id', 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Beziehung zum Hersteller
|
||||
*/
|
||||
public function manufacturer()
|
||||
{
|
||||
return $this->belongsTo(Manufacturer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope für Suche nach Name oder Nummer
|
||||
*/
|
||||
public function scopeSearch($query, $search)
|
||||
{
|
||||
return $query->where('name', 'like', "%{$search}%")
|
||||
->orWhere('number', 'like', "%{$search}%");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user