dimanche 28 août 2016

laravel 5.3 new Auth::routes()

Recently I start to use laravel 5.3 to write a blog, but I have a question after run php artisan make:auth

when I run this, it will generate routes in my web.php

this is the code in it:

Auth::routes();

Route::get('/home', 'HomeController@index');

Then I run php artisan route:list, I find lots of actions, like LoginController@login...

But I didn't find these actions in my App\Http\Controllers\Auth, where are these?

And also what is the Auth::routes() stand for, I can't find the routes about Auth.

I need someone help, thank you to answer my question



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2c7lOIm
via IFTTT

Laravel: Uploadify request to uploadify.swf issue

I am trying to add uploadify to Laravel 5. When I load my page, it sends a request to URL myBaseUrl/controller/uploadify.swf to which I get response of method not allowed Exception. I am not sure what to do and how to proceed.

Routes

Route::post('/products/upload','productsController@upload');

Uploadify call

<script type="text/javascript">
    <?php $timestamp = time();?>
    $(function() {
        $('#file_upload').uploadify({
            'formData'     : {
                'timestamp' : '<?php echo $timestamp;?>',
                '_token': $('#_token').val()
            },
            'preventCaching' : false,
            'swf'      : 'uploadify.swf',
            'uploader' : 'BaseUrl/products/upload'
        });
    });
</script>

Please guide. Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2bugIlm
via IFTTT

error while trying to run artisan command with Artisan Facade

here's the code

Route::get('run-cmd', function() {
    Artisan::call('make:controller HelloController');
});

and I wonder I'm getting this error...

InvalidArgumentException in Application.php line 549:
Command "make:controller HelloController" is not defined.
Did you mean one of these?
make:migration
make:controller
make:middleware
make:request
make:provider
make:console
make:event
make:model
make:command

what's wrong?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2c73CPe
via IFTTT

EAV is 'bad', so I need hundreds of tables?

I'm building a product catalog with hundreds of different product types. These product types have a lot of different attributes. Some are shared, but most are specific for the product type.

My initial thought was to go with an EAV-type structure, but I understand why that might be a bad choice. Especially since I want my database to enforce correctness and consistency, which is going to be a mess with EAV.

The alternative in my case would be class table inheritance. I'm a bit worried about the maintainability though... how am I going to maintain hundreds of migrations and models? Is that really a desirable situation? I understand the benefits, but isn't maintainability a huge downside?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2bu9XQC
via IFTTT

Call to undefined method Illuminate\Auth\TokenGuard::login()

I try to register a new user to my app using only JSON and api guard with token driver. I got this strange error :

FatalThrowableError in RegistersUsers.php line 32:
Call to undefined method Illuminate\Auth\TokenGuard::login()
in RegistersUsers.php line 32
at RegisterController->register(object(Request))
at call_user_func_array(array(object(RegisterController), 'register'), array(object(Request))) in Controller.php line 55
at Controller->callAction('register', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(RegisterController), 'register') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 642
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in RedirectIfAuthenticated.php line 24
at RedirectIfAuthenticated->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2brLvlw
via IFTTT

Eloquent ORM returns null using with() eager load

When using Eloquent's with() the eager loaded data sometimes becomes null. In my case, I have three tables, Users, Blogposts and Categories. The blogposts table has two foreign keys, called author and category. The query performed is given by

return Blogpost::with(['author', 'category'])->get();

The response is, well, odd. Note that author becomes null from id: 3 and category from id: 4.

In reality both the ids 1, 3 have the same author (superuser) as do the ids 2, 4 (steve). Also id 1, 4 have the same category (web dev).

It seems as if a/an category/author is already retrived and bounded to a blogpost the past categories/authors becomes null.

[
  {
    id: 4,
    author: null,
    image_name: "banner1.png",
    category: null,
    intro: "Hello World!",
  },

  {
    id: 3,
    author: null,
    image_name: "banner1.png",
    category: {
        id: 3,
        name: "big data",
    },
    intro: "Hello World!",
  },

  {
    id: 2,
    author: {
        id: 2,
        email: "foo@foo.foo",
        fullname: "foo foo",
        is_admin: false,
    },
    image_name: "banner1.png",
    category: {
        id: 2,
        name: "science",
    },
    intro: "Hello World!",
  },

  {
    id: 1,
    author: {
        id: 1,
        email: "superuser@superuser.com",
        fullname: "superuser superuser",
        is_admin: true,
    },
    image_name: "banner1.png",
    category: {
        id: 1,
        name: "web dev",
    },
    intro: "Hello World!",
  }
]

Finally here are the relations defined in the models

// User model
public function blogposts() {
    return $this->hasMany('App\Blogpost', 'id');
}

// Blogpost model
public function author() {
  return $this->belongsTo('App\User', 'id');
}

public function category() {
  return $this->belongsTo('App\Category', 'id');
}

// Category model
public function blogposts() {
  return $this->hasMany('App\Blogpost', 'id');
}

Is there any explanation to this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2bYZq1b
via IFTTT

How can I get sessions created earlier in laravel

I need to sort my sessions by created earlier in Laravel, And I don't use session table. To do this you have any suggestions? I don't know by filename or any ? thanks all and sorry for my terrible English grammer.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2bJK9jH
via IFTTT