marcofalabretti пре 12 часа
родитељ
комит
fa032c8a2f

+ 32
- 0
app/Http/Controllers/VariatePiattoController.php Прегледај датотеку

@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Models\VariantePiatto;
7
+
8
+class VariantePiattoController extends Controller
9
+{
10
+    public static $permission_group = "Varianti Piatto";
11
+    public static $permissions = [
12
+        'view-variante-piatto' => 'Vedi',
13
+        'create-variante-piatto' => 'Crea',
14
+        'edit-variante-piatto' => 'Modifica',
15
+        'delete-variante-piatto' => 'Elimina',
16
+    ];
17
+
18
+    public static function middleware(): array
19
+    {
20
+        return [
21
+            new Middleware('permission:view-variante-piatto', only: ['index']),
22
+            new Middleware('permission:create-variante-piatto|edit-variante-piatto|delete-variante-piatto', only: ['store', 'update', 'destroy']),
23
+        ];
24
+    }
25
+
26
+    public function index(VariantePiattoDataTable $dataTable)
27
+    {
28
+        $dataTable->attivita_id = Session::get('attivita_attuale');
29
+        return $dataTable->render('variante_piatto.index');
30
+    }
31
+
32
+}

+ 74
- 0
app/Models/AbstractModels/AbstractVariantePiatto.php Прегледај датотеку

@@ -0,0 +1,74 @@
1
+<?php
2
+/**
3
+ * Model object generated by: Skipper (http://www.skipper18.com)
4
+ * Do not modify this file manually.
5
+ */
6
+
7
+namespace App\Models\AbstractModels;
8
+
9
+abstract class AbstractVariantePiatto extends \Illuminate\Foundation\Auth\User
10
+{
11
+    /**  
12
+     * The table associated with the model.
13
+     * 
14
+     * @var string
15
+     */
16
+    protected $table = 'variante_piatto';
17
+    
18
+    /**  
19
+     * Primary key type.
20
+     * 
21
+     * @var string
22
+     */
23
+    protected $keyType = 'bigInteger';
24
+    
25
+    /**  
26
+     * The model's default values for attributes.
27
+     * 
28
+     * @var array
29
+     */
30
+    // protected $attributes = ['is_gruppo' => 0];
31
+    
32
+    /**  
33
+     * The attributes that should be cast to native types.
34
+     * 
35
+     * @var array
36
+     */
37
+    protected $casts = [
38
+        'id' => 'integer',
39
+        'attivita_id' => 'integer',
40
+        'piatto_id' => 'integer',
41
+        'label' => 'string',
42
+        'prezzo' => 'decimal:2',
43
+        'is_attivo' => 'boolean',
44
+        'created_at' => 'datetime',
45
+        'updated_at' => 'datetime'
46
+    ];
47
+    
48
+    /**  
49
+     * The attributes that are mass assignable.
50
+     * 
51
+     * @var array
52
+     */
53
+    protected $fillable = [
54
+        'id',
55
+        'attivita_id',
56
+        'piatto_id',
57
+        'label',
58
+        'prezzo',
59
+        'is_attivo',
60
+        'created_at',
61
+        'updated_at'
62
+    ];
63
+    
64
+    public function attivita()
65
+    {
66
+        return $this->belongsTo('\App\Models\Attivita', 'attivita_id', 'id');
67
+    }
68
+
69
+    public function piatto()
70
+    {
71
+        return $this->belongsTo('\App\Models\Piatto', 'piatto_id', 'id');
72
+    }
73
+    
74
+}

+ 14
- 0
app/Models/VariantePiatto.php Прегледај датотеку

@@ -0,0 +1,14 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class VariantePiatto extends \App\Models\AbstractModels\AbstractVariantePiatto
8
+{
9
+
10
+    public function isGlobal()
11
+    {
12
+        return is_null($this->piatto_id);
13
+    }
14
+}

+ 32
- 0
database/migrations/2026_06_20_143147_create_variantes_table.php Прегледај датотеку

@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::create('variante_piatto', function (Blueprint $table) {
15
+            $table->id();
16
+            $table->bigInteger('attivita_id')->unsigned();
17
+            $table->bigInteger('piatto_id')->unsigned()->nullable();
18
+            $table->string('label')->nullable();
19
+            $table->decimal('prezzo', 10, 2)->nullable();
20
+            $table->boolean('is_attivo')->default(true);
21
+            $table->timestamps();
22
+        });
23
+    }
24
+
25
+    /**
26
+     * Reverse the migrations.
27
+     */
28
+    public function down(): void
29
+    {
30
+        Schema::dropIfExists('variante_piatto');
31
+    }
32
+};

Loading…
Откажи
Сачувај