- Implemented stock transfer creation and management with Livewire components. - Created StockTransfer and StockTransferItem models with necessary relationships. - Added migration files for stock_transfers and stock_transfer_items tables. - Developed traits for handling stock transfer items (add, delete, update). - Integrated stock transfer logging in StockActivityLogService. - Updated ViewServiceProvider to include stock transfer permissions and routes. - Created frontend views for stock transfer form and index with appropriate UI components. - Added role permissions for stock transfer actions in RolePermissionSeeder.
47 lines
1015 B
PHP
47 lines
1015 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Scope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Veelasky\LaravelHashId\Eloquent\HashableId;
|
|
|
|
class StockTransferItem extends Model
|
|
{
|
|
use HashableId, SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'quantity' => 'int',
|
|
];
|
|
}
|
|
|
|
#[Scope]
|
|
public function currentUser(Builder $query): void
|
|
{
|
|
$query->where('user_id', auth()->id());
|
|
}
|
|
|
|
public function stockTransfer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StockTransfer::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function transferable(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
}
|