forked from doppar/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetCreatablePropertyCommand.php
More file actions
41 lines (32 loc) · 924 Bytes
/
SetCreatablePropertyCommand.php
File metadata and controls
41 lines (32 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Phaseolies\Console\Commands;
use Phaseolies\Console\Schedule\Command;
class SetCreatablePropertyCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = "get:column {table}";
/**
* The description of the console command.
*
* @var string
*/
protected $description = "Get creatable properties of a given table";
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
$tableName = $this->argument("table");
$db = db()->getTableColumns($tableName);
$filteredColumns = array_diff($db, ["id", "created_at", "updated_at"]);
$filteredColumns = array_values($filteredColumns);
$this->info('protected $creatable = ' . json_encode($filteredColumns));
return Command::SUCCESS;
}
}