cent040

Member Since 3 Years Ago

Lahore, Pakistan

Web Programmer at Lahore, Pakistan

Experience Points 14,920
Experience Level 3

80 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 102
Lessons
Completed
Best Reply Awards 3
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.

23 Jan
1 year ago

cent040 left a reply on Run A Method Of Controller With Cron And Scheduling Closures

Thanks @Snapey

It's work for me on Laravel5.5

04 Oct
1 year ago

cent040 left a reply on Method Attempt Does Not Exist Or Auth Guard Driver [api] Is Not Defined.

use check() instead of attempt. It's work for me

if (Auth::check(['email' => $email, 'password' => $password,false, false])) {
        $user = Auth::user();
        $data = array(
        "is_login" => true,
        "name" => $user->name,
        "api_token" => $user->api_token
        );
        return Response::json(
            array(
            'status' => true,
            'data' => $data,
            'msg' => "Login Successfully"
            ), 200
        );
    }

cent040 left a reply on Laravel 5.4 Web Api For Authentication

use check() instead of attempt. It's work for me

if (Auth::check(['email' => $email, 'password' => $password,false, false])) {
        $user = Auth::user();
        $data = array(
        "is_login" => true,
        "name" => $user->name,
        "api_token" => $user->api_token
        );
        return Response::json(
            array(
            'status' => true,
            'data' => $data,
            'msg' => "Login Successfully"
            ), 200
        );
    }
16 Aug
2 years ago

cent040 left a reply on Image Crop Package For Laravel

hi here is the complete tutorial with html, js and laravel intervention image http://howsolve.com/image-crop-with-laravel54-intervention-and-cropperjs-jquery/

17 May
2 years ago

cent040 left a reply on Markdown And Inline Attachments

Same issue, still haven't found a fix. Any update?

15 May
2 years ago

cent040 started a new conversation Laravel Echo.join Working Only Echo.channel And Echo.private Not Working

I am using laravel 5.4 and pusher for event broadcasting. I create a private channel "chatroom".

Echo.join('chatroom')  /// Work Well 
   .listen('MessagePosted', (e) => {
           this.messages.push({
           body: e.message.body
       });
});

But this is not working with Channel and Private...

 Echo.channel('chatroom')   OR 
 Echo.private('chatroom')   //// Not Working 

Getting following error enter image description here

cent040 left a reply on Pusher : Couldn't Get Auth Info From Your Webapp : 403

I solve it by creating channel route.

Create your Authorizing Channels in routes->channels.php

Broadcast::channel('chatroom', function ($user) {
    return $user;
});

See Documentation : https://laravel.com/docs/5.4/broadcasting#authorizing-channels

thanks

cent040 left a reply on Broadcasting/auth 403 (Forbidden) In Laravel Echo

Create your Authorizing Channels in routes->channels.php

Broadcast::channel('chatroom', function ($user) {
    return $user;
});

https://laravel.com/docs/5.4/broadcasting#authorizing-channels

thanks

12 May
2 years ago

cent040 started a new conversation Uncaught ReferenceError: Module Is Not Defined At Echo.js:768

I'm making a simple chat application, I get this error while connecting to pusher, I'm using laravel 5.4. I am getting error.

Uncaught ReferenceError: module is not defined at echo.js:768

TypeError: Echo.join is not a function

Every thing is working fine like pusher and database etc. Due to this error i did not get response

Here is code

Echo.join('chatroom').
.listen('MessagePosted', (e) => {
     console.log(e)
});
10 May
2 years ago

cent040 left a reply on Laravel's GroupBy() Not Working

Go to your config/database.php folder. In mysql configuration array, change strict => true to strict => false, and everything will work nicely.

07 Feb
2 years ago

cent040 left a reply on Php Artisan Serve Without How To Start Project

@Cutie2596 : On localhost you can run with 2 ways

1 : http://localhost/projectname/public

2 : Run git bash

php artisan serve

if will give you a link like this : http://localhost:8000

Regards Arfan

01 Feb
2 years ago

cent040 left a reply on Remove Public/index.php From URL

Here is complete .htaccess file

 <IfModule mod_rewrite.c>
   <IfModule mod_negotiation.c>
        Options -MultiViews
   </IfModule>

RewriteEngine On
RewriteBase /your-folder-name/
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

cent040 left a reply on How To Upgrade Laravel From Version 5.1 To 5.3

1 : Install fresh laravel 5.3 2: move your controllers and view in related folders 3: copy all routes.php data to reutes/web.php

It's more then easy to this https://laravel.com/docs/5.3/upgrade

Regards Arfan

30 Jan
2 years ago

