Category : restapi

We Have a Mobile App Rest API that has more than 70 routes and 12 controllers and folders structure look like, /app /Http /Controllers /Api /v1 /UserController.php /…other 11 controllers /v2 And routes : $router->group([‘prefix’ => ‘Api/V1’], function () use ($router) { $router->post(‘SignIn’,’[email protected]’); $router->post(‘Verify’,’[email protected]’); ….. other routes }); After 8 months we need now to ..

Read more

Even if the data is correct in my database, even if I delete it in the admin, they all work. Likewise Even if I give superadmin other privileges, none of them work.How should i go about my AuthController: public function register(AuthReqisterRequest $request) { DB::transaction(function () use($request){ $user=User::create($request->except(‘role’)); $user->attachRole($request[‘role’]); //$user->attachPermissions($request[‘permission’]); }); return $this->respondWithToken(auth()->attempt(request([’email’, ‘password’]))); } my ..

Read more

I want to set many to many relation between category and product and make product category api. my product model: class Product extends Model { use HasFactory; protected $fillable=[‘name’,’desc’,’price’]; public function categories(){ return $this->belongsToMany(Category::class, ‘product_categories’); } } my category model: class Category extends Model { use HasFactory; protected $fillable=[‘name’,’desc’]; public function products(){ return $this->belongsToMany(Product::class , ..

Read more

I’m creating a rest api that would handle post requests. It’s so far successful apart from the fact that it only adds the ID to the table, whereas it should be incrementing the ID, adding the oid,name and comment to the table in the database. Here is my code: <?php header("Content-Type:application/json"); header("Access-Control-Allow-Methods: GET, POST"); include(‘connection.php’); ..

Read more