sanjayacloud

sanjayacloud

Member Since 2 Years Ago

Experience Points
6,710
Total
Experience

3,290 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
8
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 2
6,710 XP
Sep
10
2 weeks ago
Activity icon

Started a new Conversation Get First 2 Characters Like "20" From Database In Laravel

Hi Friend,

I need to get a record from the database query like below

Select from orders where waybill_id first 2 characters like "20"

Anyone can help me with is.

I have tried like below. But it does not work.

 $prefix = env("Auto_Mate_Way_Bill_Prefix", '20');
        $latest_waybill = Order::latest('waybill_id')->where('waybill_id', 'like', '%' . $prefix . '%')->first();

Aug
22
1 month ago
Activity icon

Started a new Conversation Generate Invoice Number In Larvel To Predefined Specific Format

Hi Everyone, I am trying to generate invoice numbers automatically in laravel with predefined formate. Formate as follows. I don't know how to do that. Anyone can help me to do that. The invoice number should be started from "AT000001" and it should be increment.

Aug
21
1 month ago
Activity icon

Awarded Best Reply on How To Pass Object As Parameter To Url In Javascript

I have solved this problem with the below solution

   var params = respond.orders;
                        params = JSON.stringify(params);
                        // console.log(typeof params)
                        // //JSON.parse()
                        window.open("{{ url('client-orders/get-waybills-to-barcode-print-view-from-excel?orders=')}}" + params);
Activity icon

Replied to How To Pass Object As Parameter To Url In Javascript

I have solved this problem with the below solution

   var params = respond.orders;
                        params = JSON.stringify(params);
                        // console.log(typeof params)
                        // //JSON.parse()
                        window.open("{{ url('client-orders/get-waybills-to-barcode-print-view-from-excel?orders=')}}" + params);
Activity icon

Started a new Conversation Access Javascript Json.stringify In Laravel

Hi Guy I need to know, How to access the below data in laravel. I am passing data using javascript json.stringify method to laravel function.

Here is the out put data


"[{\"id\":1046,\"waybill_id\":\"20000046\",\"client_id\":1,\"order_no\":\"Test%20Order%20Number\",\"customer_name\":\"Test\",\"address\":\"Test\",\"phone_no\":\"1234567890\",\"description\":\"Test\",\"district_id\":2,\"city_id\":4,\"branch_id\":null,\"cod\":2000,\"collected_cod\":null,\"delivery_charge\":null,\"wight\":null,\"note\":null,\"first_kg\":null,\"after_kg\":null,\"inv_id\":null,\"deposit_id\":null,\"created_at\":\"2020-08-22%2000:43:46\",\"updated_at\":\"2020-08-22%2000:43:46\"}]"

~~

Need to access this "waybill_id" values.
Activity icon

Replied to How To Pass Object As Parameter To Url In Javascript

Same error. Anyone have other solution?

Activity icon

Replied to How To Pass Object As Parameter To Url In Javascript

@tykus @squiaios

Now I got below error for both of your's solutions.

TypeError: Failed to construct 'URLSearchParams': The object must have a callable @@iterator property.

Activity icon

Replied to How To Pass Object As Parameter To Url In Javascript

I got "URLSearchParams.getAll is not a function " error. I used it below.

 window.location.href = "{{ url('client-orders/get-waybills-to-barcode-print-view-from-excel?orders=')}}"+URLSearchParams.getAll(respond['orders']);
Activity icon

Started a new Conversation How To Pass Object As Parameter To Url In Javascript

This is my JS

success: function (respond) {
                    if(respond.success){
                        //console.log(respond.orders);
                        window.location.href = "{{ url('client-orders/get-waybills-to-barcode-print-view-from-excel?orders=')}}"+respond.orders;
                    }
                },

if I console log this respond.orders, I got below result

Array(1)
0: {id: 1022, waybill_id: "20000021", client_id: 1, order_no: "Test Order Number", customer_name: "Test", …}
length: 1
__proto__: Array(0)

This is my method

public function getWaybillToBarcodeViewExcel(Request $request)
    {
        dd($request->all());
      

    }

In this dd(), I got below result

array:1 [▼
  "orders" => "[object Object]"
]

Jun
22
3 months ago
Activity icon

Replied to Unable To Get Google Adwords Campaign Data

No. I cannot solve this dr.

May
12
4 months ago
Activity icon

Started a new Conversation How To Get Next Seven Day Data In Laravel

Hi Guys,

