Skip to content

Instantly share code, notes, and snippets.

View AzadGh95's full-sized avatar
😃
Programming is fun ... at least useful.

Azade Ghasemi AzadGh95

😃
Programming is fun ... at least useful.
View GitHub Profile
@AzadGh95
AzadGh95 / merge-paginated.md
Created July 3, 2023 18:16
To merge two paginated collections

The paginate() method is not available directly on the Illuminate\Database\Eloquent\Collection class. Instead, it is a method provided by the query builder (Illuminate\Database\Eloquent\Builder) or the model itself (Illuminate\Database\Eloquent\Model).

To merge two paginated collections and paginate the result, you can take a different approach:

use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;

$collection1 = Model1::paginate($perPage);
$collection2 = Model2::paginate($perPage);
@AzadGh95
AzadGh95 / how-to-use-sqlite.md
Created December 1, 2022 08:54
Best database when you are developing your laravel project.

I wanna have a stable database so I'd rather using sqlite instead other database when I'm developing my Laravel project.

Step 1: change these line in .env

DB_CONNECTION=sqlite
# DB_HOST=pgsql
# DB_PORT=5432
# DB_DATABASE=example
# DB_USERNAME=sail
@AzadGh95
AzadGh95 / how-to-run-serve.md
Last active November 30, 2022 06:56
How to run laravel project on Ubuntu 22.04

Install php: resource

sudo apt update && sudo apt -y upgrade
sudo systemctl reboot
sudo apt update
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.1
@AzadGh95
AzadGh95 / all-asserts-in-laravel-shift.txt
Last active November 2, 2022 08:28
all asserts in laravel shift
$response->assertOk();
$response->assertRedirect(back());
$this->assertModelMissing($user);
$responce->assertJsonStructure([]);
$responce->assertTrue();
@AzadGh95
AzadGh95 / git-fix-problem.md
Last active October 26, 2022 11:15
OpenSSL SSL_connect: Connection reset by peer in connection to api.github.com:443

If you encounter one of the problems in git on your system(ubuntu) : fatal: unable to access ‘xxx‘: gnutls_handshake() failed: Error in the pull function. or OpenSSL SSL_connect: Connection reset by peer in connection to api.github.com:443 you can use these steps and solve your problem:

  1. create a new rsa key in your system in first step you should create a new ssh key: $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
@AzadGh95
AzadGh95 / push.php
Created February 23, 2022 11:53
push data in array in laravel for loop
$fileNames = array();
foreach ($attachments as $file) {
$fileNames[] = $file->name;
}
@AzadGh95
AzadGh95 / import-sql-file-to-docker-mysql.sh
Created September 7, 2021 10:48
Import SQL file to docker MySQL
docker exec -i site_mysql_1 mysql -u root -p secret --init-command="set autocommit=0" dbname < ~/sample.sql