mehmetanbaki

mehmetanbaki

Full Stack Developer at Iraq, Baghdad

Member Since 11 Months Ago

Toronto

Experience Points
50,690
Total
Experience

4,310 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
404
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 11
50,690 XP
Oct
20
1 week ago
Activity icon

Replied to Laravel And Vuejs Deployment

yep they are the same, linux server.

Activity icon

Started a new Conversation Laravel And Vuejs Deployment

I've created Laravel application as API backend And Vuejs as Frontend and i want to deploy both of them to online server, what is the best way to do this? is it possible to put laravel backend files inside a folder with front file in the same public_html folder.

Jun
12
4 months ago
Activity icon

Started a new Conversation Hayder Hamza

i'm send user info inside token what's a problem in this

May
15
5 months ago
Activity icon

Started a new Conversation JWT AuthController

<?php

namespace App\Http\Controllers;

use JWTAuth;
use App\Core\Helpers\Utilities;
use App\Http\Controllers\Controller;
use App\Core\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AuthController extends Controller
{
    /**
     * Create a new AuthController instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth:api', ['except' => ['login']]);
    }

    /**
     * Get a JWT token via given credentials.
     *
     * @param  \Illuminate\Http\Request  $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function login(Request $request)
    {
        $credentials = $request->only('phone', 'password');

        if ($token = JWTAuth::attempt( $credentials) ) {
            return $this->respondWithToken($token);
        }
        return Utilities::wrapStatus(['error' => 'Unauthorized'], 401);
    }

    /**
     * Log the user out (Invalidate the token)
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function logout()
    {
        $this->guard()->logout();

        return Utilities::wrap(['message' => 'Successfully logged out']);
    }

    /**
     * Get the token array structure.
     *
     * @param  string $token
     *
     * @return \Illuminate\Http\JsonResponse
     */
    protected function respondWithToken($token)
    {
        return Utilities::wrap([
            'access_token' => $token,
            'token_type' => 'bearer',
            'expires_in' => $this->guard()->factory()->getTTL() * 60
        ]);
    }

    /**
     * Get the guard to be used during authentication.
     *
     * @return \Illuminate\Contracts\Auth\Guard
     */
    public function guard()
    {
        return Auth::guard();
    }
}

this is my authcontroller above I have error with it's keep giving me unauthorized and I don't know why

May
14
5 months ago
Activity icon

Started a new Conversation OTP

I have this code but it won't create otp

    public function sendOtp(){

        $codeCache = Cache::get('key');
        if($codeCache != $code){
           return "Please Enter The Correct Code " . $type;
        }
        $credentials;
       $user = User::where('phone', '=', $credentials)->first();
       if (!$user) {
           return response()->json(['error' => 'Please enter the correct code'], 401);
       }

       if (! $token = JWTAuth::fromUser($user)) {
           return response()->json(['error' => 'Unauthorized'], 401);
       }
       $user->details = "";
       $user->save();
       return $this->respondWithToken($token);

    }

    public function otp(Request $request)
    {

        $rand = rand(100000,999999) . rand(100000,999999);
        $second = now()->addMinutes(1);
        $code = rand();
        $value = Cache::put("key",$rand, $second);
        $phone = $request->phone;
        $cell = 964 . substr($phone,1);

        $user->details = $rand;
        $user->save();
        $client = new Client();
        return $response = $client->post('http://sms-gw.net:81/v2/api/Gateway/SendMessage' , [
            'headers' => [
                'Authorization' => 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjE2ZGMwNmEyLThkYWQtNDcyYy1hNDBhLWY3YmQwYWVhZDAxNyIsImVtYWlsIjoiZW5qYXpAc21zLWd3Lm5ldCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJFTkpBWiIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkN1c3RvbWVyIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwOS8wOS9pZGVudGl0eS9jbGFpbXMvYWN0b3IiOiIyIiwianRpIjoiODQ0MzM3NzAtM2VlMS00NjY3LTg4ODktMDBjOWZhNDdmNDRkIiwibmJmIjoxNTc2NTk0OTAwLCJleHAiOjE2MDgyMTczMDAsImlzcyI6Iklzc3VlciIsImF1ZCI6IkF1ZGllbmNlIn0.xh9avMxWnwHH-uh1QPjLij5CWW5p5fF3ENz4A0xjHb4',
                'Content-Type' => 'application/json'
            ],
            'json' => [
            'number' => $mobile,
            'text' => 'Insert This Code ' . $rand . ' I think this otp is done 0_*',
            'messageType' => 3,
            'sentThrough' => 1
            ]
        ]);
        return response()->json(['success'=>$user->phone], 200);

    }

May
12
5 months ago
Activity icon

Started a new Conversation JWT And OTP

I need to use JWT with OTP is there any package for this or should I create by my own ??

Activity icon

Replied to Middleware

@michaloravec

I use it and working with it a lot but this time I want to create my own package I want to add otp with it and make it customize

Activity icon

Replied to Middleware

@michaloravec

which means I can do it

Activity icon

Started a new Conversation Middleware

Can I build multi-auth with single middleware and using conditions to specific every single role in it ??

And to be specific I want to make one middleware call it authmiddleware and in that middleware I'll put all the roles for authentication is there any problem with that ???

May
06
5 months ago
Activity icon

Started a new Conversation JWT Bugs

I have this code in AuthController;

<?php

namespace App\Http\Controllers;

use JWTAuth;
use App\Core\Models\User;
use Illuminate\Http\Request;
use Tymon\JWTAuth\Exceptions\JWTException;

class AuthController extends Controller
{
    public $loginAfterSignUp = true;

    public function login(Request $request)
    {
        $credentials = $request->only("phone", "password");
        $token = null;

        if (!$token = JWTAuth::attempt($credentials)) {
            return response()->json([
                "status" => false,
                "message" => "Unauthorized"
            ]);
        }

        return response()->json([
            "status" => true,
            "token" => $token
        ]);
    }

    public function register(Request $request)
    {
        $this->validate($request, [
            "name" => "required|string",
            "phone" => "required|unique:user",
            "password" => "required|min:6|max:10"
        ]);

        $user = new User();
        $user->name = $request->name;
        $user->phone = $request->phone;
        $user->password = bcrypt($request->password);
        $user->save();

        if ($this->loginAfterSignUp) {
            return $this->login($request);
        }

        return response()->json([
            "status" => true,
            "user" => $user
        ]);
    }

    public function logout(Request $request)
    {
        $this->validate($request, [
            "token" => "required"
        ]);

        try {
            JWTAuth::invalidate($request->token);

            return response()->json([
                "status" => true,
                "message" => "User logged out successfully"
            ]);
        } catch (JWTException $exception) {
            return response()->json([
                "status" => false,
                "message" => "Ops, the user can not be logged out"
            ]);
        }
    }
}


it keep giving me this error:

{
    "status": false,
    "message": "Unauthorized"
}

May
02
5 months ago
Activity icon

Replied to JWT

@xinecraft

I don't wanna save in the database

Activity icon

Started a new Conversation JWT

Hey Laravelers

I need to create JWT to my application web in Laravel 7 how is that

Apr
29
6 months ago
Activity icon

Started a new Conversation Input Sanitization

how to sanitize user input ($request data), to prevent xss attack??