Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 31b63ec

Browse files
committed
add mm:append cmnd
1 parent c1f98af commit 31b63ec

File tree

3 files changed

+83
-23
lines changed

3 files changed

+83
-23
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Intro
66

7-
- Inspired by [Voyager](https://github.com/the-control-group/voyager) & [October](https://github.com/octobercms/october) & [WordPress](https://codex.wordpress.org/Media_Library_Screen)
7+
- Inspired by [Voyager](https://github.com/the-control-group/voyager), [October](https://github.com/octobercms/october), [WordPress](https://codex.wordpress.org/Media_Library_Screen)
88
- Built using
99
+ [Vue](https://vuejs.org/)
1010
+ [jQuery](https://jquery.com/)
@@ -117,12 +117,14 @@ return [
117117

118118
## Usage
119119

120-
- package automatically appends routes to `routes/web.php`
121-
- package automatically appends assets compiling to `webpack.mix.js`
122-
- add `MIX_MM_FRAMEWORK=bulma` to `.env`
120+
- run `php artisan mm:append` to
121+
+ add package routes to `routes/web.php`
122+
+ add package assets compiling to `webpack.mix.js`
123+
+ add `MIX_MM_FRAMEWORK=bulma` to `.env`
123124

124125
#### - Simple
125126
- visit `http://127.0.0.1:8000/media`
127+
- open `views/vendor/MediaManager/bulma/media.blade.php` and make any changes you may need ex.**"use bootstrap instead of bulma"**
126128

127129
#### - Advanced
128130
- install javascript dependencies
@@ -146,7 +148,10 @@ npm install vue dropzone keycode vue-tippy vue2-filters vue-lightbox vuemit
146148
>
147149
> after you are done, maybe you can send me a PR so everyone else can benefit from it :trophy:
148150
149-
## ToDo "ANY HELP IS DEEPLY APPRECIATED"
151+
## Notes
152+
- if you are using multilocale and you are having issues when switching to different locale other than `en`, [MultiLocale](https://github.com/ctf0/Laravel-Media-Manager/wiki/MultiLocale).
153+
154+
## ToDo "ANY HELP IS APPRECIATED"
150155

151156
* [ ] Add Support To Other Css Frameworks.
152157
* [ ] Add Support For Editors "tinymce / Ckeditor/ etc".

src/Commands/MMAppend.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace ctf0\MediaManager\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\Facades\File;
7+
8+
class MMAppend extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'mm:append';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = "Append routes to 'routes/web.php', Append assets compiling to 'webpack.mix.js'";
23+
24+
/**
25+
* Create a new command instance.
26+
*/
27+
public function __construct()
28+
{
29+
parent::__construct();
30+
}
31+
32+
/**
33+
* Execute the console command.
34+
*
35+
* @return mixed
36+
*/
37+
public function handle()
38+
{
39+
// routes
40+
$route_file = base_path('routes/web.php');
41+
$search = 'MediaManager';
42+
if (File::exists($route_file) && !str_contains(File::get($route_file), $search)) {
43+
$data = "\n// Media-Manager\nnew \ctf0\MediaManager\MediaRoutes();";
44+
45+
File::append($route_file, $data);
46+
$this->comment("['new \ctf0\MediaManager\MediaRoutes()'] added to [web.php]");
47+
}
48+
49+
// mix
50+
$mix_file = base_path('webpack.mix.js');
51+
$search = 'MediaManager';
52+
if (File::exists($mix_file) && !str_contains(File::get($mix_file), $search)) {
53+
$data = "\n// Media-Manager\nmix.js('resources/assets/vendor/MediaManager/js/media.js', 'public/assets/vendor/MediaManager/script.js')\n\t.sass('resources/assets/vendor/MediaManager/sass/' + process.env.MIX_MM_FRAMEWORK + '/media.scss', 'public/assets/vendor/MediaManager/style.css')\n\t.version();";
54+
55+
File::append($mix_file, $data);
56+
$this->comment("['mix.js(..).sass(..).version()'] added to [webpack.mix.js]");
57+
}
58+
59+
// fw
60+
$env_file = base_path('.env');
61+
$search = 'MIX_MM_FRAMEWORK';
62+
if (File::exists($env_file) && !str_contains(File::get($env_file), $search)) {
63+
$data = "\nMIX_MM_FRAMEWORK=bulma";
64+
65+
File::append($env_file, $data);
66+
$this->comment("['MIX_MM_FRAMEWORK=bulma'] added to [.env]");
67+
}
68+
}
69+
}

src/MediaManagerServiceProvider.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace ctf0\MediaManager;
44

5-
use Illuminate\Support\Facades\File;
65
use Illuminate\Support\ServiceProvider;
76

87
class MediaManagerServiceProvider extends ServiceProvider
@@ -39,22 +38,9 @@ public function boot()
3938
__DIR__.'/resources/views' => resource_path('views/vendor/MediaManager'),
4039
], 'view');
4140

42-
// routes
43-
$route_file = base_path('routes/web.php');
44-
$search = 'MediaManager';
45-
if (File::exists($route_file) && !str_contains(File::get($route_file), $search)) {
46-
$data = "\n// MediaManager\nnew \ctf0\MediaManager\MediaRoutes();";
47-
48-
File::append($route_file, $data);
49-
}
50-
51-
// mix
52-
$mix_file = base_path('webpack.mix.js');
53-
$search = 'MediaManager';
54-
if (File::exists($mix_file) && !str_contains(File::get($mix_file), $search)) {
55-
$data = "\n// MediaManager\nmix.js('resources/assets/vendor/MediaManager/js/media.js', 'public/assets/vendor/MediaManager/script.js')\n\t.sass('resources/assets/vendor/MediaManager/sass/' + process.env.MIX_MM_FRAMEWORK + '/media.scss', 'public/assets/vendor/MediaManager/style.css')\n\t.version();";
56-
57-
File::append($mix_file, $data);
58-
}
41+
// cmnds
42+
$this->commands([
43+
Commands\MMAppend::class,
44+
]);
5945
}
6046
}

0 commit comments

Comments
 (0)