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 Linux Shell Technology

Linux Vim commands

quit of editor without saving
:q!
Categories
Best practice devops Programming Technology Web Development

Implement Rest APIs more efficient

Most web applications are implemented based on Rest Full APIs and as I researched huge part of them are not implemented based on best practices and clean code principles, so I decided to collect some points in a couple of posts to help make them more efficient APIs and Applications.

Let’s Look at other kinds of APIs

you can easily research and find out more about all of these kine of API design methodologies but here I’m going to just collect best part of them to create a document to implement Rest API in best practice.

Graphql

the best part of graphql is that you can design your API for the front end to just get whatever need, not more.

it can bring us better speed because less amount of packets is transferring over the network.

gRPC

Socket