Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Employee | |
0.00% |
0 / 12 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| user | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAll | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| store | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models\admin; |
| 4 | |
| 5 | use App\Models\User; |
| 6 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 7 | use Illuminate\Database\Eloquent\Model; |
| 8 | |
| 9 | class Employee extends Model |
| 10 | { |
| 11 | use HasFactory; |
| 12 | |
| 13 | protected $table = 'employees'; |
| 14 | |
| 15 | protected $fillable = [ |
| 16 | 'user_id', |
| 17 | 'phone', |
| 18 | 'NID', |
| 19 | 'image', |
| 20 | 'present_address', |
| 21 | 'permanent_address', |
| 22 | 'joining_date', |
| 23 | 'joining_salary', |
| 24 | ]; |
| 25 | |
| 26 | public function user() |
| 27 | { |
| 28 | return $this->belongsTo(User::class, 'user_id'); |
| 29 | } |
| 30 | |
| 31 | /*************************** |
| 32 | * repository method start * |
| 33 | ***************************/ |
| 34 | |
| 35 | public static function getAll($order_by) |
| 36 | { |
| 37 | $query = self::query(); |
| 38 | |
| 39 | return ($order_by ? $query->orderBy('id', 'DESC') : $query)->with('user')->get(); |
| 40 | } |
| 41 | |
| 42 | public static function store($payload, $user) |
| 43 | { |
| 44 | return self::query()->create([ |
| 45 | 'user_id' => $user->id, |
| 46 | 'phone' => $payload['phone'], |
| 47 | 'NID' => $payload['nid'], |
| 48 | 'present_address' => $payload['present_address'], |
| 49 | 'permanent_address' => $payload['permanent_address'], |
| 50 | 'joining_date' => $payload['joining_date'], |
| 51 | 'joining_salary' => $payload['joining_salary'], |
| 52 | ]); |
| 53 | } |
| 54 | } |