Categories
Programming Technology Web Development

Pagination in laravel relation

public function get_shop_products($shop_id)
{
$shop = Shop::query()
->where(‘id’ , $shop_id)
->first();
$shop->setRelation(‘products’ , $shop->products()->paginate(10));
return new ShopProductsResource($shop);
}

Masoud Hosseini

Categories
Linux Technology

Why my web server doesnt work ? (ubuntu)

Check 80 port on your server :

sudo netstat -tulpn | grep :80

In my case I saw my 80 port have gotten by Nginx but I want to give it to Apache so I used this command :

sudo systemctl stop nginx
sudo systemctl start apache2.service

and it worked perfectly

Categories
Programming Technology Useful Addresses Web Development

I love Frappe Framework

In this post, I want to write about a miracle in the software development world.

Imagine you can create your database entities with some clicks; you have many types of fields that are built in that software.

For a programmer who codes in pure PHP or python with a front-end framework, it takes more than 1 month to create a blog and shop website, but you can have all of that in one or two days with Frappe; Wow 🙂 What amazing!

You can read more about it on its official website: frappeframework.com

I also created a GitHub repository to keep some sample script codes that during working with frappe you probably need to use.

You can have it here (don’t forget to give it a start and communicate):

https://github.com/masoud-me/frappe-sample-scripts

Categories
devops Linux Technology

How to run our own Smart DNS to bypass geo restrictions – let’s run something like shecan.ir

The article in the link below helps in this way.

Check it out.

https://maj0rmil4d.medium.com/how-to-run-our-own-smart-dns-to-bypass-geo-restrictions-beeeab4f82d7

Categories
Programming Technology

Masoud’s notes about Golang part 4 – Golang Commands

Execute project

go run .

Create an executable file of the project (build)

go build .

Download and install external package

go get {package path}

#### eg.
go get gorm.io/gorm

Display Current GOPATH

go env GOPATH

install new go package

go install test-app

Update package

go get -u test-app

List Packages Alongside Dependencies

go list
go list ./...

Display Version Information

go version

Maintain Module Dependencies

The go mod tidy command allows us to add missing dependencies or delete unused modules. This go command helps in maintaining module dependencies and keep your applications as lean as possible. Simply run the following simple command to do this.

Make sure to run this from your project’s root directory. You can check the go.mod file to see which dependencies were added or deleted. The -v flag, if used, causes tidy to display which modules were removed to the standard error.

go mod tidy [-v]

Verify Module Dependencies

go mod verify

Display Why Packages/Modules are Needed

You can see why certain modules or packages are required in your application. This is useful if you are working with someone else’s code or are trying to figure out what certain things do in a specific project. The “why” command of the mod tool allows us to do this

The first one is the general syntax, and the second one is an example. It prints out why the language and encoding packages are required in your application.

go mod why [-m] [-vendor] packages...
go mod why golang.org/x/text/language golang.org/x/text/encoding

Categories
devops Technology

Install PHPMyAdmin on ubuntu

Categories
Linux Technology

Linux Disk became readonly

it sometimes happens because you have multiple Operating systems, for example, i have windows and Linux on my machine so I got this problem:

after you tried to mount and unmount your disk you can use the command below as super admin:

sudo fsck -f /dev/sdxx

sdxx is the name of your disk, you can get disk names by command below :

sudo mount
Categories
Data Structure Technology

Data structure – part 1

Contents

  • Big-o

Reference

Categories
devops Linux Technology

Apache configuration manual

How to install apache on ubuntu:

let’s write a more friendly than an official apache document :

it’s simple, just follow steps below (Debian bases distributes):

  1. go to path : /etc/apache2/sites-available/
cd /etc/apache2/sites-available/

2. make a copy of the default configuration file (000-default.conf).

for every domain or subdomain that is assigned to this server IP address you need to make a copy of the default file and edit it as I explained in continue:

sudo cp 000-default.conf masoud.me.conf

3 . open the file that you created :

sudo nano masoud.me.conf

change documentRoot to the path you want to load you project

and change serverName to URL that is pointing to this file

4 . save and exit

4.5 . test your changes and be sure that your changes wont make down all apache sites :

sudo apachectl configtest

5 . now you need to add it to sites-enabled

for this you need to execute the command below :

sudo a2ensite masoud.me.conf

6 . important part is to disable the default file :

sudo a2dissite 000-default.conf

7. now you need to reset or reload apache :

service apache2 reload

Reference :

https://ubuntu.com/tutorials/install-and-configure-apache#2-installing-apache
Categories
Git Technology

how to edit last commit message

Type git commit –amend and press Enter.

git commit --amend
reference:

https://github.com/git-tips/tips