feat: membuat skema table untuk show harga beli
This commit is contained in:
parent
808f385b22
commit
d6a0422014
16
app/Http/Controllers/Studio/PriceRequestController.php
Normal file
16
app/Http/Controllers/Studio/PriceRequestController.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Studio;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\PriceRequest;
|
||||
|
||||
class PriceRequestController extends Controller
|
||||
{
|
||||
public function approve(PriceRequest $priceRequest)
|
||||
{
|
||||
$priceRequest->update(['approved_at' => now()]);
|
||||
|
||||
return redirect()->route('studio.dashboard.overview');
|
||||
}
|
||||
}
|
||||
20
app/Models/PriceRequest.php
Normal file
20
app/Models/PriceRequest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Veelasky\LaravelHashId\Eloquent\HashableId;
|
||||
|
||||
class PriceRequest extends Model
|
||||
{
|
||||
use HashableId, SoftDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@ -96,4 +96,9 @@ public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function priceRequests(): HasMany
|
||||
{
|
||||
return $this->hasMany(PriceRequest::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('price_requests', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('model', 20);
|
||||
$table->string('signature')->unique()->nullable();
|
||||
$table->timestamp('last_requested_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('price_requests');
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user