I want to get the next seven data in laravel using carbon to send a reminder. Actually I want to do an opposite in below method.

$anchor = Carbon::today()->subDay(7);
$users = Invoices::where('created_at', '>=', $date)->get();


dd($users);

May
09
4 months ago
Activity icon

Replied to Auth Middleware Not Work

Hi Friends. This is my fault. In web.php for instructor/dashboard, I called the admin dashboard controller. That's why happened like this. Sorry for troubling you. Thanks for your support.

Activity icon

Replied to Auth Middleware Not Work

@mvd I have a separate login for admin with the middleware like this. Its works fine. And this happens after successful login from instructor login. it's not getting redirect path where defined in the instructor login controller.

Activity icon

Replied to Auth Middleware Not Work

Will try dr.

Activity icon

Replied to Auth Middleware Not Work

Here is my User Model

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'role_id', 'gender', 'age', 'mobile', 'address', '	status',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    public function Role()
    {
        return $this->belongsTo('App\Role', 'role_id');
    }

    public function Student()
    {
        return $this->hasOne('App\Student');
    }
}


Activity icon

Replied to Auth Middleware Not Work

@mvd What am I do? I want to redirect to the instructor to a different dashboard. I have made middleware like this. it's work fine.

Activity icon

Started a new Conversation Auth Middleware Not Work

Hi friends,

I have created middleware for a user role. My admin middleware is worked fine. But instructor middleware redirects to the wrong place (localhost:8000/home). Anyone can help me with this?

My Middleware

<?php

namespace App\Http\Middleware;

use Closure;

class Instructor
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if(auth()->user()->role_id == 2){
            $response = $next($request);
            $response->header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0')->header('Pragma', 'no-cache')->header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');
            return $response;
        }
        return redirect('/instructor/login')->with('msg','You have not admin access');
    }
}


Instructor Login

<?php

namespace App\Http\Controllers\Instructor\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/instructor/dashboard';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    /**
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function showLoginForm() {
        return view('instructor.auth.login');
    }

    protected function attemptLogin(Request $request)
    {
        return (auth()->attempt(['email' => $request->email, 'password' => $request->password, 'role_id' => 2]));

    }
