virtual

virtual

Member Since 2 Years Ago

Experience Points
890
Total
Experience

4,110 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
890 XP
Sep
11
4 months ago
Activity icon

Started a new Conversation Fetch Nested Table Data In Laravel

Hi, I have faced a problem. I am want to fetch data from multiple table.But cuold not do this. Below i am given my elequent relationships. Model- Order

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    protected $guarded=[];
    
    public function orderItems()
    {
        return $this->hasMany(OrderItem::class);
    }
}

model-OrderItem

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class OrderItem extends Model
{
    protected $guarded=[];
    public function products()
    {
        return $this->belongsTo(Product::class);
    }
   
    public function orders()
    {
        return $this->belongsTo(Order::class);
    }
}

Model-Product

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $guarded=[];
    public function user()
    {
        return $this->belongsTo(User::class);
    }
  
  
    public function orderItem()
    {
        return $this->hasMany(OrderItem::class);
    }
  
}

And my controller method

public function completeOrder()
{
  
    $orders  = Order::with(['orderItems','orderItems.products'])->where('user_id',Auth::user()->id)->get();
    return $orders;
     return view('frontEnd.cart.completeOrder',compact('cartItem'));
}

Result---

[{"id":1,"user_id":11,"orderNumber":"#00000012","total":"3,525.94","payment":"ssfs","transaction_id":null,"process":"pending","processed_by":null,"created_at":"2019-09-11 04:50:49","updated_at":"2019-09-11 04:50:49","order_items":[]},{"id":2,"user_id":11,"orderNumber":"#00000012","total":"15,634.41","payment":"ssfs","transaction_id":null,"process":"pending","processed_by":null,"created_at":"2019-09-11 04:54:32","updated_at":"2019-09-11 04:54:32","order_items":[]},{"id":3,"user_id":11,"orderNumber":"#00000012","total":"15,634.41","payment":"ssfs","transaction_id":null,"process":"pending","processed_by":null,"created_at":"2019-09-11 05:00:01","updated_at":"2019-09-11 05:00:01","order_items":[]},{"id":4,"user_id":11,"orderNumber":"#00000012","total":"5,302.22","payment":"ssfs","transaction_id":null,"process":"pending","processed_by":null,"created_at":"2019-09-11 05:04:34","updated_at":"2019-09-11 05:04:34","order_items":[]},{"id":5,"user_id":11,"orderNumber":"#00000012","total":"1,210.00","payment":"ssfs","transaction_id":"978678","process":"pending","processed_by":null,"created_at":"2019-09-11 05:07:00","updated_at":"2019-09-11 05:07:00","order_items":[]},{"id":6,"user_id":11,"orderNumber":"#00000012","total":"2,214.30","payment":"ssfs","transaction_id":null,"process":"pending","processed_by":null,"created_at":"2019-09-11 05:18:04","updated_at":"2019-09-11 05:18:04","order_items":[]},{"id":7,"user_id":11,"orderNumber":"#00000012","total":"2,214.30","payment":"ssfs","transaction_id":null,"process":"pending","processed_by":null,"created_at":"2019-09-11 05:19:53","updated_at":"2019-09-11 05:19:53","order_items":[]},{"id":8,"user_id":11,"orderNumber":"#00000012","total":"4,951.32","payment":"ssfs","transaction_id":null,"process":"pending","processed_by":null,"created_at":"2019-09-11 12:22:51","updated_at":"2019-09-11 12:22:51","order_items":[{"id":12,"order_id":8,"product_id":6,"discount":"12","tax":"859.32","subtotal":"432","quantity":1,"created_at":"2019-09-11 12:22:51","updated_at":"2019-09-11 12:22:51","products":null},{"id":13,"order_id":8,"product_id":7,"discount":"12","tax":"859.32","subtotal":"3660","quantity":2,"created_at":"2019-09-11 12:22:51","updated_at":"2019-09-11 12:22:51","products":null}]},{"id":9,"user_id":11,"orderNumber":"#00000012","total":"866.36","payment":"ssfs","transaction_id":"78965","process":"pending","processed_by":null,"created_at":"2019-09-11 13:17:04","updated_at":"2019-09-11 13:17:04","order_items":[{"id":14,"order_id":9,"product_id":3,"discount":"12","tax":"150.36","subtotal":"284","quantity":1,"created_at":"2019-09-11 13:17:04","updated_at":"2019-09-11 13:17:04","products":null},{"id":15,"order_id":9,"product_id":6,"discount":"12","tax":"150.36","subtotal":"432","quantity":1,"created_at":"2019-09-11 13:17:04","updated_at":"2019-09-11 13:17:04","products":null}]},{"id":10,"user_id":11,"orderNumber":"#00000012","total":"0.00","payment":"ssfs","transaction_id":"78965","process":"pending","processed_by":null,"created_at":"2019-09-11 13:17:58","updated_at":"2019-09-11 13:17:58","order_items":[]},{"id":11,"user_id":11,"orderNumber":"#00000012","total":"0.00","payment":"ssfs","transaction_id":"78965","process":"pending","processed_by":null,"created_at":"2019-09-11 13:19:23","updated_at":"2019-09-11 13:19:23","order_items":[]},{"id":12,"user_id":11,"orderNumber":"#00000012","total":"0.00","payment":"ssfs","transaction_id":"78965","process":"pending","processed_by":null,"created_at":"2019-09-11 13:19:35","updated_at":"2019-09-11 13:19:35","order_items":[]},{"id":13,"user_id":11,"orderNumber":"#00000012","total":"0.00","payment":"ssfs","transaction_id":"78965","process":"pending","processed_by":null,"created_at":"2019-09-11 13:19:43","updated_at":"2019-09-11 13:19:43","order_items":[]},{"id":14,"user_id":11,"orderNumber":"#00000012","total":"2,214.30","payment":"ssfs","transaction_id":"2423","process":"pending","processed_by":null,"created_at":"2019-09-11 14:04:20","updated_at":"2019-09-11 14:04:20","order_items":[{"id":16,"order_id":14,"product_id":7,"discount":"12","tax":"384.30","subtotal":"1830","quantity":1,"created_at":"2019-09-11 14:04:20","updated_at":"2019-09-11 14:04:20","products":null}]}]

