File tree Expand file tree Collapse file tree 3 files changed +33
-4
lines changed Expand file tree Collapse file tree 3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 66 * have to implement Webfactor\Laravel\Generators\Contracts\MakeServiceInterface.
77 */
88 'services ' => [
9- Webfactor \Laravel \Generators \Services \MigrationService::class,
9+ /* Webfactor\Laravel\Generators\Services\MigrationService::class,*/
1010 Webfactor \Laravel \Generators \Services \LanguageService::class,
1111 Webfactor \Laravel \Generators \Services \BackpackCrudModelService::class,
12- Webfactor \Laravel \Generators \Services \BackpackCrudControllerService::class,
12+ /* Webfactor\Laravel\Generators\Services\BackpackCrudControllerService::class,
1313 Webfactor\Laravel\Generators\Services\BackpackCrudRequestService::class,
1414 Webfactor\Laravel\Generators\Services\FactoryService::class,
1515 Webfactor\Laravel\Generators\Services\SeederService::class,
16- Webfactor \Laravel \Generators \Services \RouteService::class,
16+ Webfactor\Laravel\Generators\Services\RouteService::class,*/
1717 Webfactor \Laravel \Generators \Services \OpenIdeService::class,
1818 ],
1919
Original file line number Diff line number Diff line change @@ -9,17 +9,46 @@ class BackpackCrudModelService extends ServiceAbstract implements ServiceInterfa
99{
1010 protected $ relativeToBasePath = 'app/Models ' ;
1111
12+ private $ fillable ;
13+
1214 public function call ()
1315 {
1416 $ this ->command ->call ('make:crud-model ' , [
1517 'name ' => $ this ->getName ($ this ->command ->entity ),
1618 ]);
1719
1820 $ this ->addLatestFileToIdeStack ();
21+ $ this ->fillFillableAttributeInGeneratedModelFromSchema ();
1922 }
2023
24+ /**
25+ * @param string $entity
26+ *
27+ * @return string
28+ */
2129 public function getName (string $ entity ): string
2230 {
2331 return ucfirst ($ entity );
2432 }
33+
34+ private function fillFillableAttributeInGeneratedModelFromSchema ()
35+ {
36+ $ modelFile = end ($ this ->command ->filesToBeOpened );
37+
38+ $ model = $ this ->filesystem ->get ($ modelFile );
39+ $ model = str_replace ('\'schemafields \'' , $ this ->getFillableFromSchema (), $ model );
40+ $ this ->filesystem ->put ($ modelFile , $ model );
41+ }
42+
43+ /**
44+ * @return string
45+ */
46+ private function getFillableFromSchema ()
47+ {
48+ $ this ->command ->schema ->getStructure ()->each (function ($ field ) {
49+ $ this ->fillable .= '\'' . $ field ->getName () . '\', ' ;
50+ });
51+
52+ return $ this ->fillable ;
53+ }
2554}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class DummyClass extends Model
1919 // protected $primaryKey = 'id';
2020 // public $timestamps = false;
2121 // protected $guarded = ['id'];
22- protected $fillable = [];
22+ protected $fillable = ['schemafields' ];
2323 // protected $hidden = [];
2424 // protected $dates = [];
2525
You can’t perform that action at this time.
0 commit comments