xxxxxxxxxx
use Illuminate\Support\Facades\DB;
$users = DB::table('users')
->join('contacts', 'users.id', '=', 'contacts.user_id')
->join('orders', 'users.id', '=', 'orders.user_id')
->select('users.*', 'contacts.phone', 'orders.price')
->get();
xxxxxxxxxx
use Illuminate\Support\Facades\DB;
//in the following example we will join two tables
//a products table and categories table
$categoryProducts = Product::join('categories', 'categories.id', '=', 'products.category_id')
->select('products.*', 'categories.category_name')
->where('products.status', 1)
->get();
xxxxxxxxxx
$users = User::join('posts', 'posts.user_id', '=', 'users.id')
->where('users.status', 'active')
->where('posts.status','active')
->get(['users.*', 'posts.descrption']);
xxxxxxxxxx
import { CustomSession } from '@/types/auth';
import axios, { AxiosInstance } from 'axios'
import { getSession } from 'next-auth/react'
import { getValidAccessToken } from '../auth';
// Async function to initialize the Axios instance with the session token
export const createApiClient = async (): Promise<AxiosInstance> => {
const apiClient = axios.create({
baseURL: process.env.NEXT_PUBLIC_BACKEND_URL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
// Add a request interceptor
apiClient.interceptors.request.use(
async (config) => {
const session = await getSession();
const customSession = session as CustomSession | null;
// Get valid access token
if (customSession) {
const accessToken = await getValidAccessToken(customSession);
if (accessToken) {
config.headers['Authorization'] = `${accessToken}`;
}
}
return config;
},
(error) => {
return Promise.reject(error);
}
);
return apiClient;
};
//calls
const apiClient = await createApiClient();
const response = await apiClient.post(
xxxxxxxxxx
with open("tmob_notcleaned.csv", "rb") as infile, open("tmob_cleaned.csv", "wb") as outfile:
reader = csv.reader(infile)
next(reader, None) # skip the headers