I want to fetch all product data but can not do this. How to solve this problem. note in the order table user_id column exist. Thanks in advanced.

Sep
01
4 months ago
Activity icon

Replied to First RowId Not Deleted From The Shopping Cart

@nakov sir, only first item not pass to the controller method. when click the button it is not show confirm messag instead of it generate the below url..

http://localhost/electro_service/user/product/user-account/cart?quantity=1&_token=XPjzGyyykNjE5OAtd3NcQEA3mvpBF8DHH8reESSr&_method=DELETE&quantity=1&name=#
Activity icon

Replied to First RowId Not Deleted From The Shopping Cart

@nakov sir, Everything works fine, when item add to the cart then the only first item rowid not delted. even delete button not working of first item.Besides the first item, all other items are deleted from the cart successfully. I want to know what's the problem.

Activity icon

Replied to First RowId Not Deleted From The Shopping Cart

@Snapey sir Yes it is shopping cart packge method.

Activity icon

Replied to First RowId Not Deleted From The Shopping Cart

@nakov sir I am use resource controller. is the problem arise using resource controller?

Activity icon

Started a new Conversation First RowId Not Deleted From The Shopping Cart

Hi, I am working in laravel 5.8. In my project I am installing shopping cart API. This works fine but when I am trying to delete items from shopping but only first rowId not deleted from the shopping cart. Besides all of those are deleled form the cart successfully.I don't understand what is the problem. Why don't delete first rowId?. Here is the blade part

<td class="product-remove">
    <form action="{{route('user.cart.destroy',$item->rowId)}}" method="post" onsubmit="return confirm('Are you sure?');">
           @csrf
        @method('DELETE')
       <button><i class="zmdi zmdi-close"></i</button>
                                                                
     </form> 
</td>

Here is the cart controller--

 public function destroy($id)
    {
       // return $id;
        Cart::remove($id);
        return back(); // will keep same page
    }

But when i checked developer console then get below error

GET http://localhost/electro_service/user/product/user-account/'https://fonts.googleapis.com/css?family=Raleway:400,500,600,700|Roboto:400,500,700 net::ERR_ABORTED 404 (Not Found)  cart:18

I don't understood this error. Please anyone help me. Thanks in advanced.

Jul
28
5 months ago
Activity icon

Replied to Redirector::with Does Not Exist.

@bobbybouwmann ,Yes it is default auth but why show this error message after reset passsword and why not redirect me aspect location such as admin or user panel

Activity icon

Replied to Redirector::with Does Not Exist.

Please response @bobbybouwmann sir

Activity icon

Replied to Redirector::with Does Not Exist.

@bobbybouwmann sir I do not know where change is needed. here is my ResetPasswordController

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Support\Facades\Auth;

class ResetPasswordController extends Controller
{ 
    use ResetsPasswords;
    protected $redirectTo;
    public function __construct()
    {
        if (Auth::check() && ((!empty(Auth::user()->role->role) == 0)||(!empty(Auth::user()->role->role) == 1)||(!empty(Auth::user()->role->role) == 2))&&Auth::user()->role_id !=NULL) {
            $this->redirectTo=route('admin.dashboard');
        }else{
             $this->redirectTo='/';
        }
        $this->middleware('guest');
    }
}

And some part of traits (ResetsPasswords)

