浏览代码

新增 DB(prize, recipients)

maa3606 2 年之前
父节点
当前提交
0557eb2936

+ 1 - 1
.env.example

@@ -11,7 +11,7 @@ LOG_LEVEL=debug
 DB_CONNECTION=sqlsrv
 DB_HOST=GMGIS\SQLEXPRESS
 DB_PORT=
-DB_DATABASE=permissions
+DB_DATABASE=
 DB_USERNAME=BIMuser
 DB_PASSWORD=Component3444
 

+ 86 - 0
app/Http/Controllers/PrizeController.php

@@ -0,0 +1,86 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\Prize;
+use App\Http\Requests\StorePrizeRequest;
+use App\Http\Requests\UpdatePrizeRequest;
+
+class PrizeController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \App\Http\Requests\StorePrizeRequest  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(StorePrizeRequest $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Http\Response
+     */
+    public function show(Prize $prize)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(Prize $prize)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \App\Http\Requests\UpdatePrizeRequest  $request
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Http\Response
+     */
+    public function update(UpdatePrizeRequest $request, Prize $prize)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(Prize $prize)
+    {
+        //
+    }
+}

+ 86 - 0
app/Http/Controllers/RecipientsController.php

@@ -0,0 +1,86 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\Recipients;
+use App\Http\Requests\StoreRecipientsRequest;
+use App\Http\Requests\UpdateRecipientsRequest;
+
+class RecipientsController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \App\Http\Requests\StoreRecipientsRequest  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(StoreRecipientsRequest $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Http\Response
+     */
+    public function show(Recipients $recipients)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(Recipients $recipients)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \App\Http\Requests\UpdateRecipientsRequest  $request
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Http\Response
+     */
+    public function update(UpdateRecipientsRequest $request, Recipients $recipients)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(Recipients $recipients)
+    {
+        //
+    }
+}

+ 30 - 0
app/Http/Requests/StorePrizeRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class StorePrizeRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array<string, mixed>
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 30 - 0
app/Http/Requests/StoreRecipientsRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class StoreRecipientsRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array<string, mixed>
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 30 - 0
app/Http/Requests/UpdatePrizeRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UpdatePrizeRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array<string, mixed>
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 30 - 0
app/Http/Requests/UpdateRecipientsRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UpdateRecipientsRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array<string, mixed>
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 18 - 0
app/Models/Prize.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Prize extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'activity_id',
+        'name',
+        'provider',
+        'count',
+    ];
+}

+ 17 - 0
app/Models/Recipients.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Recipients extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'prize_id',
+        'user_id',
+        'is_claimed',
+    ];
+}

+ 94 - 0
app/Policies/PrizePolicy.php

@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Policies;
+
+use App\Models\Prize;
+use App\Models\User;
+use Illuminate\Auth\Access\HandlesAuthorization;
+
+class PrizePolicy
+{
+    use HandlesAuthorization;
+
+    /**
+     * Determine whether the user can view any models.
+     *
+     * @param  \App\Models\User  $user
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function viewAny(User $user)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can view the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function view(User $user, Prize $prize)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can create models.
+     *
+     * @param  \App\Models\User  $user
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function create(User $user)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can update the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function update(User $user, Prize $prize)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can delete the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function delete(User $user, Prize $prize)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can restore the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function restore(User $user, Prize $prize)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can permanently delete the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Prize  $prize
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function forceDelete(User $user, Prize $prize)
+    {
+        //
+    }
+}

+ 94 - 0
app/Policies/RecipientsPolicy.php

@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Policies;
+
+use App\Models\Recipients;
+use App\Models\User;
+use Illuminate\Auth\Access\HandlesAuthorization;
+
+class RecipientsPolicy
+{
+    use HandlesAuthorization;
+
+    /**
+     * Determine whether the user can view any models.
+     *
+     * @param  \App\Models\User  $user
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function viewAny(User $user)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can view the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function view(User $user, Recipients $recipients)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can create models.
+     *
+     * @param  \App\Models\User  $user
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function create(User $user)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can update the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function update(User $user, Recipients $recipients)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can delete the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function delete(User $user, Recipients $recipients)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can restore the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function restore(User $user, Recipients $recipients)
+    {
+        //
+    }
+
+    /**
+     * Determine whether the user can permanently delete the model.
+     *
+     * @param  \App\Models\User  $user
+     * @param  \App\Models\Recipients  $recipients
+     * @return \Illuminate\Auth\Access\Response|bool
+     */
+    public function forceDelete(User $user, Recipients $recipients)
+    {
+        //
+    }
+}

