Skip to content

Commit 5abe1db

Browse files
committed
codes
1 parent 022f33f commit 5abe1db

File tree

80 files changed

+23794
-0
lines changed

Some content is hidden

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

80 files changed

+23794
-0
lines changed

composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "ntuple/laravel-blockbuilder",
3+
"description": "",
4+
"type": "project",
5+
"license": "MIT",
6+
"keywords":[
7+
"laravel"
8+
],
9+
"authors": [
10+
{
11+
"name": "Abhinav Singh Dangol",
12+
"email": "[email protected]"
13+
}
14+
],
15+
"minimum-stability": "dev",
16+
"require": {
17+
"php":">=5.6",
18+
"webwizo/laravel-shortcodes": "1.0.*"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"Ntuple\\BlockBuilder\\": "src/"
23+
}
24+
},
25+
"extra": {
26+
"laravel": {
27+
"providers": [
28+
"Webwizo\\Shortcodes\\ShortcodesServiceProvider"
29+
]
30+
}
31+
}
32+
}

src/BlockBuilderServiceProvider.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace Ntuple\BlockBuilder;
4+
5+
use Webwizo\Shortcodes\View\Factory;
6+
use Illuminate\Support\ServiceProvider;
7+
use Webwizo\Shortcodes\Compilers\ShortcodeCompiler;
8+
use Webwizo\Shortcodes\Shortcode;
9+
10+
class BlockBuilderServiceProvider extends ServiceProvider
11+
{
12+
/**
13+
* Perform post-registration booting of services.
14+
*
15+
* @return void
16+
*/
17+
public function boot()
18+
{
19+
$this->enableCompiler();
20+
}
21+
/**
22+
* Enable the compiler.
23+
*/
24+
public function enableCompiler()
25+
{
26+
// Check if the compiler is auto enabled
27+
$state = $this->app['config']->get('laravel-shortcodes::enabled', false);
28+
// Enable when needed
29+
if ($state) {
30+
$this->app['shortcode.compiler']->enable();
31+
}
32+
}
33+
/**
34+
* Register the service provider.
35+
*
36+
* @return void
37+
*/
38+
public function register()
39+
{
40+
$this->registerBlockBuilder();
41+
42+
$this->app->register('Webwizo\Shortcodes\ShortcodesServiceProvider');
43+
44+
$this->registerBlockBuilderShortCode();
45+
}
46+
47+
/**
48+
* Register any application services.
49+
*
50+
* @return void
51+
*/
52+
public function registerBlockBuilder()
53+
{
54+
$this->loadViewsFrom(__DIR__.'/views', 'blockbuilder');
55+
56+
$this->publishes([
57+
__DIR__.'/assets' => public_path('vendor/blockbuilder')
58+
],'blockbuilder_asset');
59+
}
60+
61+
/**
62+
* Register a new shortcode
63+
*
64+
* @return
65+
*/
66+
public function registerBlockBuilderShortCode()
67+
{
68+
return app('shortcode')->register('block', 'Ntuple\BlockBuilder\Services\BlockBuilderService@register');
69+
}
70+
}

src/Services/BlockBuilderService.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Ntuple\BlockBuilder\Services;
4+
5+
use Illuminate\Support\Facades\DB;
6+
7+
class BlockBuilderService
8+
{
9+
/**
10+
* @param $shortcode
11+
* @param $content
12+
*
13+
* @return string
14+
*
15+
* @throws \Throwable
16+
*/
17+
public function register($shortcode, $content)
18+
{
19+
$data = json_decode($content);
20+
21+
return $this->render($shortcode->type, $data->label, $data->sql);
22+
}
23+
/**
24+
* @param string $plugin
25+
* @param array $label
26+
* @param string $sql
27+
*
28+
* @return string
29+
* @throws \Throwable
30+
*/
31+
public function render(string $plugin, array $label, string $sql)
32+
{
33+
$sql = count($label) ? str_replace('*', implode(',', $label), $sql) : $sql;
34+
35+
$data['sql'] = DB::select(DB::raw($sql));
36+
37+
return view('blockbuilder::components.'. $plugin, $data)->render();
38+
}
39+
}

src/assets/assets/bootstrap/css/bootstrap.min.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/assets/bootstrap/js/bootstrap.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)