add some more functions
This commit is contained in:
22
app/Models/Order/Card/CardOrder.php
Normal file
22
app/Models/Order/Card/CardOrder.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Order\Card;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CardOrder extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
|
||||
];
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Models\Order\Loan;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\System\Location\Province;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -93,4 +94,20 @@ class LoanOrder extends Model
|
||||
{
|
||||
return $this->belongsTo(Province::class, 'province_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* User (who created order)
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* User who revieved order
|
||||
*/
|
||||
public function filledBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'filled_by');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Loan\Concerns;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
trait LoanOrderEvents
|
||||
{
|
||||
/**
|
||||
* Register a callback to be called after the resource is created.
|
||||
*/
|
||||
public static function afterCreate(NovaRequest $request, Model $model): void
|
||||
{
|
||||
LoanOrderNovaRepo::afterCreate($request, $model);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Nova\Resources\Order\Loan\Concerns;
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\Order\Loan\LoanType;
|
||||
use App\Nova\Resources\System\Location\Province;
|
||||
use App\Nova\User;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Legal\EducationRepo;
|
||||
use App\Repos\System\Settings\Legal\MarriageRepo;
|
||||
@@ -40,6 +41,11 @@ class LoanOrderFieldsForDetail
|
||||
->withIcons()
|
||||
->icons(OrderRepo::statusIcons()),
|
||||
|
||||
Text::make(__('Note'), 'status_reason'),
|
||||
|
||||
BelongsTo::make(__('Created by').': ', 'user', User::class),
|
||||
BelongsTo::make(__('Updated by').': ', 'filledBy', User::class),
|
||||
|
||||
new Panel(__('Loan'), [
|
||||
BelongsTo::make(__('Loan type'), 'loanType', LoanType::class),
|
||||
]),
|
||||
|
||||
@@ -30,4 +30,14 @@ class LoanOrderNovaRepo
|
||||
'status' => OrderRepo::defaultStatus(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* After model has been updated
|
||||
*/
|
||||
public static function afterCreate(NovaRequest $request, Model $model): void
|
||||
{
|
||||
$model->update([
|
||||
'filled_by' => auth()->id(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ use App\Models\System\Location\Province;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Filters\StatusFilter;
|
||||
use App\Nova\Resource;
|
||||
use App\Nova\Resources\Order\Loan\Concerns\LoanOrderEvents;
|
||||
use App\Nova\Resources\Order\Loan\Concerns\LoanOrderFieldsForDetail;
|
||||
use App\Nova\Resources\Order\Loan\Concerns\LoanOrderFieldsForIndex;
|
||||
use App\Nova\Resources\Order\Loan\Concerns\LoanOrderNovaRepo;
|
||||
use App\Repos\Order\Loan\LoanTypeRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Nova\NovaRepo;
|
||||
@@ -20,6 +20,7 @@ use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use App\Rules\DowranAgaAllowed;
|
||||
use App\Rules\OnlyLetters;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Nova\Fields\Date;
|
||||
@@ -35,8 +36,6 @@ use Nurmuhammet\NovaInputmask\NovaInputmask;
|
||||
|
||||
class LoanOrder extends Resource
|
||||
{
|
||||
use LoanOrderEvents;
|
||||
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
@@ -125,6 +124,22 @@ class LoanOrder extends Resource
|
||||
return $query->where('user_id', $request->user()->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be called after the resource is created.
|
||||
*/
|
||||
public static function afterCreate(NovaRequest $request, Model $model): void
|
||||
{
|
||||
LoanOrderNovaRepo::afterCreate($request, $model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be called after the resource is updated.
|
||||
*/
|
||||
public static function afterUpdate(NovaRequest $request, Model $model): void
|
||||
{
|
||||
LoanOrderNovaRepo::afterUpdate($request, $model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields for index.
|
||||
*/
|
||||
@@ -158,6 +173,10 @@ class LoanOrder extends Resource
|
||||
->rules('required')
|
||||
->canSeeWhen('systemUser', $this),
|
||||
|
||||
Text::make(__('Note'), 'status_reason')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
|
||||
new Panel(__('Loan'), [
|
||||
Select::make(__('Loan type'), 'loan_type')
|
||||
->displayUsingLabels()
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('card_orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
// $table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||
// $table->string('cart_inception');
|
||||
// $table->string('cart_type');
|
||||
// $table->string('region');
|
||||
// $table->foreignId('branch_id')->constrained('branches')->restrictOnDelete();
|
||||
// $table->string('name');
|
||||
// $table->string('surname');
|
||||
// $table->string('patronic_name')->nullable();
|
||||
// $table->date('born_at')->nullable();
|
||||
// $table->string('old_surname')->nullable();
|
||||
// $table->string('citizenship');
|
||||
// $table->string('passport_serie');
|
||||
// $table->integer('passport_number');
|
||||
// $table->date('passport_given_at');
|
||||
// $table->string('passport_given_by')->nullable();
|
||||
// $table->string('born_location');
|
||||
// $table->string('job_location')->nullable();
|
||||
// $table->string('passport_address')->nullable();
|
||||
// $table->string('home_address')->nullable();
|
||||
// $table->string('phone')->nullable();
|
||||
// $table->string('status')->nullable();
|
||||
// $table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('card_orders');
|
||||
}
|
||||
};
|
||||
@@ -104,6 +104,7 @@
|
||||
"Not Implemented": "Durmuşa geçirilmedi",
|
||||
"Not Modified": "Üýtgedilmedi",
|
||||
"Notes": "Bellikler",
|
||||
"Note": "Bellik",
|
||||
"of": "of",
|
||||
"OK": "Bolýar",
|
||||
"Orders": "Sargytlar",
|
||||
@@ -227,5 +228,7 @@
|
||||
"Your password has been updated": "Siziň açar sözüňiz üýtgedildi",
|
||||
"We send you a verification code to": "Tassyklama belgini şu belgä ugratdyk",
|
||||
"Backups": "Bekaplar",
|
||||
"all": "ählisi"
|
||||
"all": "ählisi",
|
||||
"Created by": "Sargyt eden",
|
||||
"Updated by": "Üýtgeden"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user