-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created Shop table in db with updated data types, add model file, and…
… controller file
- Loading branch information
Showing
3 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
50
database/migrations/2024_10_05_080533_create_shops_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |