Completed
Push — master ( f30158...bfbb50 )
by Sherif
02:18
created
src/Modules/Permissions/Resources/Lang/en/errors.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * Here goes your error messages.
7
-     */
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8 8
 
9 9
 ];
Please login to merge, or discard this patch.
src/Modules/Permissions/Permission.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,36 +10,36 @@
 block discarded – undo
10 10
 class Permission extends Model
11 11
 {
12 12
 
13
-    use SoftDeletes;
14
-    protected $table    = 'permissions';
15
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
-    protected $hidden   = ['deleted_at'];
17
-    protected $guarded  = ['id'];
18
-    protected $fillable = ['name', 'model'];
19
-
20
-    public function getCreatedAtAttribute($value)
21
-    {
22
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
23
-    }
24
-
25
-    public function getUpdatedAtAttribute($value)
26
-    {
27
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
28
-    }
29
-
30
-    public function getDeletedAtAttribute($value)
31
-    {
32
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
33
-    }
13
+	use SoftDeletes;
14
+	protected $table    = 'permissions';
15
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
+	protected $hidden   = ['deleted_at'];
17
+	protected $guarded  = ['id'];
18
+	protected $fillable = ['name', 'model'];
19
+
20
+	public function getCreatedAtAttribute($value)
21
+	{
22
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
23
+	}
24
+
25
+	public function getUpdatedAtAttribute($value)
26
+	{
27
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
28
+	}
29
+
30
+	public function getDeletedAtAttribute($value)
31
+	{
32
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
33
+	}
34 34
     
35
-    public function roles()
36
-    {
37
-        return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps();
38
-    }
39
-
40
-    public static function boot()
41
-    {
42
-        parent::boot();
43
-        Permission::observe(PermissionObserver::class);
44
-    }
35
+	public function roles()
36
+	{
37
+		return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps();
38
+	}
39
+
40
+	public static function boot()
41
+	{
42
+		parent::boot();
43
+		Permission::observe(PermissionObserver::class);
44
+	}
45 45
 }
Please login to merge, or discard this patch.
PushNotificationDevices/Http/Requests/InsertPushNotificationDevice.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class InsertPushNotificationDevice extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'device_token' => 'required|string|max:255',
28
-            'user_id'      => 'required|exists:users,id'
29
-        ];
30
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'device_token' => 'required|string|max:255',
28
+			'user_id'      => 'required|exists:users,id'
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
Modules/PushNotificationDevices/Services/PushNotificationDeviceService.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -10,63 +10,63 @@
 block discarded – undo
10 10
 
11 11
 class PushNotificationDeviceService extends BaseService
12 12
 {
13
-    /**
14
-     * Init new object.
15
-     *
16
-     * @param   PushNotificationDeviceRepository $repo
17
-     * @return  void
18
-     */
19
-    public function __construct(PushNotificationDeviceRepository $repo)
20
-    {
21
-        parent::__construct($repo);
22
-    }
13
+	/**
14
+	 * Init new object.
15
+	 *
16
+	 * @param   PushNotificationDeviceRepository $repo
17
+	 * @return  void
18
+	 */
19
+	public function __construct(PushNotificationDeviceRepository $repo)
20
+	{
21
+		parent::__construct($repo);
22
+	}
23 23
 
24
-    /**
25
-     * Register the given device to the logged in user.
26
-     *
27
-     * @param  array $data
28
-     * @return void
29
-     */
30
-    public function registerDevice($data)
31
-    {
32
-        $data['access_token'] = \Auth::user()->token();
33
-        $data['user_id']      = \Auth::id();
34
-        $device               = $this->repo->first([
35
-            'and' => [
36
-                'device_token' => $data['device_token'],
37
-                'user_id' => $data['user_id']
38
-                ]
39
-            ]);
24
+	/**
25
+	 * Register the given device to the logged in user.
26
+	 *
27
+	 * @param  array $data
28
+	 * @return void
29
+	 */
30
+	public function registerDevice($data)
31
+	{
32
+		$data['access_token'] = \Auth::user()->token();
33
+		$data['user_id']      = \Auth::id();
34
+		$device               = $this->repo->first([
35
+			'and' => [
36
+				'device_token' => $data['device_token'],
37
+				'user_id' => $data['user_id']
38
+				]
39
+			]);
40 40
 
41
-        if ($device) {
42
-            $data['id'] = $device->id;
43
-        }
41
+		if ($device) {
42
+			$data['id'] = $device->id;
43
+		}
44 44
 
45
-        return $this->repo->save($data);
46
-    }
45
+		return $this->repo->save($data);
46
+	}
47 47
 
48
-    /**
49
-     * Generate the given message data.
50
-     *
51
-     * @param  string $title
52
-     * @param  string $message
53
-     * @param  array  $data
54
-     * @return void
55
-     */
56
-    public function generateMessageData($title, $message, $data = [])
57
-    {
58
-        $optionBuilder       = new OptionsBuilder();
59
-        $notificationBuilder = new PayloadNotificationBuilder($title);
60
-        $dataBuilder         = new PayloadDataBuilder();
48
+	/**
49
+	 * Generate the given message data.
50
+	 *
51
+	 * @param  string $title
52
+	 * @param  string $message
53
+	 * @param  array  $data
54
+	 * @return void
55
+	 */
56
+	public function generateMessageData($title, $message, $data = [])
57
+	{
58
+		$optionBuilder       = new OptionsBuilder();
59
+		$notificationBuilder = new PayloadNotificationBuilder($title);
60
+		$dataBuilder         = new PayloadDataBuilder();
61 61
 
62
-        $optionBuilder->setTimeToLive(60 * 20);
63
-        $notificationBuilder->setBody($message);
64
-        $dataBuilder->addData($data);
62
+		$optionBuilder->setTimeToLive(60 * 20);
63
+		$notificationBuilder->setBody($message);
64
+		$dataBuilder->addData($data);
65 65
 
66
-        $options             = $optionBuilder->build();
67
-        $notification        = $notificationBuilder->build();
68
-        $data                = $dataBuilder->build();
66
+		$options             = $optionBuilder->build();
67
+		$notification        = $notificationBuilder->build();
68
+		$data                = $dataBuilder->build();
69 69
 
70
-        return compact('options', 'notification', 'data');
71
-    }
70
+		return compact('options', 'notification', 'data');
71
+	}
72 72
 }
Please login to merge, or discard this patch.
src/Modules/Core/Resources/Lang/en/errors.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,14 +2,14 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * Here goes your error messages.
7
-     */
8
-    'connectionError'         => 'Connection error',
9
-    'redisNotRunning'         => 'Your redis notification server is\'t running',
10
-    'dbQueryError'            => 'Please check the given inputes',
11
-    'cannotCreateSetting'     => 'Can\'t create setting',
12
-    'cannotUpdateSettingKey'  => 'Can\'t update setting key',
13
-    'notFound'                => 'The requested :replace not found'
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8
+	'connectionError'         => 'Connection error',
9
+	'redisNotRunning'         => 'Your redis notification server is\'t running',
10
+	'dbQueryError'            => 'Please check the given inputes',
11
+	'cannotCreateSetting'     => 'Can\'t create setting',
12
+	'cannotUpdateSettingKey'  => 'Can\'t update setting key',
13
+	'notFound'                => 'The requested :replace not found'
14 14
 
15 15
 ];
Please login to merge, or discard this patch.
src/Modules/Core/Resources/Lang/ar/errors.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,14 +2,14 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * Here goes your error messages.
7
-     */
8
-    'connectionError'         => 'خطأ في الاتصال',
9
-    'redisNotRunning'         => 'سيرفير الاشعارات لايعمل',
10
-    'dbQueryError'            => 'خطا في البيانات',
11
-    'cannotCreateSetting'     => 'لا يمكن اضافة اعدادات',
12
-    'cannotUpdateSettingKey'  => 'لا يمكن تعديل اعدادات',
13
-    'notFound'                => 'ال :replace المطلوب غير موجود'
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8
+	'connectionError'         => 'خطأ في الاتصال',
9
+	'redisNotRunning'         => 'سيرفير الاشعارات لايعمل',
10
+	'dbQueryError'            => 'خطا في البيانات',
11
+	'cannotCreateSetting'     => 'لا يمكن اضافة اعدادات',
12
+	'cannotUpdateSettingKey'  => 'لا يمكن تعديل اعدادات',
13
+	'notFound'                => 'ال :replace المطلوب غير موجود'
14 14
 
