Skip to content

Commit ed42635

Browse files
committed
feat: add media management components and custom select2 integration
1 parent cfd7a47 commit ed42635

File tree

211 files changed

+25027
-1103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+25027
-1103
lines changed

LICENSE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Javaabu Pvt. Ltd.
3+
Copyright (c) Javaabu Pvt Ltd
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -9,7 +9,7 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
copies of the Software, and to permit persons to whom the Software is
1010
furnished to do so, subject to the following conditions:
1111

12-
The above copyright notice and this permission notice shall be included in all
12+
The above written permission notice and this permission notice shall be included in all
1313
copies or substantial portions of the Software.
1414

1515
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 279 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,304 @@
1-
# Content Management System
1+
# Javaabu CMS
22

3-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/javaabu/cms.svg?style=flat-square)](https://packagist.org/packages/javaabu/cms)
4-
[![Test Status](../../actions/workflows/run-tests.yml/badge.svg)](../../actions/workflows/run-tests.yml)
5-
![Code Coverage Badge](./.github/coverage.svg)
6-
[![Total Downloads](https://img.shields.io/packagist/dt/javaabu/cms.svg?style=flat-square)](https://packagist.org/packages/javaabu/cms)
3+
A flexible and extensible Content Management System package for Laravel applications. Built with support for custom post types, hierarchical categories, and rich content editing with Editor.js.
74

5+
## Features
86

7+
- 🎯 **Custom Post Types**: Define unlimited custom post types with configurable features
8+
- 📁 **Hierarchical Categories**: Nested category support using Nestedset
9+
- ✍️ **Rich Content Editor**: Integrated Editor.js support for modern content editing
10+
- 🔐 **Permission System**: Built-in permission management for CMS operations
11+
- 🌐 **Multi-language Ready**: Translation support for content
12+
- 📱 **Responsive Admin**: Modern admin interface
13+
- 🔌 **Extensible**: Easy to extend with custom controllers, views, and policies
14+
- 🚀 **Easy Setup**: Artisan command for quick installation
915

10-
## Introduction
11-
Content Management System integration for Laravel Projects
16+
## Requirements
1217

13-
## Documentation
18+
- PHP ^8.2
19+
- Laravel ^11.0 or ^12.0
20+
- MySQL/PostgreSQL database
1421

15-
You'll find the documentation on [https://docs.javaabu.com/docs/cms](https://docs.javaabu.com/docs/cms).
22+
## Installation
1623

17-
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving this package? Feel free to create an [issue](../../issues) on GitHub, we'll try to address it as soon as possible.
24+
Install the package via Composer:
1825

19-
If you've found a bug regarding security please mail [info@javaabu.com](mailto:info@javaabu.com) instead of using the issue tracker.
26+
```bash
27+
composer require javaabu/cms
28+
```
2029

30+
Run the setup command:
2131

22-
## Testing
32+
```bash
33+
php artisan cms:setup
34+
```
35+
36+
This will:
37+
- Publish the configuration file
38+
- Publish and run migrations
39+
- Optionally install default post types and categories
40+
- Seed CMS permissions
41+
42+
### Quick Start with Defaults
2343

24-
You can run the tests with
44+
To get started quickly with pre-configured post types and categories:
2545

26-
``` bash
27-
./vendor/bin/phpunit
46+
```bash
47+
php artisan cms:setup --with-defaults
2848
```
2949

30-
## Changelog
50+
This installs 10 ready-to-use post types (News, Blog, Downloads, Announcements, Publications, Jobs, Galleries, Tenders, Reports, Pages) with their category types and sample categories.
3151

32-
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
52+
You can customize these defaults in `config/cms.php` before running setup.
3353

34-
## Contributing
54+
## Configuration
3555

36-
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
56+
After installation, configure your post types in `config/cms.php`:
3757

38-
## Security
58+
```php
59+
'post_types' => [
60+
'news' => [
61+
'label' => 'News',
62+
'singular_label' => 'News Article',
63+
'features' => ['categories', 'featured_image', 'excerpt'],
64+
'category_types' => ['news-categories'],
65+
],
66+
'blog' => [
67+
'label' => 'Blog Posts',
68+
'singular_label' => 'Blog Post',
69+
'features' => ['categories', 'featured_image', 'excerpt', 'video-link'],
70+
'category_types' => ['blog-categories'],
71+
],
72+
],
3973

40-
If you discover any security related issues, please email [info@javaabu.com](mailto:info@javaabu.com) instead of using the issue tracker.
74+
'category_types' => [
75+
'news-categories' => [
76+
'label' => 'News Categories',
77+
'singular_label' => 'News Category',
78+
'hierarchical' => true,
79+
],
80+
],
81+
```
4182

42-
## Credits
83+
## Register Routes
4384

44-
- [Javaabu Pvt. Ltd.](https://github.com/javaabu)
45-
- [Arushad Ahmed (@dash8x)](http://arushad.com)
46-
- [FlameXode (@WovenCoast)](https://github.com/WovenCoast)
47-
- [All Contributors](../../contributors)
85+
Add CMS routes to your `routes/web.php`:
86+
87+
```php
88+
use Javaabu\Cms\Support\Routes;
89+
90+
// Admin routes
91+
Routes::admin(
92+
prefix: 'admin',
93+
middleware: ['web', 'auth', 'verified']
94+
);
95+
96+
// Public routes
97+
Routes::web();
98+
99+
// Or register custom post type routes
100+
Routes::customPostType(
101+
postTypeSlug: 'news',
102+
prefix: 'news',
103+
middleware: ['web']
104+
);
105+
```
106+
107+
## Usage
108+
109+
### Creating Post Types
110+
111+
Post types can be created via:
112+
113+
1. **Database Seeder**:
114+
```php
115+
use Javaabu\Cms\Models\PostType;
116+
117+
PostType::create([
118+
'name' => 'News',
119+
'singular_name' => 'News Article',
120+
'slug' => 'news',
121+
'icon' => 'newspaper',
122+
'features' => [
123+
'categories' => true,
124+
'featured_image' => true,
125+
'excerpt' => true,
126+
],
127+
]);
128+
```
129+
130+
2. **Admin Panel**: Navigate to `/admin/post-types` after setup
131+
132+
### Creating Posts
133+
134+
```php
135+
use Javaabu\Cms\Models\Post;
136+
use Javaabu\Cms\Enums\PostStatus;
137+
138+
$post = Post::create([
139+
'type' => 'news',
140+
'title' => 'Breaking News',
141+
'slug' => 'breaking-news',
142+
'content' => '<p>Content here...</p>',
143+
'excerpt' => 'Short description',
144+
'status' => PostStatus::PUBLISHED->value,
145+
'published_at' => now(),
146+
]);
147+
148+
// Attach categories
149+
$post->categories()->attach($categoryIds);
150+
```
151+
152+
### Querying Posts
153+
154+
```php
155+
use Javaabu\Cms\Models\Post;
156+
157+
// Get published posts of a type
158+
$posts = Post::postType('news')
159+
->published()
160+
->ordered()
161+
->paginate(15);
162+
163+
// Search posts
164+
$posts = Post::postType('news')
165+
->search('keyword')
166+
->published()
167+
->get();
168+
169+
// Get posts by year
170+
$posts = Post::postType('news')
171+
->publishedByYear(2024)
172+
->get();
173+
```
174+
175+
### Working with Categories
176+
177+
```php
178+
use Javaabu\Cms\Models\Category;
179+
180+
// Get categories for select dropdown
181+
$categories = Category::categoryList($typeId);
182+
183+
// Get nested categories
184+
$categories = Category::categoryType($typeId)
185+
->defaultOrder()
186+
->get()
187+
->toTree();
188+
```
189+
190+
## Available Post Type Features
191+
192+
- `categories` - Category support
193+
- `featured_image` - Featured image
194+
- `excerpt` - Post excerpt
195+
- `documents` - Document attachments
196+
- `image_gallery` - Image gallery
197+
- `video_link` - Video embed URL
198+
- `document_number` - Document reference number
199+
- `expireable` - Expiry date
200+
- `format` - Post format (standard, video, gallery, etc.)
201+
- `page_style` - Custom page styling
202+
- `ref_no` - Reference number
203+
- `gazette_link` - Gazette document link
204+
205+
## Permissions
206+
207+
The package dynamically creates permissions for each Post Type and Category Type you create. Permissions are based on the slug of the type.
208+
209+
### Post Type Permissions
210+
211+
For each Post Type (e.g., 'news'), the following permissions are created:
212+
- `edit_{slug}` - Edit own posts (e.g., `edit_news`)
213+
- `edit_others_{slug}` - Edit all posts (e.g., `edit_others_news`)
214+
- `delete_{slug}` - Delete own posts
215+
- `delete_others_{slug}` - Delete all posts
216+
- `view_{slug}` - View own posts
217+
- `view_others_{slug}` - View all posts
218+
- `force_delete_{slug}` - Force delete own posts
219+
- `force_delete_others_{slug}` - Force delete all posts
220+
- `publish_{slug}` - Publish own posts
221+
- `publish_others_{slug}` - Publish all posts
222+
- `import_{slug}` - Import posts
223+
224+
### Category Type Permissions
225+
226+
For each Category Type (e.g., 'news-categories'), the following permissions are created:
227+
- `edit_{slug}` - Edit categories (e.g., `edit_news_categories`)
228+
- `delete_{slug}` - Delete categories
229+
- `view_{slug}` - View categories
230+
- `import_{slug}` - Import categories
231+
232+
### Seeding Permissions
233+
234+
Seed them using:
235+
236+
```php
237+
use Javaabu\Cms\seeders\CmsPermissionsSeeder;
238+
239+
CmsPermissionsSeeder::seedPermissions();
240+
```
241+
242+
Call this after creating your Post Types and Category Types to generate the appropriate permissions.
243+
244+
## Frontend Integration
245+
246+
The package provides models and data - implement your own views:
247+
248+
```blade
249+
{{-- resources/views/posts/index.blade.php --}}
250+
@foreach($posts as $post)
251+
<article>
252+
<h2>{{ $post->title }}</h2>
253+
<p>{{ $post->excerpt }}</p>
254+
<a href="{{ route('posts.show', [$post->type, $post->slug]) }}">
255+
Read More
256+
</a>
257+
</article>
258+
@endforeach
259+
```
260+
261+
## Editor.js Integration
262+
263+
Install the required npm packages:
264+
265+
```bash
266+
npm install --save @editorjs/editorjs @editorjs/header @editorjs/list @editorjs/image @editorjs/quote @editorjs/table @editorjs/delimiter @editorjs/embed @editorjs/link @editorjs/raw @editorjs/simple-image @calumk/editorjs-columns
267+
```
268+
269+
Or copy dependencies from `package.json` in the package root.
270+
271+
### Frontend Configuration
272+
273+
You must also configure the `window.Laravel` object in your admin layout. See the [Installation and Setup Guide](docs/installation-and-setup.md#laravel-object-configuration) for details.
274+
275+
## Testing
276+
277+
```bash
278+
composer test
279+
```
280+
281+
## Documentation
282+
283+
For detailed documentation, see the [docs](docs/) directory:
284+
285+
- [Installation and Setup](docs/installation-and-setup.md)
286+
- [Requirements](docs/requirements.md)
287+
- [Basic Usage](docs/basic-usage/)
288+
289+
## Contributing
290+
291+
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
292+
293+
## Security
294+
295+
If you discover any security-related issues, please email security@javaabu.com instead of using the issue tracker.
48296

49297
## License
50298

51299
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
300+
301+
## Credits
302+
303+
- [Javaabu](https://javaabu.com)
304+
- [All Contributors](../../contributors)

0 commit comments

Comments
 (0)