/** * マイグレーション実行 * * @return void */ public function up() { Schema::create('information', function (Blueprint $table) { $table->increments('id'); $table->integer('group_id')->unsigned(); $table->foreign('group_id')->references('id')->on('groups')->onDelete('restrict'); $table->timestamp('datetime'); $table->string('title'); $table->text('message'); $table->timestamps(); $table->softDeletes(); $table->unsignedInteger('created_user_id')->nullable(); $table->unsignedInteger('updated_user_id')->nullable(); $table->unsignedInteger('deleted_user_id')->nullable(); }); $information = new Information(); $information->group_id = Group::GUEST; $information->title = '開発開始'; $information->message = "開発開始しました"; $information->datetime = Carbon::createFromFormat(config('format.date'), '2015/9/11'); $information->save(); $information = new Information(); $information->group_id = Group::SYSTEM; $information->title = '開発環境について'; $information->message = "使用言語:PHP5.6\nフレームワーク:Laravel5.1\nデータベース:MySQL\nCSS:Bootstrap3"; $information->datetime = Carbon::createFromFormat(config('format.date'), '2015/9/12'); $information->save(); }
/** * Index Layout * * @return @Theme View */ public function onPageUserInformation() { Meta::title(Lang::get('meta.user information')); Meta::meta('description', Lang::get('meta.user information description')); $query = \App\Models\User::leftJoin('roles', 'roles.id', '=', 'users.role_id')->leftJoin('companies', 'companies.id', '=', 'users.company_id')->select('users.*')->where('roles.authorize', '=', '0'); if (Auth::user()->authorize() != 1) { $query = $query->where('users.company_id', '=', Auth::user()->company_id); } $query = $query->addSelect('roles.name as role_name')->addSelect('companies._id as company_id')->addSelect('companies.name as company_name'); $grid = new Grid((new GridConfig())->setDataProvider(new EloquentDataProvider($query))->setName('grid')->setPageSize(15)->setColumns([(new FieldConfig())->setName('email')->setLabel(Lang::get('label.email'))->setSortable(true), (new FieldConfig())->setName('first_name')->setLabel(Lang::get('label.first name'))->setSortable(true), (new FieldConfig())->setName('last_name')->setLabel(Lang::get('label.last name'))->setSortable(true), (new FieldConfig())->setName('information')->setLabel(Lang::get('label.leave entitlement'))->setSortable(true), (new FieldConfig())->setName('active')->setLabel(Lang::get('label.active'))->setSortable(false)->setCallback(function ($val) { return '<a href="javascript:active(\'' . $val . '\')"><center><i class="fa ' . ($val ? 'fa-check' : 'fa-close') . '"></i></center></a>'; })])); $grid2 = new Grid((new GridConfig())->setDataProvider(new EloquentDataProvider(\App\Models\Information::leftJoin('users', 'users.id', '=', 'informations.created_by')->leftJoin('information_companies', 'information_companies.information_id', '=', 'informations.id')->select('informations.*')->addSelect("users.first_name as upload_name")->where("information_companies.company_id", Auth::user()->company_id)->addSelect("informations.created_at as upload_at")))->setName('grid')->setPageSize(15)->setColumns([(new FieldConfig())->setName('name')->setLabel(Lang::get('label.name'))->setSortable(false)->setCallback(function ($val) { return '<a href="' . url('file/information/download/' . $val) . '">' . $val . '</a>'; }), (new FieldConfig())->setName('description')->setLabel(Lang::get('label.description'))->setSortable(true), (new FieldConfig())->setName('upload_name')->setLabel(Lang::get('label.upload by'))->setSortable(true), (new FieldConfig())->setName('upload_at')->setLabel(Lang::get('label.upload at'))->setSortable(true)])); return Theme::view('users.pages.user-information', compact('grid', 'grid2', 'text')); }
/** * Function Download Information File * to Response Form User * @Request @Name,@Code etc * * @return response ajax */ public function onInformationDownload($id) { $path = base_path() . '/public/uploads/informations/'; $id = $id; $row = \App\Models\Information::select(['name'])->where('name', $id)->first(); if ($row) { $file = $path . $row->name; return response()->download($file); } else { } }
public function getIndex() { $maxInformation = config('const.max_home_information'); $informations = Information::orGroup(Group::SYSTEM)->orderBy('datetime', 'desc')->limit($maxInformation)->get(); return view('home.index', compact('informations')); }