cent040 left a reply on I Want To Upload File Form Local Path To Server.

Yes Thanks @Snapey . It's exactly same error. File could not be opened. Server does now know about file.

@barbarouspony . Yes using sftp/scp it's working fine.

Thanks to both of you.

28 Jan
2 years ago

cent040 left a reply on I Want To Upload File Form Local Path To Server.

Hi, @Snapey. thanks for help. But I don't want input type="file".. I want type="text" i will give path. like D:/files/file.zip. I want this becuase i am writing APIs that will take file form folder and upload on server every day.

cent040 started a new conversation I Want To Upload File Form Local Path To Server.

Hi, I want to upload file from local to Server in PHP i.e A page have text box i will give local file path on textbox. TextBox input like : D:/files/test.zip

27 Jan
2 years ago

cent040 left a reply on SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'Date' In 'field List'

@jhansi are you still getting the issue after adding. ?

@Sirik If this is not a good idea. What's good please wrote here..

Regards Arfan

cent040 left a reply on SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'Date' In 'field List'

In Model User.php

 protected $fillable = [
          'first_name', 'email', 'password','Date',
 ];

Add Date in fillable in User Model

Regards Arfan

26 Jan
2 years ago

cent040 left a reply on Batch Insert In Laravel 5.2

Here i got answer Use insert() method for bulk insertion. First, build an array with this structure:

$data = [
  ['name' => 'John', 'age' => 25],
  ['name' => 'Maria', 'age' => 31],
  ['name' => 'Julia', 'age' => 55],
];

Then insert the data using Eloquent model:

Model::insert($data);

Or using query builder:

DB::table('table_name')->insert($data);

cent040 started a new conversation Batch Insert In Laravel 5.2

I am using a API's with lot's of calculation almost 100 database fields at the end with a big Foreach loop.

In every iteration i insert data in database. I want to insert data in once at the end (Batch Insert like in CodeIgniter).

Any body have idea how to insert all data at the end of iteration. instead of every iteration it insert row in database.

I want to insert data at the end of loop. Any help or idea appreciated.

20 Jan
2 years ago

cent040 left a reply on JSON Column

I think you must use varchar or text for that . json data type is in latest version. It's may not available on many hosting servers yet.

cent040 left a reply on Users List From Database Using Query Builder

@mturner20 As WebDo said Its designing task. Have you any idea of html/css ? you need to know css for design.

cent040 left a reply on JSON Column

Yes simple create a VARCHAR or TEXT field. And you can store json_encode data easily.

$json_data = json_encode("your data");

When you get data form database you can use json_decode

$data = json_decode("$databasae_field");

regards Arfan

18 Jan
2 years ago

cent040 left a reply on Users List From Database Using Query Builder

   <h1>List of All Users</h1>

 <table width="50%">
  <tr> 
    <td> Name </td>
  </tr> 
@forelse($users as $user)
<tr>
         <td>{{ $user->name }}</td>
 </tr>
    @empty
 </table>

That's it

Regards Arfan

12 Jan
2 years ago

cent040 left a reply on Laravel 5 Authentication

Use this library its best library for user roles and permissions https://github.com/Zizaco/entrust

09 Jan
2 years ago

cent040 left a reply on SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'user_id' In 'where Clause'

If your user_id is primary key change it in Model. protected $primaryKey = 'user_id';

if not add it in fillable in User.php Model

protected $fillable = [
      'user_id', 'field1','field2',
  ];

cent040 left a reply on Ajax Returning 500 Internal Server Error

check your route it must be POST

