我使用Backpack for Laravel來提供我的laravel網站的後端區域。在窗體中添加一個 - 揹包laravel
我有以下表在我的數據庫結構:
這是套增加了一根火柴,火柴添加到比賽。
這些都是我模式:
錦標賽型號:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
class Tournament extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $fillable = ['from', 'to', 'type', 'location', 'place'];
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function matches()
{
return $this->hasMany('App\Models\Match');
}
}
匹配型號:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
class Match extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'matches';
protected $fillable = ['opponent'];
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function sets()
{
return $this->hasMany('App\Models\Set');
}
}
設置型號:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
class Set extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $fillable = ['self', 'opponent', 'index'];
public function match()
{
return $this->belongsTo('App\Models\Match');
}
}
現在我想有以下的,當我在後臺創建錦標賽:
我已經可以從,到,類型,位置和設置到位。但是現在我希望能夠添加一個匹配併爲這個匹配添加集合。這一切都在一個頁面上。
但我有點卡住如何做到這一點。有人可以在我的路上幫助我嗎?
很好,另外,vue.js可以使它更簡單。 – 2017-03-09 19:26:45