アプリ関連ニュース

知っておいていただきたいこと – 12

今日もlaravelのTipsをいくつか共有したいと思います。

アプリケーションを作成する際、他のユーザーがアクセスできない管理者ロールを用意することがほとんどでしょう。別のコントロールを繰り返し追加する代わりに、 ルートやコントローラに適用できるミドルウェアを作成することを検討しましょう。これは、absort ヘルパーや absort_unless ヘルパーを使えば簡単に実現できます。

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;

class CheckUserIsAdmin{
     public function handle(Request $request, Closure $next){
        abort_unless(Auth::user()?->isAdmin(), Request::HTTP_FORBIDDEN);
        return $next($request);
     }
}

そして、そのミドルウェアをルートHTTPカーネルに追加する。

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel{
    protected $routeMiddleware = [
       'admin' => \App\Http\Middleware\CheckUserIsAdmin::class;
     ];
}

最後に、ミドルウェアを適用する

use App\Http\Middleware\AdminUserController;
use App\Http\Middleware\AdminDashboardController;

Route::prefix('admin')->middleware('admin')->group(function(){
  Route::get('/',[AdminDashboardController::class, 'index']);
  Route::get('/users',[AdminUserController::class, 'index']);
});

ということで、今回はこれで終わります。

金曜担当 – Ami



Nothing Phone 1

Nothing finally announces its first smartphone, the Nothing Phone 1 by OnePlus co-founder Carl Pei. Nothing is said that Phone 1 will be available in more than 40 markets, including the UK, Japan, India, and countries of the Europe.

The Nothing Phone (1) is an Android device with the Qualcomm Snapdragon 778G + chipset introduced by Qualcomm over a year ago. It has the same power and performance as the regular Snapdragon 778G found on overseas mobile phone models, but the “plus” indicates that it has changed which can customize the chip to allow the phone (1) to be wirelessly and reversely charged.

The screen is a 6.55 inch flexible OLED display with a resolution of 2400 x 1080 pixels and a maximum peak brightness of 1200 knits for very sunny conditions. The screen has an adaptive refresh rate of 120Hz, which matches mid-range devices such as the Samsung Galaxy A535G and flagship products such as the Google Pixel 6 Pro.

Phone (1) can be used with 8GB of RAM and 128GB of storage, or 12GB of RAM and 256GB of storage.

It packs its in-display fingerprint sensor, dual stereo speakers, IP53 water resistance, and Face ID-like unlock capabilities with a 4,500mAh battery. With dual cameras: a 50 MP main camera with f/1.88 aperture along with a 50 MP ultra-wide sensor with f/2.2 aperture and macro capabilities. There’s also a 16 MP front-facing camera with an f/2.45 aperture and night shooting capabilities.

The cool thing is there are 900 creatively placed LEDs on the back of the Nothing Phone (1). They are customizable and can help notify you when a particular contact calls or sends a message to your phone.

Actually there are lot of features and the price is affordable which tends to get interest by end users. On the other hand, the maturity and community is still building and the product still might contains bugs and errors.

Yuuma



知っておいていただきたいこと – 11

今日もlaravelのTipsをいくつか共有したいと思います。

foreignIdFor() メソッドを使って、与えられたモデルクラスと同等のカラムを追加できること

$table->foreignId('user_id');
それとも
$table->foreignIdFor(User::class);

//Userモデルに関連するuser_idカラム

QueryBuilderの insert メソッドを使用したときに、bool値ではなくレコード ID を返したい場合、insertGetId を使用

$data = [....];

DB::table('users')->insert($data);
//return bool

DB::table('users')->insertGetId($data);
//return レコード ID (E.G 13)

ということで、今回はこれで終わります。

金曜担当 – Ami



[Laravel] Auth 機能とMiddlewareの設定(3)

今回はLaravel標準の認証機能とMiddlewareによる認証チェック機能についての情報を
シェアしたいと思います。
本記事は前回の「[Laravel] Auth 機能とMiddlewareの設定(2)」の続きです。

続きを読む

5 useful image libraries for PHP developers

Today, I would like to share about 5 useful image libraries for PHP developers. Let’s take a look.

1. Zebra Image

This  is a lightweight and object oriented image manipulation library. . It can convert one format to another format easily. The formats supported by Zebra Image including .JPG, .GIF and .PNG .

2. Dynamic Dummy Image Generator

This library is a free PHP script by which images of any size and color can be generated.  And text can be written over the images.

3. PhpThumb

This library is a  PHP image manipulating library that allows to rotate, crop, and watermark the mages and define their quality. It accepts all the source types for images.

4. Php Graphic Works

This library is for image manipulation on the server side. It allows to perform complex image processing in an easy way. It can perform rotating, cropping, resizing, stretching, and flipping.

5. Image Cache

This library is a lightweight PHP class to move, compress, and cache the image in the browser/ It can set various options such as the base URL, the directory, etc.

This is all for now. Hope you enjoy that.

By Asahi



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム