1. Go to this page and download the library: Download silnex/gula 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/ */
silnex / gula example snippets
// 그누보드
use SilNex\GuLa\Models\Gnu\G5Member;
$g5Member = new G5Member;
$g5Member->where('mb_id', '=', 'admin')->get();
// 영카트
use SilNex\GuLa\Models\Young\G5ShopItem;
$g5ShopItem = new G5ShopItem;
$g5ShopItem->get();
use SilNex\GuLa\Models\Gnu\G5Member;
$g5Member = new G5Member;
$admin = $g5Member->where('mb_id', '=', 'admin')->first();
$admin->g5Points()->get();
// Anywhere
use SilNex\GuLa\G5ModelFactory;
// ['connection', 'table_name']
$g5WriteFree = new G5ModelFactory(['gula', 'g5_write_free']);
$g5WriteFree->get();
use SilNex\GuLa\G5ModelFactory;
use Illuminate\Support\Str;
$notExistsModel = "\SilNex\GuLa\Gnu\G5WriteFree";
if (!class_exists($notExistsModel)) {
$model = explode('\\', $notExistsModel);
$table = Str::snake(end($model));
$g5WriteFree = new G5ModelFactory(['gula', $table]);
$g5WriteFree->get();
}
use SilNex\GuLa\Models\Gnu\G5Member;
var_dump(class_exists("\SilNex\GuLa\Gnu\G5WriteFree")); // bool(false)
$g5Member = new G5Member;
$admin = $g5Member->where('mb_id', '=', 'admin')->first();
$admin->g5WriteFree()->first(); // g5_write_free의 mb_id가 admin인 게시글을 가져옵니다.
// 여러 테이블에서 가져올 수 있습니다.
$admin->with('g5WriteFree', 'g5WriteNotice', 'g5WriteQa')->get();
/** app/G5Models/MyG5CustomTable.php */
namespace App\G5Models;
use SilNex\GuLa\G5Model;
class MyG5CustomTable extends G5Model
{
protected $table = 'my_g5_custom_table';
// ... 그외 MyG5CustomTable에 필요한 사항들
}
/** app/G5Models/G5WriteFree.php */
namespace App\G5Models;
use SilNex\GuLa\G5Model;
class G5WriteFree extends G5Model
{
use \SilNex\GuLa\Traits\BelongToG5Member;
protected $table = 'g5_write_free';
// ... 그외 G5WriteFree에 필요한 사항들
/**
* 댓글 리스트
*/
public function comments()
{
return $this->hasMany(G5WriteFree::class, 'wr_parent', 'wr_id')->where('wr_is_comment', '=', '1');;
}
/**
* 댓글이라면, 게시글을 보여줌
*/
public function parent()
{
if ($this->wr_is_comment) {
return $this->belongsTo(G5WriteFree::class, 'wr_id', 'wr_parent')->where('wr_is_comment', '=', '0');;
} else {
throw new \Exception("해당 글은 댓글이 아닙니다.");
}
}
/**
* 게시판에 첨부된 파일을 가져옴
*/
public function files()
{
return $this->hasMany(G5BoardFile::class, 'wr_id', 'wr_id')->where('bo_table', $this->bo_table);
}
}
// Using
$g5WriteFree = new G5WriteFree;
$g5WriteFree->comments();
$g5WriteFree->first()->files();
bash
php artisan g5model:write free
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.