muazzamazaz

muazzamazaz

Member Since 2 Years Ago

Experience Points
3,370
Total
Experience

1,630 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.

Level 1
3,370 XP
Nov
19
1 month ago
Activity icon

Replied to Count(): Parameter Must Be An Array Or An Object That Implements Countable

use App\Promocode;
use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use App\Http\Controllers\Controller;
use DB;
class PromocodeResource extends Controller

Activity icon

Replied to Count(): Parameter Must Be An Array Or An Object That Implements Countable

when I use another query like $promocodes = DB::table('promocodes')->get(); it works.

Activity icon

Replied to Count(): Parameter Must Be An Array Or An Object That Implements Countable

$promocodes = Promocode::orderBy('created_at' , 'desc')->get();

Activity icon

Started a new Conversation Count(): Parameter Must Be An Array Or An Object That Implements Countable

I am using Laravel 5.3 and PHP 7.3, when I do eloquent queries and use get() method it give me above error, I can't upgrade laravel as its running app.

Nov
06
2 months ago
Activity icon

Started a new Conversation Migration Error On Maria Db Xamp

Getting error on migration:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i n your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json null, remember_token varc har(100) null, created_at timestamp null, upd' at line 1 (SQL: create ta bleusers(idint unsigned not null auto_increment primary key,nickna mevarchar(255) not null,emailvarchar(255) not null,passwordvarcha r(60) not null,pic_urlvarchar(255) null,languagevarchar(255) not nu ll default 'en',mobile_phonevarchar(255) null,work_phonevarchar(255 ) null,websitevarchar(255) null,twittervarchar(255) null,facebookvarchar(255) null,descriptionvarchar(255) null,time_zonevarchar(255) null,rate_valint null,rate_countint null,roleenum('admin','business', 'nonprofit', 'person') not null default 'person',typeenum(' normal', 'trusted') not null default 'normal',verifiedenum('yes', 'no') not null default 'no',preferencesjson null,remember_token` varchar(1

  1. null, created_at timestamp null, updated_at timestamp null, disabl ed_at timestamp null, deleted_at timestamp null) default character set u tf8 collate utf8_unicode_ci engine = InnoDB)

where web server is:

Database server
Server: 127.0.0.1 via TCP/IP
Server type: MariaDB
Server version: 10.1.10-MariaDB-log - mariadb.org binary distribution
Protocol version: 10
User: [email protected]
Server charset: UTF-8 Unicode (utf8)
Web server
Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.2
Database client version: libmysql - mysqlnd 5.0.12-dev - 20150407 - $Id: 7e72f9690b1498a1bead7a637c33a831c0d2f655 $
PHP extension: mysqli Documentation
PHP version: 7.0.2

Schema :

Schema::create('users', function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->increments('id');
            $table->string('nickname')->unique();
            $table->string('email')->unique();
            $table->string('password', 60);
            $table->string('pic_url')->nullable();
            $table->string('language')->default('en');
            $table->string('mobile_phone')->nullable();
            $table->string('work_phone')->nullable();
            $table->string('website')->nullable();
            $table->string('twitter')->nullable();
            $table->string('facebook')->nullable();
            $table->string('description')->nullable();
            $table->string('time_zone')->nullable();
            $table->integer('rate_val')->nullable();
            $table->integer('rate_count')->nullable();
            $table->enum('role', array_keys(trans('globals.roles')))->default('person');
            $table->enum('type', array_keys(trans('globals.type_user')))->default('normal');
            $table->enum('verified', array_keys(trans('globals.verification')))->default('no');
            $table->json('preferences')->nullable();
            $table->rememberToken();
            $table->timestamps();
            $table->timestamp('disabled_at')->nullable();
            $table->softDeletes();
        });
Nov
02
2 months ago
Activity icon

Replied to Unauthorized Error For Api Call

I have to fix issues in existing code so want to use iwt and using header Accep and authorization bearer token

Activity icon

Started a new Conversation Unauthorized Error For Api Call

I am doing login via mobile and generate token like:

{
    "token_type": "Bearer",
    "expires_in": 2255555,
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjQwLCJpc3MiOiJodHRwOi8vbXljbGllbnR3b3JrLndlYnNpdGUvdHJhbnhpdF9zY2hlZHVsZS9wdWJsaWMvYXBpL3VzZXIvbG9naW4iLCJpYXQiOjE1NzI2OTM4MzUsImV4cCI6MTU3MzA1MzgzNSwibmJmIjoxNTcyNjkzODM1LCJqdGkiOiIwdHdrZHFwNHNzcXVRM0FZIn0.Jez-RqV1AXgaApGYQNRJorsW9XiYuX63hWJddLsppVk",
    "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjQwLCJpc3MiOiJodHRwOi8vbXljbGllbnR3b3JrLndlYnNpdGUvdHJhbnhpdF9zY2hlZHVsZS9wdWJsaWMvYXBpL3VzZXIvbG9naW4iLCJpYXQiOjE1NzI2OTM4MzYsImV4cCI6MTU3MzA1MzgzNiwibmJmIjoxNTcyNjkzODM2LCJqdGkiOiJJbDk1V2g3WHRhWHM0SDMxIn0.uDoMAIj33ldKT93jnRbr8Wc3kYAdfG0AV24ka9R5k68"
}

