Skip to content

Commit

Permalink
Created Shop table in db with updated data types, add model file, and…
Browse files Browse the repository at this point in the history
… controller file
  • Loading branch information
meowfu0 committed Oct 5, 2024
1 parent 1af892e commit cfc5fba
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
85 changes: 85 additions & 0 deletions app/Http/Controllers/ShopController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace App\Http\Controllers;

use App\Models\Shop;
use Illuminate\Http\Request;

class ShopController 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 \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param \App\Models\Shop $shop
* @return \Illuminate\Http\Response
*/
public function show(Shop $shop)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Shop $shop
* @return \Illuminate\Http\Response
*/
public function edit(Shop $shop)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Shop $shop
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Shop $shop)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param \App\Models\Shop $shop
* @return \Illuminate\Http\Response
*/
public function destroy(Shop $shop)
{
//
}
}
11 changes: 11 additions & 0 deletions app/Models/Shop.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Shop extends Model
{
use HasFactory;
}
50 changes: 50 additions & 0 deletions database/migrations/2024_10_05_080533_create_shops_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateShopsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('shops', function (Blueprint $table) {
$table->id();

// Nullable timestamps
$table->timestamp('created_at')->useCurrent();
$table->timestamp('modified_at')->nullable()->useCurrentOnUpdate();
$table->timestamp('deleted_at')->nullable();

// Other fields
$table->string('shop_name', 255);
$table->text('shop_description');
$table->string('shop_logo', 255)->nullable();

// Foreign keys with not null and cascade on delete
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('status_id');
$table->unsignedBigInteger('course_id');

// Foreign key constraints with cascading on delete
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('status_id')->references('id')->on('statuses')->onDelete('cascade');
$table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('shops');
}
}

0 comments on commit cfc5fba

Please sign in to comment.