and your ajax URL

 url    : {{(url('updater')}},

OR

url : "<?php echo url('updater'); ?>",

Regards Arfan

06 Jan
2 years ago

cent040 left a reply on Notification (plus/bell) Hard To Click

yes very hard to click on bell. It's work only when your cursor on plus(+).

cent040 left a reply on Laravel 5.3

Create your own register function in RegisterController

public function register(Request $request)
{
  $user = User::create([
          'name' => $request->input('name'),
          'email' => $request->input('email'),
         'password' => bcrypt($request->input('password')),
    ]);
return redirect("/login");
}

Regards Arfan

cent040 left a reply on Format Data From Database Into Correct JSON Structure. (Fusioncharts)

Simple

echo json_encode($mappedCollection); 

and send data to chart.

Regards Arfan

cent040 left a reply on [L5.2] Blank Screen After Submitting Form.

there must be a php error on your page that's why it's showing blank page. go to .env change DEBUG to TRUE. It will show you what's the error.

cent040 left a reply on [L5.2] Blank Screen After Submitting Form.

Where is your route file

Add this in route

Route::post('/addwarehouse', '[email protected]');

Regards Arfan

03 Jan
2 years ago

cent040 started a new conversation Laravel In A Directory With Nginx And WordPress

I am using Laravel 5.2 and WordPress. My WordPress files or

WordPress : /var/www/html/site Laravel : /var/www/html/laravel_files

My Domain example.com Access the wordpress code (site folder). But i want to access My Laravel Applicaiton with this link : example.com/app

here is my nginx conf

# You may add here your
# server {
#       ...
# }
# statements for each of your virtual hosts to this file
server {
        listen 80;
         listen [::]:80;
 # listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# include snippets/ssl-3ptcap.com.conf;
# include snippets/ssl-params.conf;

    root /var/www/html/site;
    index index.php index.html index.htm;



    # Make site accessible from http://localhost/
    server_name 3ptcap.com www.3ptcap.com;
access_log /var/log/nginx/3ptappsite.access.log;
 error_log /var/log/nginx/3ptappsite.error.log;

location /app {
       index index.php
 try_files $uri $uri/ /var/www/html/3ptapp/public/index.php?$args;
}


    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            #try_files $uri $uri/ =404;
             try_files $uri $uri/ /index.php?$query_string;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
location = /robots.txt { log_not_found off; access_log off; allow all; }

When i try access example.com/app it give me 404 page error. Any help please.

cent040 left a reply on Nginx Setup For Subdirectory

Best Answer award should go to @bashy :)

cent040 left a reply on How To Redirect The Page After Logout To Login Page

Simply Add this on controller constructor

$this->middleware('auth');

Now one can access the controller function without login.

Regards Arfan

cent040 left a reply on How Do I Display This Image From Storage/app?

you must set the destination path of your file while uploading.

cent040 left a reply on PuTTy SSH Connection Permission Denied When Installing Laravel

using virtual host.

If you find the above answer correct. Mark it to Best Answer.

Regards Arfan

cent040 left a reply on Sweetalert2 Confirm Box Is Not Working In Ajax And Laravel 5.3

I have added the cdn links and it's work for me.

cent040 left a reply on Query From Two Tables With 'Where' Conditions

@yansusanto I have update my answer on top. it will help you.

Regards Arfan

cent040 left a reply on PuTTy SSH Connection Permission Denied When Installing Laravel

Install laravel by using login root. run below command

sudo su

It may solve your problem

Regards Arfan

cent040 left a reply on Two Factor Authentication

Hi, @jryd you must use this one for google 2FA

https://github.com/antonioribeiro/google2fa

i am using this it's working fine

Regards Arfan

cent040 left a reply on How Do I Display This Image From Storage/app?

i think is created maybe hidden

get one of images with this code to check

<img class="user_avatar" src="{{url('public/storage/app/image.jpg')}}">

cent040 left a reply on Different Access Levels

Here is User.php model

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zizaco\Entrust\Traits\EntrustUserTrait;

class User extends Authenticatable
{
    use Notifiable;
    use EntrustUserTrait; 
    
.... . ..

}

Regards Arfan

cent040 left a reply on Different Access Levels

Hi, It's very easy to create access levels with this library. I am already using this you can create many access level as needed.

https://github.com/Zizaco/entrust

Regards Arfan

cent040 left a reply on How Do I Display This Image From Storage/app?

Yes @Doga you are right. Image should store in storage/app folder

It's simple run this command in your composer

php artisan storage:link

you will see a shortcut of storage folder in public folder like : public/storage

now you can get image easily

<img class="user_avatar" src="{{url('public/storage/app/image.jpg')}}">

Regards Arfan

cent040 left a reply on Change The Url Of The Password Reset Link Send By Broker

simple update your email template.

Goto

 resource/view/auth/password.blade.php

you can change the link and template of email there.

Regards Arfan

cent040 left a reply on Change The Url Of The Password Reset Link Send By Broker

Yes simple add your new url in routes, and change in "auth/reset.blade.php" form action url as well.

Regards Arfan

cent040 left a reply on Query From Two Tables With 'Where' Conditions

Simple here Controller

$orders = Order::with('user', 'invoice')->latest()->paginate(10);
foreach($orders as $order) { 
    $order->agents = User::whereStatus(3)->where('location', $order->location_id)->get();
}

On View

@foreach ($orders as $order)
    <select class="custom-select" name="agent_id">
    @foreach($order->agents as $agent)
            <option value="{{ $agent->id }}">{{ $agent->name }}</option>
    @endforeach
</select>
@endforeach

If it solve your problem. Mark the best answer.

Regards Arfan