30 lines
779 B
PHP
30 lines
779 B
PHP
<?php
|
|
|
|
namespace App\Component\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Staff extends Model
|
|
{
|
|
protected $table = 'staffs';
|
|
|
|
public static function getName($data)
|
|
{
|
|
$staff_name = Staff::where('code', intval($data))
|
|
->where('is_history', 0)
|
|
->first();
|
|
if ($staff_name) {
|
|
$staff_name = $staff_name['name'];
|
|
} else {
|
|
$staff_name = Staff::where('code', intval($data))
|
|
->where('is_history', 1)
|
|
->first();
|
|
if ($staff_name) {
|
|
$staff_name = $staff_name['name'];
|
|
} else {
|
|
$staff_name = 'Связанный персонал не найден';
|
|
}
|
|
}
|
|
return $staff_name;
|
|
}
|
|
} |