//    protected function attemptLogin(Request $request) {
//        return (auth()->attempt(['email' => $request->email, 'password' => $request->password, 'role_id' => 1]));
//    }

    /**
     * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {
       if ($user->role_id == 2){
           return redirect('instructor/dashboard');
       }
       else {
           return back();
       }
    }
    /**
     * Log the user out of the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function logout(Request $request) {
        $this->guard()->logout();
        $request->session()->invalidate();
        return $this->loggedOut($request) ?:redirect('instructor/login');
    }
}


May
03
4 months ago
Activity icon

Replied to Get Characters After Second/ In Path

I want to get a third parameter (1587654236-817295330). Because of Its a folder. Actually I want to delete the image with the folder.

Activity icon

Started a new Conversation Get Characters After Second/ In Path

HI Guys,

I want to get the characters after the second "/" in a path like storage/venues/1587654236-817295330/1587654236-883425557.jpg

Anyone can help me to do this?

May
01
4 months ago
Activity icon

Replied to Can't Validate Radio Button

Thanks. Will try and let you know.

Apr
30
4 months ago
Activity icon

Started a new Conversation Can't Validate Radio Button

Hi All,

I am trying to validate radio button. but its not works. Anyone can help me on this? This is my radio button and validation.

   <div class="col-sm-12">
                                <div class="radio">
                                    <label for="රැකියා විරහිත">
                                        <input type="radio" name="job" id="රැකියා විරහිත" value="රැකියා විරහිත" {{ (collect(old('job'))->contains('රැකියා විරහිත')) ? 'checked':'' }} >
                                        රැකියා විරහිත
                                    </label>
                                </div>
                                <div class="radio">
                                    <label for="පූර්ණ කාලීන සේවය">
                                        <input type="radio" name="job" id="පූර්ණ කාලීන සේවය" value="පූර්ණ කාලීන සේවය" {{ (collect(old('job'))->contains('පූර්ණ කාලීන සේවය')) ? 'checked':'' }}>
                                        පූර්ණ කාලීන සේවය
                                    </label>
                                </div>
                                <div class="radio">
                                    <label for="අර්ධ කාලීන සේවය">
                                        <input type="radio" name="job" id="අර්ධ කාලීන සේවය" value="අර්ධ කාලීන සේවය" {{ (collect(old('job'))->contains('අර්ධ කාලීන සේවය')) ? 'checked':'' }}>
                                        අර්ධ කාලීන සේවය
                                    </label>
                                </div>
                                <div class="radio">
                                    <label for="ගෘහණියකි">
                                        <input type="radio" name="job" id="ගෘහණියකි" value="ගෘහණියකි" {{ (collect(old('job'))->contains('ගෘහණියකි')) ? 'checked':'' }}>
                                        ගෘහණියකි
                                    </label>
                                </div>
                                @if ($errors->has('job'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('job') }}</strong>
                                    </span>
                                @endif
                            </div>

Validation

    $validator = Validator::make($request->all(), [
            'job' => 'required',
        ]);

        if ($validator->fails()) {
            return redirect('questions')
                ->withErrors($validator)
                ->withInput();
        }

Apr
25
4 months ago
Activity icon

Replied to Get Count Of Not Null Items

@michaloravec

Thanks. Its work. It's my fault.

Activity icon

Replied to Get Count Of Not Null Items

I have cleaned cache and try now it's said null. But This user has answered questions.

Activity icon

Replied to Get Count Of Not Null Items

@maheshkalasa

I add it as you answered,

 public function getUnansweredQuestionCountAttribute() {
        return collect($this->attributes)->except(['created_at', 'updated_at'])->filter()->count();
    }

But I got the same error

App\Question::getUnansweredQuestionCountAttribute must return a relationship instance.
Activity icon

Replied to Get Count Of Not Null Items

I am doing the same thing.

I add this below method in my question model.

public function getUnansweredQuestionCountAttribute() {
    return count(array_filter($this->attributes));
}

and I access it like below.

 $qs = Question::where('user_id', Auth::user()->id)->count();
            dd($qs->getUnansweredQuestionCountAttribute);

I got App\Question::getUnansweredQuestionCountAttribute must return a relationship instance.

Any idea

Activity icon

Replied to How Do I Get A Count Of How Many Columns Are (or Aren't) Null In A Query?

@cronix

I am doing the same thing.

I add this below method in my question model.

public function getUnansweredQuestionCountAttribute() {
    return count(array_filter($this->attributes));
}

and I access it like below.

 $qs = Question::where('user_id', Auth::user()->id)->count();
            dd($qs->getUnansweredQuestionCountAttribute);

I got App\Question::getUnansweredQuestionCountAttribute must return a relationship instance.

Any idea?

Activity icon

Replied to Get Count Of Not Null Items

@bobbybouwmann @maheshkalasa @michaloravec

This is my query

$qs = Question::where('user_id', Auth::user()->id)->first();

This is the output

Image Link: https://i.stack.imgur.com/Zp2Bf.png

I want to count that not null columns. Can anybody help me with this?

Apr
21
5 months ago
Activity icon

Replied to Get Count Of Not Null Items

I want do it on ORM. Not pure SQL

Activity icon

Replied to Get Count Of Not Null Items

This is the insert query. I want to count that answered cells in this row

INSERT INTO `questions` (`id`, `q1`, `q2`, `q3`, `q4`, `q4_a`, `q5`, `q5_2`, `q5_3`, `q5_4`, `q5_5`, `q5_6`, `q5_7`, `q5_8`, `q6`, `q6_2`, `q6_3`, `q7`, `q7_2`, `q7_3`, `q7_4`, `q7_5`, `q8`, `q9`, `q9_2`, `q9_3`, `q10`, `q10_2`, `q10_3`, `q10_4`, `q10_5`, `q10_6`, `q10_7`, `q11`, `q11_2`, `q11_3`, `q11_4`, `q11_5`, `q12`, `q12_2`, `q12_3`, `q13`, `q13_2`, `q13_3`, `q13_4`, `q13_5`, `q13_6`, `q13_7`, `q13_a`, `q14`, `q15`, `q16`, `q17`, `q18`, `q19`, `q20`, `created_at`, `updated_at`, `user_id`) VALUES (NULL, 'Test', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2020-04-21 00:00:00', '2020-04-21 00:00:00', NULL);

Activity icon

Started a new Conversation Get Count Of Not Null Items

Hi Guys,

I want to know how to get a count of not null items in a row. As an example, if someone answers to question 1 to 5 and leave other 5 then answer should be 5. Can I know how to do it in the row?

Mar
20
6 months ago
Activity icon

Replied to API For Social Social Listening.

Hi @bugsysha this something similer for brand24.com