Edit Item DB structure

This commit is contained in:
Mathieu Lagace
2019-08-27 13:36:55 -04:00
parent 615752d61a
commit 509a135e74
6 changed files with 146 additions and 2 deletions

View File

@@ -0,0 +1,85 @@
<?php
namespace App\Http\Controllers;
use App\ItemCategory;
use Illuminate\Http\Request;
class ItemCategoryController 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\ItemCategory $itemCategory
* @return \Illuminate\Http\Response
*/
public function show(ItemCategory $itemCategory)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\ItemCategory $itemCategory
* @return \Illuminate\Http\Response
*/
public function edit(ItemCategory $itemCategory)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\ItemCategory $itemCategory
* @return \Illuminate\Http\Response
*/
public function update(Request $request, ItemCategory $itemCategory)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\ItemCategory $itemCategory
* @return \Illuminate\Http\Response
*/
public function destroy(ItemCategory $itemCategory)
{
//
}
}

View File

@@ -18,8 +18,17 @@ class Item extends Model
return $col_items;
}
protected $casts = [
'metadata' => 'array',
];
public function bookings()
{
return $this->hasMany('App\Booking');
}
public function category()
{
return \App\ItemCategory::find($this->category_id);
}
}

13
app/ItemCategory.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ItemCategory extends Model
{
public function items()
{
return $this->hasMany('App\Item','category_id');
}
}

View File

@@ -15,9 +15,12 @@ class CreateItemsTable extends Migration
{
Schema::create('items', function (Blueprint $table) {
$table->increments('id');
$table->integer('category_id');
$table->integer('quantity');
$table->string('name');
$table->string('official_number');
$table->string('desc');
$table->text('metadata');
$table->timestamps();
});
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateItemCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('item_categories', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('desc');
$table->boolean('is_training');
$table->boolean('is_op_appro');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('item_categories');
}
}

View File

@@ -69,7 +69,6 @@
<p> Horaire</p>
</a>
</li>
<!--
<li class="nav-item ">
<a class="nav-link" data-toggle="collapse" href="#inventory">
<i class="material-icons">shopping_basket</i>
@@ -99,7 +98,7 @@
</li>
</ul>
</div>
</li>-->
</li>
<li class="nav-item ">
<a class="nav-link" data-toggle="collapse" href="#inventory">
<i class="material-icons">image</i>