+ 27 - 0
database/factories/PrizeFactory.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use \App\Models\User;
+
+/**
+ * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Prize>
+ */
+class PrizeFactory extends Factory
+{
+    /**
+     * Define the model's default state.
+     *
+     * @return array<string, mixed>
+     */
+    public function definition()
+    {
+        return [
+            'activity_id' => $this->faker->randomElement(User::query()->get('id')),
+            'name' => $this->faker->name(),
+            'provider' => '亞新',
+            'count' => $this->faker->numerify('##'),
+        ];
+    }
+}

+ 27 - 0
database/factories/RecipientsFactory.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace Database\Factories;
+
+use Illuminate\Database\Eloquent\Factories\Factory;
+use \App\Models\User;
+use \App\Models\Prize;
+
+/**
+ * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Recipients>
+ */
+class RecipientsFactory extends Factory
+{
+    /**
+     * Define the model's default state.
+     *
+     * @return array<string, mixed>
+     */
+    public function definition()
+    {
+        return [
+            'prize_id' => $this->faker->randomElement(Prize::query()->get('id')),
+            'user_id' => $this->faker->randomElement(User::query()->get('id')),
+            'is_claimed' => false,
+        ];
+    }
+}

+ 35 - 0
database/migrations/2023_02_02_064552_create_prizes_table.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('prizes', function (Blueprint $table) {
+            $table->id();
+            $table->string('activity_id');
+            $table->string('name');
+            $table->string('provider');
+            $table->integer('count');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('prizes');
+    }
+};

+ 34 - 0
database/migrations/2023_02_02_064840_create_recipients_table.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('recipients', function (Blueprint $table) {
+            $table->id();
+            $table->string('prize_id');
+            $table->string('user_id');
+            $table->boolean('is_claimed');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('recipients');
+    }
+};

+ 117 - 0
database/seeders/PrizeSeeder.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace Database\Seeders;
+
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+use Illuminate\Database\Seeder;
+use \App\Models\Prize;
+
+class PrizeSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        Prize::insert([
+            [
+                'activity_id' => '0',
+                'name' => '現金 16,800 元',
+                'provider' => '亞新',
+                'count' => 2,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '現金 12,000 元',
+                'provider' => '亞新',
+                'count' => 1,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '現金 10,000 元',
+                'provider' => '亞新',
+                'count' => 1,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '大潤發禮券 10,000 元',
+                'provider' => '亞新',
+                'count' => 4,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '現金 8,800 元',
+                'provider' => '亞新',
+                'count' => 5,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '大潤發禮券 8,000 元',
+                'provider' => '亞新',
+                'count' => 6,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '現金 6,600 元',
+                'provider' => '亞新',
+                'count' => 13,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '大潤發禮券 6,000 元',
+                'provider' => '亞新',
+                'count' => 10,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '大潤發禮券 3,000 元',
+                'provider' => '亞新',
+                'count' => 80,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '大潤發禮券 2,000 元',
+                'provider' => '亞新',
+                'count' => 50,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '福利即享券 2,000 元',
+                'provider' => '亞新',
+                'count' => 50,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'activity_id' => '0',
+                'name' => '普獎現金 1,200 元',
+                'provider' => '亞新',
+                'count' => 0,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+        ]);
+    }
+}

+ 35 - 0
database/seeders/RecipientsSeeder.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace Database\Seeders;
+
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+use Illuminate\Database\Seeder;
+use \App\Models\Recipients;
+
+class RecipientsSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        Recipients::insert([
+            [
+                'prize_id' => '0',
+                'user_id' => '3606',
+                'is_claimed' => true,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+            [
+                'prize_id' => '1',
+                'user_id' => '3606',
+                'is_claimed' => false,
+                'created_at' => now(),
+                'updated_at' => now(),
+            ],
+        ]);
+    }
+}

文件差异内容过多而无法显示
+ 154 - 33
package-lock.json


部分文件因为文件数量过多而无法显示