Member Since 5 Months Ago

Experience Points 640
Experience Level 1

4,360 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
Best Reply Awards 0
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    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.

28 Feb
4 months ago

Shoken left a reply on Form Doesn't Get Values

Thanks guys, adding a name attribute worked! How did I miss that?

However, there's one more thing: the correct name I had to add was something like "category[]". The brackets allowed to me to accept multiple inputs for the same checkboxes.

Thanks again!

Shoken started a new conversation Form Doesn't Get Values

Here's my form:

<form id="filter" action="/filter" method="POST">
              <div class="checkbox checkbox-primary">
                  @foreach($data['category'] as $category)
                    <input form="filter" id="cat-{{$category->id}}" value="{{$category->id}}" class="styled" type="checkbox" >
                    <label for="cat-{{$category->id}}"> {{$category->name}} </label>
              <!-- Featured Brands -->
              <h6>Brand in vetrina</h6>
              <div class="checkbox checkbox-primary">
                  @foreach($data['brands'] as $brand)
                    <input form="filter" id="brand-{{$brand->id}}" value="{{$brand->id}}" class="styled" type="checkbox" >
                    <label for="brand-{{$brand->id}}"> {{$brand->name}} </label>
                    <input type="submit" form="filter" value="Filter" class="btn-round">


It seems fine to me, however when I dd($request) from the controller, there's nothing in the parameter bag. The form appears just fine, so I have no clue what is going wrong. The checkboxes can be selected but no value is taken, apparently.

My routes are set up correctly and my controller only contains a dd($request)

25 Feb
4 months ago

Shoken started a new conversation Form Generated By AJAX Post Does Not Get Styled.

The problem is rather simple. Here is my HTML code for the form:

                                    <h5 class="info-text"> Position</h5>
                                    <div class="row justify-content-center">
                                        <div class="col-sm-10">

                                            <div class="togglebutton">
                                                    <input type="checkbox" id="subCat">
                                                    <span class="toggle"></span>
                                        <div class="col-sm-10" id="mainRanking">
                                            {!! Form::select('position', array_merge(['' => 'Last (default)'],array_pluck($categories, 'sortOrder')), old('position') ,array('id'=>'position','class'=>'selectpicker','data-style'=>'select-with-transition','title'=>'Position','required'=>'required')) !!}
                                        <div class="col-sm-10" style="display:none" id="parentCat">
                                            {!! Form::select('position1', array_pluck($categories, 'name'), old('position1') ,array('id'=>'position1','class'=>'selectpicker','data-style'=>'select-with-transition','title'=>'Parent Category','required'=>'required')) !!}
                                        <div class  id="formcontainer">



You can see there is an empty div at the bottom, called formcontainer, which is where I put my second select form once a selection has been picked for the first one. To do so, I use this AJAX code:

                    categoryname: $('#position1 option:selected').text(),
                function(data) {
                    $('#formcontainer').empty().append( data );


            ) });

The Controller that takes care of this post request is:

public function get(Request $request){



        return view('back_end.selectorderform')->with('subcategories',$subcategories);


And lastly, the returned HTML to put inside the empty div is:

    <div class="col-sm-10" id="insideRanking">
{!! Form::select('position2', array_pluck($subcategories, 'name'),['id'=>'position2','class'=>'selectpicker','data-style'=>'select-with-transition','title'=>'Position','required'=>'required']) !!}

The code works, as the second select is generated with the correct values I seek, next to the first one. Problem is, it isn't styled, and I can't get it to be styled. Here is a screenshot of how it looks, so maybe it can give you a better idea:

The one on the left is the first form (styled) and the one on the right is the one generated in the empty div.

I understand this is a lenghty question, so special thanks to whoever feels like helping. (:

21 Feb
4 months ago

Shoken started a new conversation How To Make A Page Accessible Only By Clicking On A Button?

Title is confusing, I understand. Here's what's happening: my user has a view on their cart where they can review which items they are buying. On that view, they can click a button that says "Go to payment methods" and open another view where they can insert their data.

However, I do not want that payment page to be accessible from the URL. The user should only get there by using that button, and not in any other way.

I've tried using sessions but the basic knowledge I have is probably not enough. This is a cardinal part for security (my project isn't really going live, it's for uni), and I wanted to know if there was a standarized better way that I'm not aware of.

20 Feb
4 months ago

Shoken left a reply on Class "Input" Not Found.

Using old('product') fixed the problem, and yes I did put "use" on top of the controller. Guess we will never know what was causing that error.

19 Feb
4 months ago

Shoken started a new conversation Class "Input" Not Found.

This is the error I get:

Class 'Input' not found (View: C:\MAMP\htdocs\eCommerce\resources\views\back_end\createProduct.blade.php)

The line with the error is this one:

 Form::text('name', Input::old('nameProduct'),['class' => 'form-control','required' => 'required']) }}