but it does not being authorized for further processing of application and give me

Unauthorized error for other api requests.

I am using route middleware `auth:api'

and inside kernal.php, I have

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'account' => \App\Http\Middleware\RedirectIfNotAccount::class,
        'account.guest' => \App\Http\Middleware\RedirectIfAccount::class,
        'fleet' => \App\Http\Middleware\RedirectIfNotFleet::class,
        'fleet.guest' => \App\Http\Middleware\RedirectIfFleet::class,
        'dispatcher' => \App\Http\Middleware\RedirectIfNotDispatcher::class,
        'dispatcher.guest' => \App\Http\Middleware\RedirectIfDispatcher::class,
        'provider' => \App\Http\Middleware\RedirectIfNotProvider::class,
        'provider.guest' => \App\Http\Middleware\RedirectIfProvider::class,
        'provider.api' => \App\Http\Middleware\ProviderApiMiddleware::class,
        'admin' => \App\Http\Middleware\RedirectIfNotAdmin::class,
        'admin.guest' => \App\Http\Middleware\RedirectIfAdmin::class,
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'jwt.auth' => 'Tymon\JWTAuth\Middleware\GetUserFromToken',
        'jwt.refresh' => 'Tymon\JWTAuth\Middleware\RefreshToken',
        'demo' => \App\Http\Middleware\DemoModeMiddleware::class,
    ];

controller:

public function login(Request $request){
            
        if (isset($request->email))
        {

        $credentials = $request->only('email', 'password');
        
         try {
            if (! $token = JWTAuth::attempt($credentials)) {
            
                return response()->json(['error' => 'The email address or password you entered is incorrect.'], 401);
            }
        } catch (JWTException $e) {
            return response()->json(['error' => 'Something went wrong, Please try again later!'], 500);
        }
        
$refresh_token=$this->refresh_token($request);

        }
else{
    
    $token=$request->refresh_token;
    
$refresh_token = JWTAuth::refresh($request->refresh_token);

        
        
}

return response()->json(["token_type" => "Bearer",'expires_in' => 2255555,'access_token' => $token, 'refresh_token'=>$refresh_token]);

       
   }


public function refresh_token(Request $request)
    {

  $credentials = $request->only('email', 'password');
        
         try {
            if (! $token = JWTAuth::attempt($credentials)) {
                
                return 'The email address or password you entered is incorrect.';
            }
        } catch (JWTException $e) {
            return 'Something went wrong, Please try again later!';
        }
        return $token;
    }
Activity icon

Replied to User Auth From Mobile App

The route is guarded by middleware auth:api

Activity icon

Started a new Conversation User Auth From Mobile App

How I can get user id to update user profile through mobile app using

Auth::user()->id

Currently its giving null while I put at top: use Auth;

    public function update_location(Request $request){

        $this->validate($request, [
                'latitude' => 'required|numeric',
                'longitude' => 'required|numeric',
            ]);

        if($user = User::find(Auth::user()->id)){

            $user->latitude = $request->latitude;
            $user->longitude = $request->longitude;
            $user->save();

            return response()->json(['message' => trans('api.user.location_updated')]);

        }else{

            return response()->json(['error' => trans('api.user.user_not_found')], 500);

        }

    }
Oct
20
2 months ago
Activity icon

Replied to Read Json In Ajax - Undefined

result.name gives undefined

Activity icon

Replied to Read Json In Ajax - Undefined

console.log(result); results in [{"name":"tests","governorate":"Trento, Province of Trento, Italy"}]

Activity icon

Replied to Read Json In Ajax - Undefined

function fetch_d(Request $request)
    {
 
  $d_id = $request->get('destination_id');

$dest = Destination::join('governorates','Destinations.governorate_id','=','governorates.id')->select('name','governorate')   
    ->get();


echo $dest;
    }
Oct
19
3 months ago
Activity icon

Started a new Conversation Read Json In Ajax - Undefined

I am getting following json data in ajax from laravel controller

[{"name":"tests","governorate":"Trento, Province of Trento, Italy"}]

When I read it through

success:function(result)
    {
alert(result.name);
    },

it gives

Undefined.

Oct
16
3 months ago
Activity icon

Started a new Conversation Laravel Route Not Found Using Ajax

Under view I have named view as:

 <script>
    var config = {
        routes: {
            add_plan: "{{ URL::to('destinations.fetch_d') }}"
        }
    };
</script>

Inside web:

Route::post('destinations/fetch_d', '[email protected]_d')->name('destinations.fetch_d');

Inside controller:

 function fetch_d(Request $request)
    {

echo 'test';
    }

Inside custom.js file using Ajax:

$.ajax({
  headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          },
          cache: false,
    url:config.routes.add_plan,
    type: "POST",
    data:id:1,
    success:function(result)
    {
    alert(result);
    },
    error: function(req, textStatus, errorThrown) {
        //this is going to happen when you send something different from a 200 OK HTTP
        alert('Error: ' + textStatus + ' ' +errorThrown);
    }

   });

It gives error

Route Not found under developer console with URL: http://localhost:8000/destinations.fetch_d