1. Go to this page and download the library: Download wangta69/laravel_board library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wangta69 / laravel_board example snippets
public function __construct()
{
$this->middleware('auth');
// Example: Check for administrator role
// if (!Auth::user()->hasRole('administrator')) {
// abort(403, 'Unauthorized action.');
// }
}
// config/pondol-bbs.php
'admin' => [
'layout' => [
// 1) Component format (e.g. 'pondol-common::common-admin')
// 2) Traditional @extends format (e.g. 'admin.layouts.admin')
// 3) null: Runs standalone with package default layout
'name' => 'pondol-common::common-admin',
// LNB sidebar view (set null to use host's native sidebar)
'lnb' => 'bbs::lnb-partial',
// Section name for @extends mode (default: 'content')
'section' => 'content',
// Title section name for @extends mode (default: 'title')
'title_section' => 'title',
],
],
namespace App\Services;
use Pondol\Bbs\Contracts\BbsQueryCustomizer as BbsQueryCustomizerInterface;
class BbsQueryCustomizer implements BbsQueryCustomizerInterface
{
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Pondol\Bbs\Models\BbsTables $cfg
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Database\Eloquent\Builder
*/
public function indexQuery($query, $cfg, $request)
{
// Custom join for 'qna' board
if ($cfg->table_name === 'qna') {
$query->leftJoin('users as u', 'u.id', '=', 'bbs_articles.user_id')
->leftJoin('agents as a', 'u.agent', '=', 'a.id')
->addSelect([
'bbs_articles.*',
'a.name as agent_name',
'u.email'
]);
}
return $query;
}
}
use Pondol\Bbs\Contracts\BbsQueryCustomizer;
use App\Services\BbsQueryCustomizer as MyBbsQueryCustomizer;
public function register()
{
$this->app->bind(
BbsQueryCustomizer::class,
MyBbsQueryCustomizer::class
);
}
namespace App\Services;
use Pondol\Bbs\Contracts\BbsMetaResolver;
use Illuminate\Support\Str;
class MyBbsMetaResolver implements BbsMetaResolver
{
/**
* @param \Pondol\Meta\Meta $meta
* @param string $type 'index' or 'show'
* @param object $cfg Board Configuration (BbsTables)
* @param object|null $article Article Data (BbsArticles)
* @param mixed|null $collection Articles Collection (on index)
*/
public function resolve($meta, $type, $cfg, $article = null, $collection = null)
{
if ($cfg->table_name === 'notice') {
$meta->title("[Notice] " . ($article ? $article->title : $cfg->name));
}
if ($type === 'show' && $article) {
$description = Str::limit(strip_tags($article->content), 160);
$meta->description($description);
if ($article->image) {
$meta->image(\Storage::disk('public')->url($article->image));
}
}
return $meta;
}
}
public function register()
{
$this->app->bind(
\Pondol\Bbs\Contracts\BbsMetaResolver::class,
\App\Services\MyBbsMetaResolver::class
);
}