mriyadh

mriyadh

Member Since 1 Year Ago

Experience Points 270
Experience Level 1

4,730 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

16 Apr
4 months ago

mriyadh started a new conversation Lumen Post Routes Not Working On Production

Hi every 1,

I have completed my lumen api project on my local machine and its all working fine after testing all routes, push it to GitHub and clone it on my VPS install the project and add .env file , make the migration, ..etc .

Now my app doesn't accept any post request while get request run normally ?!

This is my routes :

$router->get('/', function () use ($router) {
    return 'Hello From Lumen';
});


$router->group(['prefix' => 'api'], function () use ($router) {
    $router->post('login','[email protected]');
    $router->post('signup','[email protected]');
    $router->post('verfiy','[email protected]');
    $router->post('order','[email protected]');
    
    
});

Post man request error :

MethodNotAllowedHttpException

in RoutesRequests.php line 231
at Application->handleDispatcherResponse(array(2, array('POST')))
in RoutesRequests.php line 169
at Application->Laravel\Lumen\Concerns\{closure}(object(Request))
in RoutesRequests.php line 416

I really don't know what is wrong here ? Any help will be much appreciated

10 Mar
1 year ago

mriyadh left a reply on DataBase Query : Return All Results If Field Is Null

@Snapey Again I'm sorry for not being so clear I agree with you for passing the query terms but let me explain more .

my request response is like below,

{
    "current_page": 1,
    "data": [
        {
            // array of my object
        }
    ],
    "first_page_url": "https://www.example.com/Search?page=1",
    "from": 1,
    "last_page": 3,
    "last_page_url": "https://www.example.com/Search?page=3",
    "next_page_url": "https://www.example.com/Search?page=2",
    "path": "https://www.example.com/Search",
    "per_page": 10,
    "prev_page_url": null,
    "to": 10,
    "total": 27
}

The response is already provide the next page url which I use directly to fetch the next page and so on, When i use it with simple query like,

public function list(){
        
        $car_list = Car::where([['cargage', '>', 10000]])->orderBy('updated_at','DESC')->paginate(10);
        return response()->json($car_list,200);
    }

There is no need to pass the query terms with each page but it's loosing the terms only here

public function list(Request $request){
       
   $query = Car::select('cargov', 'carname', 'carmodel');

   if($request->filled('carGov') {
       $query->where('cargov', $request->carGov);
   }

   if($request->filled('carName') {
       $query->where('carname', $request->carName);
   }

   if($request->filled('carModel') {
       $query->where('carmodel', $request->carModel)
   }

       $result = $query->orderBy('updated_at','DESC')->paginate(10);

       return response()->json($result,200);
   }

mriyadh left a reply on DataBase Query : Return All Results If Field Is Null

@Snapey Sorry for re posting but I'm facing a strange behavior with this code,

public function list(Request $request){
       
   $query = Car::select('cargov', 'carname', 'carmodel');

   if($request->filled('carGov') {
       $query->where('cargov', $request->carGov);
   }

   if($request->filled('carName') {
       $query->where('carname', $request->carName);
   }

   if($request->filled('carModel') {
       $query->where('carmodel', $request->carModel)
   }

       $result = $query->orderBy('updated_at','DESC')->paginate(10);

       return response()->json($result,200);
   }

As you can see I'm paging the result of my query ( 10 / Page ), the first page results matches the query successfully but starting from Page2 and so on the results will not match the query (exactly select all with out any conditions) ? any ideas why this is happening.

10 Feb
1 year ago

mriyadh left a reply on DataBase Query : Return All Results If Field Is Null

@Snapey Thanks man,

Its

$query = Car::select('*');

mriyadh left a reply on DataBase Query : Return All Results If Field Is Null

@Snapey How can i change below line to select all columns ? or i have to add them all

$query = Car::select('cargov', 'carname', 'carmodel');

mriyadh left a reply on DataBase Query : Return All Results If Field Is Null

but you should've assigned $car_list as you mentioned but its produce the same result ( empty list ) when car name, model is not provided. I'm testing with postman and when I don't provide carModel and return $carModel instead of car_list the result is ""

09 Feb
1 year ago

mriyadh started a new conversation DataBase Query : Return All Results If Field Is Null

With my app I have search function including 3 fields (cargov, carname, carmodel). I want my user to be able to select the fields that he wants for search so if the car name filed is not provided by the user ( null, same as for the car model filed ) the query should return all results, I tried the following and it's working only when providing all the fields but it doesn't work one is missing?

<?php 

namespace App\Http\Controllers;

use App\Car;
use Illuminate\Http\Request;
class ByNameController extends Controller
{
    
 
   public function list(Request $request){
        
        $carGov = $request->get('carGov');
        $carName = $request->get('carName');
        $carModel = $request->get('carModel');
       $car_list = Car::select('cargov', 'carname', 'carmodel');
       $car_list = is_null($carModel) ? $query : $car_list->wherecarmodel($carModel);
       $car_list = is_null($carName) ? $query : $car_list->wherecarname($carName);
       $result = $car_list->orderBy('updated_at','DESC')->paginate(10);
        return response()->json($result,200);
    }
  
}


?>
05 Jan
1 year ago

mriyadh left a reply on Lumen Updating Controller Code Not Working

Yes its updated in the editor, One more thing to mention I'm not using any browser its Mobile App API (JSON response testing with swift).

mriyadh started a new conversation Lumen Updating Controller Code Not Working

Changing my controller code is not working its keep serving the old one, i tried php artisan cache:clear and composer dump-autoload -o but i still getting the old results so how can i update my controller code ?

01 Jan
1 year ago

mriyadh left a reply on Upload Images With Lumen And Files Permissions

Its public Images not something private for the user

mriyadh started a new conversation Upload Images With Lumen And Files Permissions

Hi, I'm trying to build my own API for mobile application using Lumen and every thing is great till i came to upload images from the mobile app to my web server and save the URL in mysql database, because i'm new in the web servers world i have the following questions :

  1. (most important) lets assume my project folder named TestProject and i want to save the images under Testproject/public/Images/user_id/img.png what permissions should i use to make only the web server write the folders and images and any body else can only read the images ?

  2. Is it safe to save the images in the public folder or should i save them in the storage folder ?

Any explanation would be much appreciated