use RedirectsUsers;

    public function showResetForm(Request $request, $token = null)
    {
        return view('auth.passwords.reset')->with(
            ['token' => $token, 'email' => $request->email]
        );
    }

  
    public function reset(Request $request)
    {
        $request->validate($this->rules(), $this->validationErrorMessages());

        $response = $this->broker()->reset(
            $this->credentials($request), function ($user, $password) {
                $this->resetPassword($user, $password);
            }
        );

        return $response == Password::PASSWORD_RESET
                    ? $this->sendResetResponse($request, $response)
                    : $this->sendResetFailedResponse($request, $response);
    }

    
    protected function rules()
    {
        return [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:8',
        ];
    }

    /**
     * Get the password reset validation error messages.
     *
     * @return array
     */
    protected function validationErrorMessages()
    {
        return [];
    }

    /**
     * Get the password reset credentials from the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    protected function credentials(Request $request)
    {
        return $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );
    }

    /**
     * Reset the given user's password.
     *
     * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user
     * @param  string  $password
     * @return void
     */
    protected function resetPassword($user, $password)
    {
        $user->password = Hash::make($password);

        $user->setRememberToken(Str::random(60));

        $user->save();

        event(new PasswordReset($user));

        $this->guard()->login($user);
    }

    /**
     * Get the response for a successful password reset.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  string  $response
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
     */
    protected function sendResetResponse(Request $request, $response)
    {
        return redirect($this->redirectPath())
                            ->with('status', trans($response));
    }

Sir please tell me where change is needed

Activity icon

Replied to Redirector::with Does Not Exist.

Anyone help me

Activity icon

Started a new Conversation Redirector::with Does Not Exist.

Hi, I am new in laravel, I am trying to reset password with laravel default authentication. It insert data in reset_password table successfully and login. But when reset password it did not redirect me in admin panel or user panel instead of it show an errror message Illuminate\Routing\Redirector::with does not exist.. . I am searched in google but can not find proper solution. Here the error class

C:\xampp\htdocs\electro_service\vendor\laravel\framework\src\Illuminate\Support\Traits\Macroable.php
        if (static::$macros[$method] instanceof Closure) {
            return call_user_func_array(Closure::bind(static::$macros[$method], null, static::class), $parameters);
        }
 
        return call_user_func_array(static::$macros[$method], $parameters);
    }
 
    /**
     * Dynamically handle calls to the class.
     *
     * @param  string  $method
     * @param  array  $parameters
     * @return mixed
     *
     * @throws \BadMethodCallException
     */
    public function __call($method, $parameters)
    {
        if (! static::hasMacro($method)) {
            throw new BadMethodCallException(sprintf(
                'Method %s::%s does not exist.', static::class, $method
            ));
        }
 
        $macro = static::$macros[$method];
 
        if ($macro instanceof Closure) {
            return call_user_func_array($macro->bindTo($this, static::class), $parameters);
        }
 
        return call_user_func_array($macro, $parameters);
    }
}
 

How can I solved this problem. Thanks in advanced

Activity icon

Replied to Method Illuminate\Routing\Redirector::with Does Not Exist.

Hi, I am face the same problem, Please help me how to solve this problem. I think here is not proper solution

Jul
27
6 months ago
Activity icon

Replied to Object Of Class Illuminate\Routing\Redirector Could Not Be Converted To String

Hi,I am successfully solved this problem. In RegisterController.php

protected $redirectTo;

  /**
   * Create a new controller instance.
   *
   * @return void
   */
  public function __construct()
  {
      if (Auth::check() && ((!empty(Auth::user()->role->role) == 0)||(!empty(Auth::user()->role->role) == 1)||(!empty(Auth::user()->role->role) == 2))) {
          $this->redirectTo=route('admin.dashboard');
      }else{
           $this->redirectTo='/';
      }
      $this->middleware('guest');
  }

Thanks for all to spent your time with mine.

Jul
26
6 months ago
Activity icon

Replied to Object Of Class Illuminate\Routing\Redirector Could Not Be Converted To String

@mstrauss sir i am trying your solution. but get the same error. what will next step?

Activity icon

Replied to Object Of Class Illuminate\Routing\Redirector Could Not Be Converted To String

@mstrauss sir here is the registerController

namespace App\Http\Controllers\Auth;

use App\Models\User; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Support\Facades\Auth;

class RegisterController extends Controller {

use RegistersUsers;

protected $redirectTo;
public function __construct()
{
    if (Auth::check() && Auth::user()->role->role == 0) {
         return $next($request);
    }else{
        return redirect('/');
    }
    $this->middleware('guest');
}
protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => ['required', 'string', 'max:255'],
        'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
        'password' => ['required', 'string', 'min:8', 'confirmed'],
    ]);
}
protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => Hash::make($data['password']),
    ]);
}

}

Activity icon

Started a new Conversation Object Of Class Illuminate\Routing\Redirector Could Not Be Converted To String

Hello when I am trying to register as a new user in my local app then get the above error through Response.php class. here the code

C:\xampp\htdocs\electro_service\vendor\symfony\http-foundation\Response.php }

/**
 * Sets the response content.
 *
 * Valid types are strings, numbers, null, and objects that implement a __toString() method.
 *
 * @param mixed $content Content that can be cast to string
 *
 * @return $this
 *
 * @throws \UnexpectedValueException
 */
public function setContent($content)
{
    if (null !== $content && !\is_string($content) && !is_numeric($content) && !\is_callable([$content, '__toString'])) {
        throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', \gettype($content)));
    }

    $this->content = (string) $content;

    return $this;
}

/**
 * Gets the current response content.
 *
 * @return string Content
 */
public function getContent()
{
    return $this->content;
}

I am not understand this problem and how to solve this problem. Anyone help me .Thanks in advanced.