fixes
This commit is contained in:
@@ -12,13 +12,14 @@ class UnitiesDataTable extends DataTable
|
||||
|
||||
public function query(Unity $model)
|
||||
{
|
||||
$model = $model::with(['package'])->select('shop_unities.*');
|
||||
$model = $model::with(['package.article_family'])->select('shop_unities.*');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('package.article_family.name')->title('Famille'),
|
||||
Column::make('package.value')->title('Package'),
|
||||
Column::make('value')->title('Valeur'),
|
||||
self::makeColumnButtons(),
|
||||
|
||||
@@ -31,7 +31,7 @@ class PackageController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$data['families'] = ArticleFamilies::getOptions();
|
||||
return view('Shop.Admin.Packages.create');
|
||||
return view('Shop.Admin.Packages.create', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class Unity extends Model
|
||||
{
|
||||
use BelongsToThrough, softDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_unities';
|
||||
|
||||
@@ -14,6 +19,11 @@ class Unity extends Model
|
||||
return $this->belongsTo('App\Models\Shop\Package');
|
||||
}
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsToThrough('App\Models\Shop\ArticleFamily', 'App\Models\Shop\Package', null, '', ['App\Models\Shop\ArticleFamily' => 'article_family_id', 'App\Models\Shop\Package' => 'package_id']);
|
||||
}
|
||||
|
||||
public function scopeByPackage($query, $id)
|
||||
{
|
||||
return $query->where('package_id', $id);
|
||||
|
||||
@@ -16,4 +16,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
@include('components.button', ['class' => 'btn-success save ' . ($class ?? ''), 'icon' => 'fa-save', 'txt' => __('save')])
|
||||
@include('components.button', ['type' => 'submit', 'class' => 'btn-success save ' . ($class ?? ''), 'icon' => 'fa-save', 'txt' => __('save')])
|
||||
|
||||
18
resources/views/load/form/save.blade.php
Normal file
18
resources/views/load/form/save.blade.php
Normal file
@@ -0,0 +1,18 @@
|
||||
@if(!defined('LOAD_SAVE'))
|
||||
@push('scripts')
|
||||
<script>
|
||||
function initSaveForm(sel, form) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.save' : sel;
|
||||
var form = (typeof(form) == 'undefined') ? '#form' : form;
|
||||
console.log(selector);
|
||||
console.log(form);
|
||||
$(selector).off().click(function(e) {
|
||||
console.log("ici");
|
||||
e.preventDefault();
|
||||
$(form).submit();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@php(define('LOAD_SAVE', true))
|
||||
@endif
|
||||
@@ -3,6 +3,7 @@
|
||||
Route::prefix('Packages')->name('Packages.')->group(function () {
|
||||
Route::any('getOptionsByFamily', 'PackageController@getOptionsByFamily')->name('getOptionsByFamily');
|
||||
Route::get('edit/{id}', 'PackageController@edit')->name('edit');
|
||||
Route::delete('destroy/{id?}', 'PackageController@destroy')->name('destroy');
|
||||
});
|
||||
|
||||
Route::resource('Packages', 'PackageController');
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Route::prefix('Unities')->name('Unities.')->group(function () {
|
||||
Route::any('getOptionsByPackage', 'UnityController@getOptionsByPackage')->name('getOptionsByPackage');
|
||||
Route::get('edit/{id}', 'UnityController@edit')->name('edit');
|
||||
Route::delete('destroy/{id?}', 'UnityController@destroy')->name('destroy');
|
||||
});
|
||||
|
||||
Route::resource('Unities', 'UnityController');
|
||||
|
||||
Reference in New Issue
Block a user