Yes, I know I should've inserted Input in the aliases in the config/app.php file, and I have done so. In the aliases , there is:

'Input' => Illuminate\Support\Facades\Input::class,

So I have no idea what I am doing wrong. I'm doing this project with another guy and he doesn't get this error, while I do, and our Git version is EXACTLY the same. We're totally lost here,

Shoken left a reply on Using AJAX With Laravel For Simple Operations

I wanted to give this issue some closure, so people who have the same problem and googled it (hey there!) will find a solution. I read what jlrdw linked and also followed click's advice for CSRF tokens. In the end, I managed to make it work with this code:


// "cart" is the ID of my "Add to Cart" button.

//Gets stuff from the form  (e.g.: number of products to add)

                            number: document.getElementById("number").value,
                            itemid: $('#hiddenID').text(),
                        function() {

//Changes text on the button and disables it, if the function returns success from PHP.

                            document.getElementById("cart").innerHTML = "Added!";
                            document.getElementById("cart").disabled = true;

                    ) });


18 Feb
4 months ago

Shoken started a new conversation Using AJAX With Laravel For Simple Operations

Ok, so my goal is very simple: when the user clicks on the button "Add to Cart", the item gets added to the cart without reloading the page. To do this, I know I have to use AJAX in my Laravel environment.

Here is my HTML button:

<button id="cart" class="btn-round">Aggiungi al carrello</button> 

This is my script:

                type: "POST",
                url: '/addtocart',
                data: { itemid: 2 },

I have added this route to my web:

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

And lastly, this is my Controller:

class CartController extends Controller

    public function add($itemid){

        if (Auth::guest())
        {return redirect('/login');}


            $cartitem=new Cart;


            return redirect('/products/'.$itemid);


As you can see I have hardcoded some values to test stuff, but it does not work. I don't get any errors so I think the Controller is actually never called. The route should be enough, right? Or maybe there are some syntax errors in my AJAX code? I find the online documentation for AJAX extremely confusing.

14 Feb
5 months ago

Shoken left a reply on @foreach Does Nothing, Even If I Do Have Objects.

@CLICK - You were totally on point, and so fast too! I was under the impression that ->take(n) could substitute ->get(), but I re-read the documentation and boy was I wrong. The objects I were passing were query objects!

Thank you so much. I had a massive misunderstanding of a basic function, so I do not regret asking even if that wasn't the smartest question :p

Shoken started a new conversation @foreach Does Nothing, Even If I Do Have Objects.

Ok so what is happening is very weird. What happens is, I have an HTML pane view defined with multiple categories. In this case, my HTML looks like this:

<li role="presentation"><a href="#game-com" aria-controls="special" role="tab" data-toggle="tab"><i class="flaticon-gamepad-1"></i>Game Console <span>{{$data['games']->count()}}</span></a></li>

Now done below I have defined the content of such panes, as such:

<!-- Game Console -->
                    <div role="tabpanel" class="tab-pane fade" id="game-com">
                        <!-- Items -->
                        <div class="item-col-5">
                            <!-- Product -->
                            @foreach($data['games'] as $game)
                                <div class="product">
                                    <article> <img class="img-responsive" src="images/item-img-1-1.jpg" alt="" >
                                        <!-- Content -->
                                        <span class="tag">{{$game->category}}</span> <a href="/products/{{$game->id}}" class="tittle">{{$game->name}}</a>
                                        <!-- Reviews -->
                                        <p class="rev"><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i> <i class="fa fa-star-o"></i> <span class="margin-left-10">{{$game->reviewsnumber}} Recensioni</span></p>
                                        <div class="price">{{$game->normalPrice}} </div>
                                        <a href="/products/{{$game->id}}" class="cart-btn"><i class="icon-basket-loaded"></i></a>

As you can see, those are just little boxes that contain all the info I need (I had a template and simply edited what I needed). However, nothing shows up! I tried doing


Right before the @foreach and it does show at least one element! But nothing appears.

I also tried putting

<p> TEST </p>

Inside the @foreach loop but those do not appear, and even if I go see the Source code of the page, they are not there! Also the {{$data['games']->count()}} on the tab pane works as intended, as it shows the correct number of items I have.

So the items are definitely there and correctly passed to the view, but I simply can't get them to show up. What am I doing wrong?

11 Feb
5 months ago

Shoken left a reply on Form Submit Not Working

Thanks everyone for the answers. I've tried each and everyone of them.

I fixed it, but none of those were the answer. Turns out, I had an open tag in my HTML even before I started writing the form in Laravel. So they were kind of innested forms..? I'm not really sure, but I can see why it wasn't working.

Oh also actually I had to change the routing to lowercase message, that was also necessary.

I lost 4 hours on this. In case anyone else has this problem, please please please check your HTML.

Thanks again!

Shoken left a reply on Form Submit Not Working

@MUNAZZIL - I have, that use is already in place. My message model is empty as I created that with artisan together with its migration.

However, I feel like the controller is not the issue, because even if I simply put "return 123" in the store function, it still doesn't work. I feel like the issue is in the Routing or something, but I just can't get it to work.

Shoken left a reply on Form Submit Not Working

Here is my web.php:


| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!

Route::get('/', '[email protected]');
Route::get('/about','[email protected]');


Route::get('/home', '[email protected]')->name('home');*/

Route::get('/admin',function (){
    return view('back_end.index');

Route::get('/admin',function (){
    return view('back_end.dashboard');

Route::get('/admin/users', '[email protected]');

And I had no output with dd($request). Or at least, I don't know how to get it. Simply going with php artisan serve again produced nothing, and neither did clicking on the button.

Shoken left a reply on Form Submit Not Working

@MUNAZZIL - I get nothing new. Everything's just as it was before: I think the controller is never even called.

Shoken started a new conversation Form Submit Not Working

I've been stuck with this issue for serveral hours, so hopefully some of you can help. Thanks in advance.

The issue is simple: when I click the form's submit button, nothing happens. Like, literally nothing. No errors, anything. Before starting developing the form I had created the Message model by doing

php artisan make:model Message --resource

Thus I have the methods create, store etc.. already done and ready (thanks artisan!). In my route web.php route file, I have:


This should automatically link all the methods, right?

Anyway, my form is:

{!!  Form::open(['action' => '[email protected]', 'method' => 'POST']) !!}
                                    <ul class="row">
                                        <li class="col-sm-6">
                                                {{Form::text('name', '', ['class' => 'form-control'])}}
                                        <li class="col-sm-6">
                                                {{Form::text('email', '', ['class' => 'form-control', 'placeholder' => 'Your email'])}}
                                        <li class="col-sm-12">
                                                {{Form::textarea('message','', ['class' => 'form-control'])}}
                                        {{Form::submit('Submit', ['class' => 'btn-round'])}}

                                    {!! Form::close() !!}

and my [email protected] looks like this:

 public function store(Request $request)
        $this -> validate($request, [
            'name' => 'required',
            'email' => 'required',
            'message' => 'required'

        $message = new Message();
        $message -> name= $request -> input('name');
        $message -> email= $request -> input('email');
        $message -> text= $request ->input('text');
        $message -> user_id = Auth::user()->id;


        return redirect('/');

The controller just doesn't seem to work because even if I cut validation, nothing happens. I have no clue what I'm doing wrong!

10 Feb
5 months ago

Shoken left a reply on Where To Check If An User Is Logged In?

@TYKUS - I had mistakenly copied

use Illuminate\Support\Facades\View;

in the view composer... now it works perfectly! Thank you!

Shoken left a reply on Where To Check If An User Is Logged In?

Alright so I copied the View::Composer function in AppServiceProvider's boot and that other code in the new class. However I am now getting the error:

Argument 1 passed to App\Http\View\Composers\CartComposer::compose() must be an instance of App\Http\View\Composers\View, instance of Illuminate\View\View given

I am... pretty lost here

Shoken started a new conversation Where To Check If An User Is Logged In?

Hey there, I've been using your advice and View::sharing all of my important data to all views. However, there is one issue I have encountered.

This code:

        else $user=0;

        View::share('cartnumber', count($temp));
        View::share('cartitems', $temp);

doesn't work when put in AppServiceProvider. Or better, it always sets $user=0, even if I am logged in. I thought it is because AppServiceProvider's boot function executes before the site checks if someone is logged in.

I then tried to use a BaseController with a construct function but that doesn't work either. The only solution that seems to work correctly is putting the code in every single Controller for every view! That actually works, which kind of confirms my theory.

But is there anywhere I can put this code without having to copy/paste it in every single Controller? Thanks in advance!

08 Feb
5 months ago

Shoken left a reply on Passing The Same Variables To Multiple Views Over And Over Again

@SNAPEY - This is probably a more elegant solution, thank you!

Shoken left a reply on Passing The Same Variables To Multiple Views Over And Over Again

@tomopongrac it works now! I made a mistake when calling for those variables.

Before, I returned the views with the method with(). That allowed me to call the variables directly with $categories and such.

Now I have to do $data['categories'] so it can work. My understanding is this has to do with the fact that I'm working with an array and no longer an object, but I might be wrong.

Anyway, in case anyone else needs this, I'm going to leave this here. :) Thanks for the help.

Shoken left a reply on Passing The Same Variables To Multiple Views Over And Over Again

@TOMOPONGRAC - I get a very long dump of the data in the DB. Not sure if I should post it all here, but here's a fraction of it for reference:

array:2 [ "main_menus" => Illuminate\Database\Eloquent\Collection {#170 #items: array:3 [ 0 => App\MainMenu {#171 #connection: "mysql" #table: "main_menus" #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: true +wasRecentlyCreated: false #attributes: array:6 [ "id" => 1 "created_at" => null "updated_at" => null "name" => "Homepage" "URL" => "/" "Order" => 1 ] #original: array:6 [ "id" => 1 "created_at" => null "updated_at" => null "name" => "Homepage" "URL" => "/" "Order" => 1 ]

.... etc...

Shoken left a reply on Passing The Same Variables To Multiple Views Over And Over Again

@TOMOPONGRAC - That seems exactly what I need, but I am a bit confused on the values of 'key' and 'value'. Now I wrote, in the class AppServiceProvider:

''' public function boot() {

    $menu = MainMenu::OrderBy('Order', 'asc')->get();
    $cat = Category::OrderBy('sortOrder', 'asc')->get();

    $data = array(
        'main_menus' => $menu,
        'categories' => $cat,

    View::share('data', $data);


But this does not seem to work, as categories is an undefined variable.

Shoken left a reply on Passing The Same Variables To Multiple Views Over And Over Again

@TOMOPONGRAC - Nevermind what I posted earlier -- it worked! Thank you so much. This framework is so efficient and clean.

Shoken left a reply on Passing The Same Variables To Multiple Views Over And Over Again

@TOMOPONGRAC - Thank you! This seems exactly what I need. I do feel a little confused on what 'key' and 'value' mean, though.

Should I put ('data', $data) in my case? Because that doesn't seem to work.

Shoken started a new conversation Passing Variables To The Same View Over And Over Again

Hey everyone, I've recently started using Laravel for a university project. It is AMAZING.

I have one issue I haven't been able to solve myself, though. Basically I have a main nav menu stored in the file main.blade.php.

This file is extended by all the other views, including "index.blade.php" and "about.index.php".

Now, when returing index through my FrontEndController, I just prepare an array of variables and return it with the view in order to dinamically generate my menus and categories. Basically my function looks like this:

''' public function index() { $menu = MainMenu::OrderBy('Order', 'asc')->get(); $cat = Category::OrderBy('sortOrder', 'asc')->get();

    $data = array(
        'main_menus' => $menu,
        'categories' => $cat,

    return view('front_end.index')->with($data);



Note that all these variables are used by the menu, not the content. Now I've started working on "about.index.php" and I noticed that I have to send the same $data array all over again in order to prepare the menu once more. So I basically need to send the same array over and over again for all the views.

This seems redundant and repetitive, and I feel like I am missing something. Is there a better way to do this?