Top 10 Trucks tips

Check Image EXIF Details in the Photos App

iOS 15 finally lets you check the EXIF details of an image from the default Photos app. This means you’ll no longer have to rely on third-party apps just to check the details of a photo you have taken. You can open any image in the Photos app and tap on the info ‘i’ button to view photo size, maps, photo date, time, resolution, and more.

Model boot() method

There is a magical place called boot() in an Eloquent model where you can override default behavior:

 1class User extends Model 2{ 3    public static function boot() 4    { 5        parent::boot(); 6        static::updating(function($model) 7        { 8            // do some logging 9            // override some property like $model->something = transform($something);10        });11    }12}

Probably one of the most popular examples is setting some field value at the moment of creating the model object. Let’s say you want to generate UUID field at that moment.

1public static function boot()2{3  parent::boot();4  self::creating(function ($model) {5    $model->uuid = (string)Uuid::generate();6  });7}

Add Apple Music to Photos Memories

The default Photos app carries a Memories feature that combines your recent photos and creates a video out of it using animations and other cool tricks. In iOS 15, you can now set any music clip from the Apple Music app and make your memories even more beautiful. Memories will change the slideshow look and feel based on the song selection with custom filters and animations.

Add Wallpaper Background in Safari Browser

This was already possible in Safari on macOS Big Sur. iOS 15 carries the same wallpaper customization trick to the iPhone as well. Open Safari on the iPhone and scroll down to the bottom. Select Edit, and you can pick a relevant wallpaper from the Background Image menu. One can also go ahead and add wallpaper from the gallery on the iPhone.

Relationship with conditions and ordering

This is a typical way to define relationship:

1public function users() {2    return $this->hasMany('App\User');3}

But did you know that at this point we can already add where or orderBy? For example, if you want a specific relationship for some type of users, also ordered by email, you can do this:

1public function approvedUsers() {2    return $this->hasMany('App\User')->where('approved', 1)->orderBy('email');3}

Safari Extensions

Similar to the macOS Safari browser, users can now use the same extensions for the Safari on iPhone as well. Previously, it was limited to ad-blockers only. iOS 15 open the doors for developers to create mobile-friendly extensions for the Safari browser. The collection is slim for now. But we can expect to see more developers creating Safari browser extensions in the future.

Model properties: timestamps, appends etc.

There are a few “parameters” of an Eloquent model, in the form of properties of that class. The most popular ones are probably these:

1class User extends Model {2    protected $table = 'users';3    protected $fillable = ['email', 'password']; // which fields can be filled with User::create()4    protected $dates = ['created_at', 'deleted_at']; // which fields will be Carbon-ized5    protected $appends = ['field1', 'field2']; // additional values returned in JSON6}

But wait, there’s more:

1protected $primaryKey = 'uuid'; // it doesn't have to be "id"2public $incrementing = false; // and it doesn't even have to be auto-incrementing!3protected $perPage = 25; // Yes, you can override pagination count PER MODEL (default 15)4const CREATED_AT = 'created_at';5const UPDATED_AT = 'updated_at'; // Yes, even those names can be overridden6public $timestamps = false; // or even not used at all

And there’s even more, I’ve listed the most interesting ones, for more please check out the code of default abstract Model class and check out all the traits used.

Unlock Home Using Apple Wallet

Another useful add-on for those living in a complete Apple ecosystem. Users can now unlock home, hotel room, or even office using the stored key in the Apple Wallet app. Open the Apple Wallet app, use the stored digital key, tap the phone to the lock, and voila! The room is ready to serve you. It will be up to third-party devices and hotel chains to quickly implement the functionality.

Find multiple entries

Everyone knows the find() method, right?

1$user = User::find(1);

I’m quite surprised how few people know about that it can accept multiple IDs as an array:

1$users = User::find([1,2,3]);

WhereX

There’s an elegant way to turn this:

1$users = User::where('approved', 1)->get();

Into this:

1$users = User::whereApproved(1)->get();

Yes, you can change the name of any field and append it as a suffix to “where” and it will work by magic. Also, there are some pre-defined methods in Eloquent, related to date/time:

1User::whereDate('created_at', date('Y-m-d'));2User::whereDay('created_at', date('d'));3User::whereMonth('created_at', date('m'));4User::whereYear('created_at', date('Y'));
;