15 15
 ];
Please login to merge, or discard this patch.
src/Modules/Core/Facades/Errors.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 class Errors extends Facade
6 6
 {
7
-    protected static function getFacadeAccessor()
8
-    {
9
-        return 'Errors';
10
-    }
7
+	protected static function getFacadeAccessor()
8
+	{
9
+		return 'Errors';
10
+	}
11 11
 }
Please login to merge, or discard this patch.
src/Modules/Core/Providers/ModuleServiceProvider.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -6,53 +6,53 @@
 block discarded – undo
6 6
 
7 7
 class ModuleServiceProvider extends ServiceProvider
8 8
 {
9
-    /**
10
-     * Bootstrap the module services.
11
-     *
12
-     * @return void
13
-     */
14
-    public function boot()
15
-    {
16
-        $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core');
17
-        $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core');
18
-
19
-        $this->loadMigrationsFrom(module_path('core', 'Database/Migrations', 'app'));
20
-        $this->loadFactoriesFrom(module_path('core', 'Database/Factories', 'app'));
21
-    }
22
-
23
-    /**
24
-     * Register the module services.
25
-     *
26
-     * @return void
27
-     */
28
-    public function register()
29
-    {
30
-        //Bind Core Facade to the Service Container
31
-        $this->app->singleton('Core', function () {
32
-            return new \App\Modules\Core\Core;
33
-        });
34
-
35
-        //Bind Errors Facade to the Service Container
36
-        $this->app->singleton('Errors', function () {
37
-            return new \App\Modules\Core\Errors\Errors;
38
-        });
39
-
40
-        //Bind CoreConfig Facade to the Service Container
41
-        $this->app->singleton('CoreConfig', function () {
42
-            return new \App\Modules\Core\Utl\CoreConfig;
43
-        });
44
-
45
-        //Bind Media Facade to the Service Container
46
-        $this->app->singleton('Media', function () {
47
-            return new \App\Modules\Core\Utl\Media;
48
-        });
49
-
50
-        //Bind ApiConsumer Facade to the Service Container
51
-        $this->app->singleton('ApiConsumer', function () {
52
-            $app = app();
53
-            return new \App\Modules\Core\Utl\ApiConsumer($app, $app['request'], $app['router']);
54
-        });
9
+	/**
10
+	 * Bootstrap the module services.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function boot()
15
+	{
16
+		$this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core');
17
+		$this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core');
18
+
19
+		$this->loadMigrationsFrom(module_path('core', 'Database/Migrations', 'app'));
20
+		$this->loadFactoriesFrom(module_path('core', 'Database/Factories', 'app'));
21
+	}
22
+
23
+	/**
24
+	 * Register the module services.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function register()
29
+	{
30
+		//Bind Core Facade to the Service Container
31
+		$this->app->singleton('Core', function () {
32
+			return new \App\Modules\Core\Core;
33
+		});
34
+
35
+		//Bind Errors Facade to the Service Container
36
+		$this->app->singleton('Errors', function () {
37
+			return new \App\Modules\Core\Errors\Errors;
38
+		});
39
+
40
+		//Bind CoreConfig Facade to the Service Container
41
+		$this->app->singleton('CoreConfig', function () {
42
+			return new \App\Modules\Core\Utl\CoreConfig;
43
+		});
44
+
45
+		//Bind Media Facade to the Service Container
46
+		$this->app->singleton('Media', function () {
47
+			return new \App\Modules\Core\Utl\Media;
48
+		});
49
+
50
+		//Bind ApiConsumer Facade to the Service Container
51
+		$this->app->singleton('ApiConsumer', function () {
52
+			$app = app();
53
+			return new \App\Modules\Core\Utl\ApiConsumer($app, $app['request'], $app['router']);
54
+		});
55 55
         
56
-        $this->app->register(RouteServiceProvider::class);
57
-    }
56
+		$this->app->register(RouteServiceProvider::class);
57
+	}
58 58
 }
Please login to merge, or discard this patch.
src/Modules/Core/Console/Commands/MakeModuleCommand.php 1 patch
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -10,243 +10,243 @@
 block discarded – undo
10 10
 
11 11
 class MakeModuleCommand extends Command
12 12
 {
13
-    /**
14
-     * The name and signature of the console command.
15
-     *
16
-     * @var string
17
-     */
18
-    protected $signature = 'generate:module
13
+	/**
14
+	 * The name and signature of the console command.
15
+	 *
16
+	 * @var string
17
+	 */
18
+	protected $signature = 'generate:module
19 19
         {slug : The slug of the module}';
20 20
 
21
-    /**
22
-     * The console command description.
23
-     *
24
-     * @var string
25
-     */
26
-    protected $description = 'Create a new module';
27
-
28
-    /**
29
-     * The modules instance.
30
-     *
31
-     * @var RepositoryManager
32
-     */
33
-    protected $module;
34
-
35
-    /**
36
-     * The filesystem instance.
37
-     *
38
-     * @var Filesystem
39
-     */
40
-    protected $files;
41
-
42
-    /**
43
-     * Array to store the configuration details.
44
-     *
45
-     * @var array
46
-     */
47
-    protected $container;
48
-
49
-    /**
50
-     * Array of folder mappings.
51
-     *
52
-     * @var Array
53
-     */
54
-    protected $mapping = [
55
-        'Database/Factories'  => 'Database/Factories',
56
-        'Database/Migrations' => 'Database/Migrations',
57
-        'Database/Seeds'      => 'Database/Seeds',
58
-        'Http/Controllers'    => 'Http/Controllers',
59
-        'Http/Requests'       => 'Http/Requests',
60
-        'Http/Resources'      => 'Http/Resources',
61
-        'ModelObservers'      => 'ModelObservers',
62
-        'Providers'           => 'Providers',
63
-        'Repositories'        => 'Repositories',
64
-        'Services'            => 'Services',
65
-        'Routes'              => 'Routes',
66
-        'Errors'              => 'Errors',
67
-    ];
68
-
69
-    /**
70
-     * Create a new command instance.
71
-     *
72
-     * @param Filesystem $files
73
-     * @param RepositoryManager $module
74
-     */
75
-    public function __construct(Filesystem $files, RepositoryManager $module)
76
-    {
77
-        parent::__construct();
78
-
79
-        $this->files = $files;
80
-        $this->module = $module;
81
-    }
82
-
83
-    /**
84
-     * Execute the console command.
85
-     *
86
-     * @return mixed
87
-     */
88
-    public function handle()
89
-    {
90
-        $this->container['slug']        = Str::slug($this->argument('slug'));
91
-        $this->container['name']        = Str::studly($this->container['slug']);
92
-        $this->container['version']     = '1.0';
93
-        $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.';
94
-        $this->container['location']    = config('modules.default_location');
95
-        $this->container['provider']    = config("modules.locations.{$this->container['location']}.provider");
96
-        $this->container['basename']    = Str::studly($this->container['slug']);
97
-        $this->container['namespace']   = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename'];
98
-
99
-        return $this->generate();
100
-    }
101
-
102
-    /**
103
-     * Generate the module.
104
-     */
105
-    protected function generate()
106
-    {
107
-        $steps = [
108
-            'Generating module...' => 'generateModule',
109
-            'Optimizing module cache...' => 'optimizeModules',
110
-            'Generating migrations...' => 'generateMigration',
111
-        ];
112
-
113
-        $progress = new ProgressBar($this->output, count($steps));
114
-        $progress->start();
115
-
116
-        foreach ($steps as $message => $function) {
117
-            $progress->setMessage($message);
118
-
119
-            $this->$function();
120
-
121
-            $progress->advance();
122
-        }
123
-
124
-        $progress->finish();
125
-
126
-        event($this->container['slug'] . '.module.made');
127
-
128
-        $this->info("\nModule generated successfully.");
129
-    }
130
-
131
-    /**
132
-     * Generate defined module folders.
133
-     */
134
-    protected function generateModule()
135
-    {
136
-        $location = $this->container['location'];
137
-        $root     = module_path(null, '', $location);
138
-        $manifest = config("modules.locations.$location.manifest") ?: 'module.json';
139
-        $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider';
140
-
141
-        if (!$this->files->isDirectory($root)) {
142
-            $this->files->makeDirectory($root);
143
-        }
144
-
145
-        $directory = module_path(null, $this->container['basename'], $location);
146
-        $source    = __DIR__ . '/Stubs/Module';
147
-
148
-        $this->files->makeDirectory($directory);
149
-
150
-        $sourceFiles = $this->files->allFiles($source, true);
151
-
152
-        if (!empty($this->mapping)) {
153
-            $search = array_keys($this->mapping);
154
-            $replace = array_values($this->mapping);
155
-        }
156
-
157
-        foreach ($sourceFiles as $file) {
158
-            $contents = $this->replacePlaceholders($file->getContents());
159
-            $subPath = $file->getRelativePathname();
160
-
161
-            if (!empty($this->mapping)) {
162
-                $subPath = str_replace($search, $replace, $subPath);
163
-            }
164
-
165
-            $filePath = $directory . '/' . $subPath;
21
+	/**
22
+	 * The console command description.
23
+	 *
24
+	 * @var string
25
+	 */
26
+	protected $description = 'Create a new module';
27
+
28
+	/**
29
+	 * The modules instance.
30
+	 *
31
+	 * @var RepositoryManager
32
+	 */
33
+	protected $module;
34
+
35
+	/**
36
+	 * The filesystem instance.
37
+	 *
38
+	 * @var Filesystem
39
+	 */
40
+	protected $files;
41
+
42
+	/**
43
+	 * Array to store the configuration details.
44
+	 *
45
+	 * @var array
46
+	 */
47
+	protected $container;
48
+
49
+	/**
50
+	 * Array of folder mappings.
51
+	 *
52
+	 * @var Array
53
+	 */
54
+	protected $mapping = [
55
+		'Database/Factories'  => 'Database/Factories',
56
+		'Database/Migrations' => 'Database/Migrations',
57
+		'Database/Seeds'      => 'Database/Seeds',
58
+		'Http/Controllers'    => 'Http/Controllers',
59
+		'Http/Requests'       => 'Http/Requests',
60
+		'Http/Resources'      => 'Http/Resources',
61
+		'ModelObservers'      => 'ModelObservers',
62
+		'Providers'           => 'Providers',
63
+		'Repositories'        => 'Repositories',
64
+		'Services'            => 'Services',
65
+		'Routes'              => 'Routes',
66
+		'Errors'              => 'Errors',
67
+	];
68
+
69
+	/**
70
+	 * Create a new command instance.
71
+	 *
72
+	 * @param Filesystem $files
73
+	 * @param RepositoryManager $module
74
+	 */
75
+	public function __construct(Filesystem $files, RepositoryManager $module)
76
+	{
77
+		parent::__construct();
78
+
79
+		$this->files = $files;
80
+		$this->module = $module;
81
+	}
82
+
83
+	/**
84
+	 * Execute the console command.
85
+	 *
86
+	 * @return mixed
87
+	 */
88
+	public function handle()
89
+	{
90
+		$this->container['slug']        = Str::slug($this->argument('slug'));
91
+		$this->container['name']        = Str::studly($this->container['slug']);
92
+		$this->container['version']     = '1.0';
93
+		$this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.';
94
+		$this->container['location']    = config('modules.default_location');
95
+		$this->container['provider']    = config("modules.locations.{$this->container['location']}.provider");
96
+		$this->container['basename']    = Str::studly($this->container['slug']);
97
+		$this->container['namespace']   = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename'];
98
+
99
+		return $this->generate();
100
+	}
101
+
102
+	/**
103
+	 * Generate the module.
104
+	 */
105
+	protected function generate()
106
+	{
107
+		$steps = [
108
+			'Generating module...' => 'generateModule',
109
+			'Optimizing module cache...' => 'optimizeModules',
110
+			'Generating migrations...' => 'generateMigration',
111
+		];
112
+
113
+		$progress = new ProgressBar($this->output, count($steps));
114
+		$progress->start();
115
+
116
+		foreach ($steps as $message => $function) {
117
+			$progress->setMessage($message);
118
+
119
+			$this->$function();
120
+
121
+			$progress->advance();
122
+		}
123
+
124
+		$progress->finish();
125
+
126
+		event($this->container['slug'] . '.module.made');
127
+
128
+		$this->info("\nModule generated successfully.");
129
+	}
130
+
131
+	/**
132
+	 * Generate defined module folders.
133
+	 */
134
+	protected function generateModule()
135
+	{
136
+		$location = $this->container['location'];
137
+		$root     = module_path(null, '', $location);
138
+		$manifest = config("modules.locations.$location.manifest") ?: 'module.json';
139
+		$provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider';
140
+
141
+		if (!$this->files->isDirectory($root)) {
142
+			$this->files->makeDirectory($root);
143
+		}
144
+
145
+		$directory = module_path(null, $this->container['basename'], $location);
146
+		$source    = __DIR__ . '/Stubs/Module';
147
+
148
+		$this->files->makeDirectory($directory);
149
+
150
+		$sourceFiles = $this->files->allFiles($source, true);
151
+
152
+		if (!empty($this->mapping)) {
153
+			$search = array_keys($this->mapping);
154
+			$replace = array_values($this->mapping);
155
+		}
156
+
157
+		foreach ($sourceFiles as $file) {
158
+			$contents = $this->replacePlaceholders($file->getContents());
159
+			$subPath = $file->getRelativePathname();
160
+
161
+			if (!empty($this->mapping)) {
162
+				$subPath = str_replace($search, $replace, $subPath);
163
+			}
164
+
165
+			$filePath = $directory . '/' . $subPath;
166 166
             
167
-            // if the file is module.json, replace it with the custom manifest file name
168
-            if ($file->getFilename() === 'module.json' && $manifest) {
169
-                $filePath = str_replace('module.json', $manifest, $filePath);
170
-            }
167
+			// if the file is module.json, replace it with the custom manifest file name
168
+			if ($file->getFilename() === 'module.json' && $manifest) {
169
+				$filePath = str_replace('module.json', $manifest, $filePath);
170
+			}
171 171
             
172
-            // if the file is ModuleServiceProvider.php, replace it with the custom provider file name
173
-            if ($file->getFilename() === 'ModuleServiceProvider.php') {
174
-                $filePath = str_replace('ModuleServiceProvider', $provider, $filePath);
175
-            }
176
-            $filePath = $this->replacePlaceholders($filePath);
172
+			// if the file is ModuleServiceProvider.php, replace it with the custom provider file name
173
+			if ($file->getFilename() === 'ModuleServiceProvider.php') {
174
+				$filePath = str_replace('ModuleServiceProvider', $provider, $filePath);
175
+			}
176
+			$filePath = $this->replacePlaceholders($filePath);
177 177
             
178
-            $dir = dirname($filePath);
178
+			$dir = dirname($filePath);
179 179
             
180
-            if (! $this->files->isDirectory($dir)) {
181
-                $this->files->makeDirectory($dir, 0755, true);
182
-            }
183
-
184
-            $this->files->put($filePath, $contents);
185
-        }
186
-    }
187
-
188
-    protected function replacePlaceholders($contents)
189
-    {
190
-        $modelName = \Str::camel($this->container['slug']);
191
-        $modelNameSingular = \Str::singular($modelName);
192
-
193
-        $find = [
194
-            'DummyFactory',
195
-            'DummyModelName',
196
-            'DummyModuleSlug',
197
-            'DummyModule',
198
-            'DummyModel',
199
-            'DummyDatabaseSeeder',
200
-            'DummyTableSeeder',
201
-            'DummyController',
202
-            'DummyService',
203
-            'DummyRepository',
204
-            'DummyErrors',
205
-            'InsertDummy',
206
-            'UpdateDummy',
207
-            'DummyResource',
208
-            'DummyObserver',
209
-            'DummyTableName',
210
-            'DummyRoutePrefix',
211
-        ];
212
-
213
-        $replace = [
214
-            ucfirst($modelNameSingular) . 'Factory',
215
-            $modelNameSingular,
216
-            $this->container['slug'],
217
-            ucfirst($modelName),
218
-            ucfirst($modelNameSingular),
219
-            ucfirst($modelName) . 'DatabaseSeeder',
220
-            ucfirst($modelName) . 'TableSeeder',
221
-            ucfirst($modelNameSingular) . 'Controller',
222
-            ucfirst($modelNameSingular) . 'Service',
223
-            ucfirst($modelNameSingular) . 'Repository',
224
-            ucfirst($modelName) . 'Errors',
225
-            'Insert' . ucfirst($modelNameSingular),
226
-            'Update' . ucfirst($modelNameSingular),
227
-            ucfirst($modelNameSingular),
228
-            ucfirst($modelNameSingular) . 'Observer',
229
-            $modelName,
230
-            $modelName,
231
-        ];
232
-
233
-        return str_replace($find, $replace, $contents);
234
-    }
235
-
236
-    /**
237
-     * Reset module cache of enabled and disabled modules.
238
-     */
239
-    protected function optimizeModules()
240
-    {
241
-        return $this->callSilent('module:optimize');
242
-    }
243
-
244
-    /**
245
-     * Generate table migrations.
246
-     */
247
-    protected function generateMigration()
248
-    {
249
-        $modelName = $this->container['slug'];
250
-        return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']);
251
-    }
180
+			if (! $this->files->isDirectory($dir)) {
181
+				$this->files->makeDirectory($dir, 0755, true);
182
+			}
183
+
184
+			$this->files->put($filePath, $contents);
185
+		}
186
+	}
187
+
188
+	protected function replacePlaceholders($contents)
189
+	{
190
+		$modelName = \Str::camel($this->container['slug']);
191
+		$modelNameSingular = \Str::singular($modelName);
192
+
193
+		$find = [
194
+			'DummyFactory',
195
+			'DummyModelName',
196
+			'DummyModuleSlug',
197
+			'DummyModule',
198
+			'DummyModel',
199
+			'DummyDatabaseSeeder',
200
+			'DummyTableSeeder',
201
+			'DummyController',
202
+			'DummyService',
203
+			'DummyRepository',
204
+			'DummyErrors',
205
+			'InsertDummy',
206
+			'UpdateDummy',
207
+			'DummyResource',
208
+			'DummyObserver',
209
+			'DummyTableName',
210
+			'DummyRoutePrefix',
211
+		];
212
+
213
+		$replace = [
214
+			ucfirst($modelNameSingular) . 'Factory',
215
+			$modelNameSingular,
216
+			$this->container['slug'],
217
+			ucfirst($modelName),
218
+			ucfirst($modelNameSingular),
219
+			ucfirst($modelName) . 'DatabaseSeeder',
220
+			ucfirst($modelName) . 'TableSeeder',
221
+			ucfirst($modelNameSingular) . 'Controller',
222
+			ucfirst($modelNameSingular) . 'Service',
223
+			ucfirst($modelNameSingular) . 'Repository',
224
+			ucfirst($modelName) . 'Errors',
225
+			'Insert' . ucfirst($modelNameSingular),
226
+			'Update' . ucfirst($modelNameSingular),
227
+			ucfirst($modelNameSingular),
228
+			ucfirst($modelNameSingular) . 'Observer',
229
+			$modelName,
230
+			$modelName,
231
+		];
232
+
233
+		return str_replace($find, $replace, $contents);
234
+	}
235
+
236
+	/**
237
+	 * Reset module cache of enabled and disabled modules.
238
+	 */
239
+	protected function optimizeModules()
240
+	{
241
+		return $this->callSilent('module:optimize');
242
+	}
243
+
244
+	/**
245
+	 * Generate table migrations.
246
+	 */
247
+	protected function generateMigration()
248
+	{
249
+		$modelName = $this->container['slug'];
250
+		return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']);
251
+	}
252 252
 }
Please login to merge, or discard this patch.