45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| namespace App\Console\Commands;
 | |
| 
 | |
| use App\Http\Resources\CVResource;
 | |
| use App\Models\CV;
 | |
| use Illuminate\Console\Command;
 | |
| 
 | |
| class ListCV extends Command
 | |
| {
 | |
|     protected $signature = 'cv:list';
 | |
| 
 | |
|     protected $description = 'List of CV';
 | |
| 
 | |
|     public function handle(): int
 | |
|     {
 | |
|         $cvList = CV::all();
 | |
|         $cvListCollection = [];
 | |
| 
 | |
|         /** @var CV $cv */
 | |
|         foreach ($cvList as $cv) {
 | |
|             $cvResource = (new CVResource($cv))->setAsConsole()->toArray();
 | |
|             $cvListCollection[] = [
 | |
|                 'id' => $cvResource['id'],
 | |
|                 'token' => $cvResource['token'],
 | |
|                 'email' => $cvResource['email'],
 | |
|                 'recipient' => $cvResource['recipient'],
 | |
|                 'locations' => implode(' / ', $cvResource['locations']),
 | |
|                 'phone' => $cvResource['phone']['formattedPhoneNumber'],
 | |
|                 'views' => $cvResource['views'] . '/' . $cvResource['registeredViews'],
 | |
|             ];
 | |
|         }
 | |
| 
 | |
|         if (count($cvListCollection) > 0)
 | |
|             $this->table(
 | |
|                 ['Id', 'Token', 'E-mail', 'Company', 'Locations', 'Phone', 'Views'],
 | |
|                 $cvListCollection
 | |
|             );
 | |
| 
 | |
|         return Command::SUCCESS;
 | |
|     }
 | |
| }
 |