laradium / laradium
Installs: 170
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 3
Open Issues: 28
Language:CSS
Requires
- ext-json: *
- baum/baum: v2.x-dev
- cviebrock/eloquent-sluggable: 4.8.*
- czim/laravel-paperclip: 2.*
- dimsav/laravel-translatable: ^9.0
- doctrine/dbal: 2.8.*
- laracasts/utilities: ^3.0
- maatwebsite/excel: 3.1.*
- yajra/laravel-datatables-oracle: ~9.0
- dev-master
- 2.2.x-dev
- 2.1.x-dev
- 2.0.x-dev
- v2.0.17
- v2.0.16
- v2.0.15
- v2.0.14
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.0
- dev-dependabot/npm_and_yarn/json5-1.0.2
- dev-dependabot/npm_and_yarn/express-4.18.2
- dev-dependabot/npm_and_yarn/tinymce-5.10.7
- dev-dependabot/npm_and_yarn/qs-and-express-6.11.0
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/loader-utils-and-webpack-cli-1.4.2
- dev-dependabot/npm_and_yarn/jquery-ui-1.13.2
- dev-dependabot/npm_and_yarn/moment-2.29.4
- dev-dependabot/npm_and_yarn/eventsource-1.1.1
- dev-dependabot/npm_and_yarn/url-parse-1.5.10
- dev-dependabot/npm_and_yarn/ajv-6.12.6
- dev-dependabot/npm_and_yarn/datatables.net-1.11.3
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/ws-6.2.2
- dev-dependabot/npm_and_yarn/dns-packet-1.3.4
- dev-dependabot/npm_and_yarn/browserslist-4.16.6
- dev-dependabot/npm_and_yarn/chart.js-2.9.4
- dev-dependabot/npm_and_yarn/codemirror-5.61.0
- dev-dependabot/npm_and_yarn/lodash-4.17.21
- dev-dependabot/npm_and_yarn/ssri-6.0.2
- dev-dependabot/npm_and_yarn/y18n-4.0.1
- dev-dependabot/npm_and_yarn/elliptic-6.5.4
- dev-dependabot/npm_and_yarn/axios-0.21.1
- dev-dependabot/npm_and_yarn/ini-1.3.7
- dev-dependabot/npm_and_yarn/http-proxy-1.18.1
- dev-dependabot/npm_and_yarn/websocket-extensions-0.1.4
- dev-dependabot/npm_and_yarn/jquery-3.5.0
- dev-dependabot/npm_and_yarn/acorn-6.4.1
- dev-l5.8
- dev-interface-renderer
- dev-temp-master
- dev-temp-translations
- dev-l5.7
- dev-page-duplicate
- dev-htmlpreview
- dev-feature/additional-translation-scan-paths
- dev-select2-fix
- dev-feature/charts
- dev-wysiwyg-height
- dev-refactor-forms
- dev-feature/local-storage-file-download
- dev-btm-tags
- dev-tinymce-editor
- dev-menu-bugfix
- dev-feature/permissions
- dev-feature/datatable-reorder
- dev-feature/belongsto-refactor
- dev-LAR-8
- dev-feature/nested-menu
- dev-feature/refactor
- dev-feature/belongs-to
- dev-feature/select-change
This package is not auto-updated.
Last update: 2024-03-18 08:22:43 UTC
README
Package allows you to create advanced CRUD views with relations in light weight admin panel. Using plain laravel database structure, models and VueJS which allows to make it very flexible and can be adjusted up to your needs.
Installation
For local development
- Add this to your project repositories list in
composer.json
file
"repositories": [
{
"type": "path",
"url": "../packages/laradium"
}
]
Directory structure should look like this
-Project
-packages
--laradium
--laradium-content
For global use
"repositories": [
{
"type": "git",
"url": "https://github.com/laradium/laradium.git"
}
]
composer require laradium/laradium dev-master
php artisan vendor:publish --tag=laradium
- Configure
config/laradium.php
file with your preferences - Comment out
Illuminate\Translation\TranslationServiceProvider::class,
inconfig/app.php
in order to enable translations - Run
php artisan migrate
You should be up and running
Admin panel will be under http://your-domain.com/admin
Default credentials (can be change in config file): email:admin@laradium.com, pw: laradium2018
Creating new resource
php artisan laradium:resource Task
It will create new resource under App\Laradium\Resource
, resource should look like this
<?php
namespace App\Laradium\Resources;
use Laradium\Laradium\Base\AbstractResource;
use Laradium\Laradium\Base\FieldSet;
use Laradium\Laradium\Base\ColumnSet;
use App\Models\Task;
Class TaskResource extends AbstractResource
{
/**
* @var string
*/
protected $resource = Task::class;
/**
* @return \Laradium\Laradium\Base\Resource
*/
public function resource()
{
return laradium()->resource(function (FieldSet $set) {
$set->text('type')->rules('required|min:3');
});
}
/**
* @return \Laradium\Laradium\Base\Table
*/
public function table()
{
return laradium()->table(function (ColumnSet $column) {
$column->add('id', '#ID');
});
}
}
You will have 2 methods resource
and table
.
Resource
Here you can specify field configuration for your create and edit actions.
Available field list
Text
$set->text('name')->rules('required')->translatable();
Textarea
$set->textarea('name')->rules('required')->translatable();
Wysiwyg
$set->wysiwyg('name')->rules('required')->translatable();
$set->email('email')->rules('required|email');
Password
$set->password('password')->rules('required|confirmed|min:3|max:36');
$set->password('password_confirmation');
Boolean
$set->boolean('is_active');
Select
$set->select('target')
->options([
'_self' => 'Self',
'_target' => 'Target',
])
->rules('required');
Date
$set->date('starts_at')->rules('date_format:Y-m-d');
Time
$set->time('starts_at')->rules('date_format:H:i');
DateTime
$set->datetime('starts_at')->rules('date_format:Y-m-d H:i');
Color
$set->color('color');
HasMany
- First argument must be the name of the relation
- Fields method should contain fields that is required for relation
- You can make items sortable, if you add sortable column to your table and specify column name in
sortable
method - You can remove create and/or delete actions for items by adding
actions
method
$set->hasMany('items')
->fields(function (FieldSet $set) {
$set->boolean('is_active');
$set->select('target')->options([
'_self' => 'Self',
'_target' => 'Target',
])->rules('required');
$set->text('name')->rules('required')->translatable();
$set->text('url')->rules('required')->translatable();
})
->sortable('sequence_no')
->actions([]); // This will remove both create/delete actions
HasOne
- First argument must be the name of the relation
- Fields method should contain fields that is required for relation
$set->hasOne('author')
->fields(function (FieldSet $set) {
$set->text('name');
});
BelongsTo
- First argument must be class of relation where items will belong
$set->belongsTo(Article::class)
->hideIf(true) // optional if value is true, field will be hidden and value will be set from "default" method
->default(2);
BelongsToMany
- First argument must be name of the relation in model
- Second argument is label for field
$set->belongsToMany('menuItems', 'Menu items');
Tab (Lets you put certain field groups under certain tabs for better UI)
- First argument must be the name of the tab
- Fields method must contain fields that will be under this tab
$set->tab('Items')->fields(function (FieldSet $set) {
$set->hasMany('items')->fields(function (FieldSet $set) {
$set->boolean('is_active');
$set->select('target')->options([
'_self' => 'Self',
'_target' => 'Target',
])->rules('required');
$set->text('name')->rules('required')->translatable();
$set->text('url')->rules('required')->translatable();
})->sortable('sequence_no');
});
File
For managing files we use https://github.com/czim/laravel-paperclip package. You don't need to set it up individually because it comes with base package.
$set->file('image');
By default package uses Laravel's public storage, we do not like to deal with symlinks that's why we have changed configuration to this:
Storage configuration in config/paperclip.php
'storage' => [
// The Laravel storage disk to use.
'disk' => 'public_root',
// Per disk, the base URL where attachments are stored at
'base-urls' => [
'public_root' => config('app.url') . '/uploads',
],
],
Add new disk to config/filesystems.php
'public_root' => [
'driver' => 'local',
'root' => public_path('uploads'),
],
Available methods for fields
- attr() // You can pass array of html attributes to add to the field
$set->text('field')->attr([
'required' => 'required'
]);
- col() // With this method you can change layout of the fields in form
$set->text('field')->col(6, 'lg'); // Default type is - md, so if you need md, you can only specify col number
$set->text('field-2')->col(6, 'lg');
- options() // Pass options to the `select` field
$set->select('field')->options([
'key' => 'value'
]);
- rules() // You can specify validation rules for this field
$set->text('field')->rules('required|min:1|max:255');
- translatable() // Make field translatable
$set->text('field')->translatable();
# Table
Available fields for columns
## Add
$column->add('column_name_in_table', 'Nice column name');
## Editable (Allows you to edit database column from index view)
$column->add('column_name_in_table', 'Nice column name')->editable();
## Modify (Allow you to modify columns data output)
$column->add('is_active', 'Is Visible?') ->modify(function ($item) { return $item->is_active ? 'Yes' : 'No'; });
## Title
$column->add('column_name_in_table')->title('Nice column name');
## Translatable
$column->add('title')->translatable();
NOTE: You need to specify additional method for Table `relations(['translations'])` to enable eager loading and improve performance
Available methods for Table
## Actions (create, edit, delete)
->actions(['edit', 'delete'])
## Relations
->relations(['translations'])
## Additional view which will be included above the table
->additionalView('laradium-content::admin.pages.index-top', compact('channels'));