eloquent query scope

Defining A Query Scope


class User extends Eloquent {

    public function scopePopular($query)
    {
        return $query->where('votes', '>', 100);
    }

    public function scopeWomen($query, $gender)
    {
        return $query->whereGender($gender);
    }

}

Utilizing A Query Scope

$users = User::popular()->women($gender)->orderBy('created_at')->get();

permissions

To recursively give directories read&execute privileges:

find /path/to/base/dir -type d -exec chmod 755 {} +

To recursively give files read privileges:

find /path/to/base/dir -type f -exec chmod 644 {} +

Or, if there are many objects to process:

chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)

Or, to reduce chmod spawning:

find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644

permissions

 

1. All directories should be 755 or 750
2. All files should be 644 or 640. Exception: wp-config.php should be 440 or 400 to prevent other users on the server from reading it.
3. No directories should ever be given 777, even upload directories. Since the php process is running as the owner of the files, it gets the owners permissions and can write to even a 755 directory.
4. If you use Permalinks you should also change permissions of .htaccess to make sure that WordPress can update it when you change settings such as adding a new page, redirect, category, etc.. which requires updating the .htaccess file when mod_rewrite Permalinks are being used.
chmod 755 -R wordpress
chmod 440 wp-config.php
chmod -v 666 .htaccess
https://wordpress.org/support/article/changing-file-permissions/

https://stackoverflow.com/questions/18817744/change-all-files-and-folders-permissions-of-a-directory-to-644-755

laravel dusk

works on windows (atkrp demesi i: chromedriver)
composer require --dev laravel/dusk:"^5.4"

composer require --dev laravel/dusk - latest version
it needs pcntl (dont work on windows)

chromedriver
https://github.com/laravel/dusk/issues/490
https://chromedriver.storage.googleapis.com/index.html?path=2.36/

download chromedriver and put in directory: vendor/laravel/dusk/bin
Managing ChromeDriver Installations
php artisan dusk:chrome-driver --all

https://laravel.com/docs/6.x/dusk

get wifi-password

1. Network & Internet settings -> Status -> Network and Sharing Center
2. Wi-Fi (YOUR-NAME) -> Wirelless Properties -> Security -> Show Characters

 

model read-only

1. You can setup global listener for all the models:

Event::listen('eloquent.saving: *', function ($model) {
  return false;
});
2. Or for given model:

Event::listen('eloquent.saving: User', function ($user) {
  return false;
});
// or
User::saving(function ($user) {
  return false;
});

// If it's not global, but for single model, then I would place it in boot():
// SomeModel
public static function boot()
{
   parent::boot();

   static::saving(function ($someModel) {
      return false;
   });
}
3. For read-only model you need just one saving event listener returning false, then all: Model::create, $model->save(), $model->update() will be rejected.
4. Here's the list of all Eloquent events: booting, booted, creating, created, saving, saved, updating, updated, deleting, deleted and also restoring and restored provided by SoftDeletingTrait.
https://stackoverflow.com/questions/28203317/prevent-certain-crud-operations-on-laravel-eloquent-models