MacのbrewのPHP7.1にImagickをいれる。
$ brew install php71-imagick
でインストール
$ php -S localhost:8000
でphpinfo()を書いて。テスト
http://localhost:8000 へ。
$ brew install php71-imagick
でインストール
$ php -S localhost:8000
でphpinfo()を書いて。テスト
http://localhost:8000 へ。
2017.12月現在はできました。
いろいろパスを変えてもできなかったのですが、セキュリティー設定を変更するとできました。
インターネットセキュリティーのプロパティーを開いて、[セキュリティー]タブの“信頼済サイト”に該当サイトを追加します。(サイトがhttpsでない場合はhttps必須のチェックを外す)
→InternetExploler/Edgeともこれで開けるようになります。
リンクはfile::///から初めるかたち。
<a href="file:///\exampele.compathtofile_or_dir">リンク文字列</a>
ちなみにMacは、そのままsmb://~で行けました。(iPad/iPhone/Androidなどはどうなるかは未検証
<a href="smb://exampele.com/path/to/file_or_dir">リンク文字列</a>
限定した業務システムなどでは使えそうな感じです。
をつくってみた。
public static function set_date_search($query,$date,$targetKey){
$y = ($date['year'])?'1':'0';
$m = ($date['month'])?'1':'0';
$d = ($date['day'])?'1':'0';
$ymd = ''.$y.$m.$d;
switch($ymd){
case '001':
return $query->where($targetKey,'like','______'.$date['day']);
case '011':
return $query->where($targetKey,'like','____'.$date['month'].$date['day']);
case '100':
return $query->where($targetKey,'like',$date['year'].'____');
case '110':
return $query->where($targetKey,'like',$date['year'].$date['month'].'__');
case '010':
return $query->where($targetKey,'like','____'.$date['month'].'__');
case '101':
return $query->where($targetKey,'like',$date['year'].'__'.$date['day']);
case '111':
return $query->where($targetKey,'=',dateArr2DbString($date));
default:
return $query;
}
}
参考
http://php.net/manual/ja/regexp.reference.escape.php
そのままですが。
$lines = preg_split('/R/',$text);
$textはテキストエリアなどに入力された文字を想定。
win/macどちらからでも
ふつうのコントローラーだと。アクションで return して上げればリダイレクトできる。
function restore($request){
・
・
return Redirect::route("item.index")->with('message', '登録しました。');
}
ただ、親のコントローラーや別のメソッドからだとできない場合は以下の様にする。
function hoge(){
Redirect::route('item.index')->withErrors(['redirect'=>'エラー発生'])->throwResponse();
}
Redirect(ファザード)の実態は。IlluminateRoutingRedirector で、
route()->withErrors()を実行した戻り値は。IlluminateHttpRedirectResponse
その RedirectResponseクラスのthrowResponse();を実行している流れ。
こちらを使わせてもらいました。
kyslik/column-sortable
https://github.com/Kyslik/column-sortable
まずはcomposerでインストール。
$ composer require kyslik/column-sortable
config/app.phpの providersに追加
'providers' => [
/*
* Laravel Framework Service Providers...
*/
IlluminateAuthAuthServiceProvider::class,
IlluminateBroadcastingBroadcastServiceProvider::class,
IlluminateBusBusServiceProvider::class,
・
・
・
・
/*
* paginate sortable ※こちら
*/
KyslikColumnSortableColumnSortableServiceProvider::class,
],
モデルに追記。
<?php
namespace App;
use IlluminateDatabaseEloquentModel;
use SymfonyComponentHttpFoundationRequest;
use KyslikColumnSortableSortable; //※ここと。
class User extends Model
{
use Sortable; // ※ココ
ビューは以下の様に
<th>@sortablelink('email','メールアドレス')</th>
Goodby, CSV
https://github.com/goodby/csv#requirements
composer.json のrequireに“goodby/csv”を追加。
"require": {
"goodby/csv": "*"
}
して、composerをアップデート
$ composer update
$ composer dump-autoload
モデル、ライブラリをuseして使う。
app/ItemCsv.php
<?php
namespace App;
use IlluminateDatabaseEloquentModel;
use GoodbyCSVImportStandardLexer;
use GoodbyCSVImportStandardInterpreter;
use GoodbyCSVImportStandardLexerConfig;
class ItemCsv extends Model
{
protected $table = 'items';
public static function import($path){
$config = new LexerConfig();
$config->setToCharset("UTF-8");
$config->setFromCharset("sjis-win");
$interpreter = new Interpreter();
$tmp = array();
$interpreter->addObserver(function(array $row) use (&$tmp) {
$tmp[] = $row;
});
$lexer = new Lexer($config);
$lexer->parse($path, $interpreter);
dd($tmp);
}
}
あとは、何処かしらから。
ItemCsv::import($path_to_csv_file);
解決した方法。
//routes/web.php
Route::post('item/import/confirm',['as'=>'item.import.confirm','uses'=>'ItemController@importConfirm']);
‘as’ で指定する。実行先は ‘uses’
ルート一覧確認方法
$ php artisan route:list
jQueryのときは、Class内部のメソッド呼び出し時に$.proxy()をつかってましたが、bind()が楽。
class Foo {
constructor(){
$('#btn1').on('click',this.onClick1);
$('#btn2').on('click',$.proxy(this.onClick2,this);
$('#btn3').on('click',this.onClick3.bind(this));
}
onClick1(e){
console.log(this); //thisのスコープが #btn1のElementになる。
}
onClick2(e){
console.log(this); //thisのスコープがclass Fooになる。
}
onClick3(e){
console.log(this); //thisのスコープがclass Fooになる。
}
}
CakePHPのバーチャルフィールドの様な仮想のフィールドの設定方法。
class User extends Model
{
protected $appends = ['name'];
public function getNameAttribute()
{
return $this->lastname. ' ' .$this->firstname;
}
・
・
・
あとはビューで。以下の様に参照するだけ。
$user->name;
Powered by WordPress & Theme by Anders Norén