Skip to content

Instantly share code, notes, and snippets.

@huzaifa-a
huzaifa-a / tar.md
Created April 27, 2023 16:15
extract tar file
tar -xvf app.tar.xz 
@huzaifa-a
huzaifa-a / nginx.md
Last active November 6, 2022 18:18
Nginx localdevelopment with laravel
sudo apt-get install nginx

Enable php and update root path in default config file

sudo apt-get install nginx
cd /etc/nginx/sites-available
@huzaifa-a
huzaifa-a / permissions.md
Created April 26, 2022 10:48
run php artisan as www-data

Run php artisan as www-data

sudo -u www-data php artisan queue:work
@huzaifa-a
huzaifa-a / setup.md
Last active February 16, 2022 13:17
initial setup

install laravel/ui

composer require laravel/ui
php artisan ui bootstrap --auth
php artisan migrate

disable registration

Auth::routes(['register' => false]);
@huzaifa-a
huzaifa-a / logs-permission.md
Last active October 22, 2021 16:49
Fix logs permission issue

add 'permission' => 0664 in the driver

'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
            'permission' => 0664,
        ],
@huzaifa-a
huzaifa-a / googlemaps.md
Created August 21, 2021 10:16
get coordinates from address
public function validate_address(Request $request)
    {
        $this->validate($request, [
            'address' => 'required',
        ]);


 try {
@huzaifa-a
huzaifa-a / compress.md
Last active July 6, 2021 08:37
Compress files on current directory

To tar and gzip a folder, the syntax is:

tar czf name_of_archive_file.tar.gz name_of_directory_to_tar

The - with czf is optional.

If you want to tar the current directory, use . to designate that.

To construct filenames dynamically, use the date utility (look at its man page for the available format options). For example:

@huzaifa-a
huzaifa-a / alias.md
Last active March 10, 2021 07:42
Windows CMD alias
doskey pa=php artisan
@huzaifa-a
huzaifa-a / binding.md
Last active January 15, 2021 09:24
Resolve model binding

add in model

public function resolveRouteBinding($value, $field = null)
{
    if (auth()->check()){
        if (!Auth::user()->is_admin()) {
            return $this->where('user_id', Auth::id())->where($field ?? $this->getRouteKeyName(), $value)->first();
        }
    }
@huzaifa-a
huzaifa-a / comopserinstall.md
Last active January 27, 2021 14:10
composer install with php memory limit

we can get the composer path from composer help command

 php -d memory_limit=-1 /usr/sbin/composer install  --no-interaction --prefer-dist --optimize-autoloader