El_Matella

El_Matella

Member Since 4 Years Ago

Lille

Student at Telecom Lille

Experience Points 19,470
Experience Level 4

530 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 106
Lessons
Completed
Best Reply Awards 13
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.

12 Dec
2 years ago

El_Matella left a reply on Laravel Passport, Multiple Connexions Via Password Client

Well, I think that the pull request was canceled.

What I do now, is that I create a new client for each used device. For example, when a new app tries to connect for the first time, I create a new Password Grant Client to handle Authentication.

Please someone tell me if I'm wrong...

07 Oct
2 years ago

El_Matella left a reply on Laravel Passport, Multiple Connexions Via Password Client

Taylor responded to me on Twitter about the issue and fixed it: https://github.com/laravel/passport/commit/b95791d42f42d405ffacdf21007f80ef7798b164

However, It seems that all of the passport users are not convinced by it, let's wait and see...

22 Sep
2 years ago

El_Matella left a reply on Laravel Passport, Multiple Connexions Via Password Client

@Prullenbak Yes, I could give a second password client for the iPad app, but the problem remains the same, if the user wants to use two iPads, this won't work anymore :/

09 Sep
3 years ago

El_Matella started a new conversation Laravel Passport, Multiple Connexions Via Password Client

Hi,

I am having troubles understanding how could I implement such a thing with Laravel Passport:

I have a mobile app, that needs to communicate with a Laravel based API. My users, at first launch of the app, will have to enter their login and password to get an access_token.

So I think that I need to put my client secret in the code of my mobile app to be able to request tokens. But what if, my user has an iPhone and an iPad and he wants to login from both.

I'm asking because every time I make a request to POST /oauth/token, from the same password_client, every access_token of a certain user requested with my password_client get revoked.

That would mean that, every time my user would use his iPad, he would be disconnected from his iPhone because the token wouldn't be valid anymore?

Am I missing something?

24 Jul
3 years ago

El_Matella left a reply on How To Execute An External Function In Laravel 5.2?

Did you check your config/app.php to see if you referenced your class as it should, in the two arrays for Service Provider and Facade?

23 Jul
3 years ago

El_Matella left a reply on How To Execute An External Function In Laravel 5.2?

Hi, I retested this exact Code on a test project and it works. Something I did wrong in my explanation with the directory of the Facade:

# app/Services/Payment/PaymentFacade.php not app/Services/OurService/OurServiceFacade.php

<?php
namespace App\Services\Payment;

use Illuminate\Support\Facades\Facade;

class PaymentFacade extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'Payment';
    }
}

Another thing if you use it in a controller, don't forget the use Payment; at the beginning of the file.

22 Jul
3 years ago

El_Matella left a reply on How To "from Table Where (x And Y) AND Z = S" In Laravel

In your last code, you wrote:

$tag_billnum = DB::table('bills')
            ->orWhere('billnum', 'LIKE', '%$search%');

You are using single quotes for '%$search%', is it normal? The $search variable won't be interpreted. Maybe you should use:

$tag_billnum = DB::table('bills')
            ->orWhere('billnum', 'LIKE', "%$search%");

Does your raw SQL query returns something when using same data as your code?

El_Matella left a reply on How To Execute An External Function In Laravel 5.2?

I think that you need to make a service:

# app/Services/Payment/Payment.php

<?php
namespace App\Services\Payment;

class Payment 
{
    public function billUser($cardnum, $mm, $yy, $cvc)
    {
        // Your logic here
    }
}

Then, if you want to integrate this Service "the Laravel way", you would need to create a Service Provider:

# app/Services/Payment/PaymentServiceProvider.php

<?php
namespace App\Services\Payment;

use Illuminate\Support\ServiceProvider;

class PaymentServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton('Payment', function($app) {
            return new Payment();
        });
    }
}

Then register this Service Provider in config/app.php:

return [

    ...

    'providers' => [

        ...

        App\Services\Payment\PaymentServiceProvider::class,

        ...

    ],

    ...

];

You can then access it in your controller:

<?php
namespace App\Http\Controllers;

public function completeRegistration(Request $request)
{
    $yy = $request->exp_year;
    $mm = $request->exp_month;
    $cardnum = $request->cardnum;
    $cvc = $request->cvc;

    if(app('Payment')->billUser($cardnum, $mm, $yy, $cvc))
    {
        echo "charge success";
    }
    else 
    {
        echo "uh something was wrong";
    }
}

You can then go further and create a Facade for your Service:

# app/Services/OurService/OurServiceFacade.php

<?php
namespace App\Services\Payment;

use Illuminate\Support\Facades\Facade;

class PaymentFacade extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'Payment';
    }
}

To use it, you also need to register it into your app/config.php file:

return [

    ...

    'aliases' => [

        ....

        'Payment' => App\Services\Payment\PaymentFacade::class,
    ],

];

And use it anywhere in your code:

<?php
namespace App\Http\Controllers;

use Payment;

public function completeRegistration(Request $request)
{
    $yy = $request->exp_year;
    $mm = $request->exp_month;
    $cardnum = $request->cardnum;
    $cvc = $request->cvc;

    if(Payment::billUser($cardnum, $mm, $yy, $cvc))
    {
        echo "charge success";
    }
    else 
    {
        echo "uh something was wrong";
    }
}

I hope this helps!

El_Matella started a new conversation Invalidating JWT For A User

Hi, I am using this package for my application: https://github.com/tymondesigns/jwt-auth

Everything works fine but I have some questions:

  • Can a user have multiples tokens? If he wants to use multiple devices simultaneously for example
  • If a User changes his credentials like his password, wouldn't it make sense to invalidate all active tokens for this User? Do you know if there is a way to do that with this package?

I ask the question here because I think that this package is quite known in the Laravel Comunity :)

Thanks a lot for your responses and have a good night!

16 May
3 years ago

El_Matella started a new conversation Built-in Remember Me Functionality Doesn't Work

Hi, I am having some problems getting the out of the box remember_me functionnality working on Laravel. I am using 5.2.

I think that I identified the problem, but I really don't know how to solve it. Basically, here is the output of dd($this->request->cookies->all()); in the SessionGuard.php file:

array:3 [
  "remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d" => null
  "XSRF-TOKEN" => null
  "laravel_session" => null
]

As you can see, all of my cookies are considered null, but in the Chrome Tab, they are not. So when the SessionGuard.php tries to call getRecaller(), the function returns null and the user is not logged in.

I searched over "the internet" and I figured out this was because of Encrypted Cookies, but I didn't find a lot more of information about that. How could I solve my problem? When I log out and login, it doesn't change the problem...

Thank you all for your help and have a nice day :)

26 Apr
3 years ago

El_Matella left a reply on Can Variable Be Classified In View?

Do you mean, ordered by the status? If so, you can do this in your controller:

    public function index()
    {
        $user=\Auth::user();
        $articles = $user->articles()->orderBy('status')->get();
        
        return view('user.dashboard.index',  compact('articles'));
    }
22 Apr
3 years ago

El_Matella left a reply on Strange Behaviour With File Upload

Hi, for the record or if anyone has the same problem, the solution was adding a headers: {'Content-Type': undefined} in my vue request...

21 Apr
3 years ago

El_Matella left a reply on Strange Behaviour With File Upload

Hi @jekinney thank you for your answer. I think I'm using the Javascript Form Class, here is my code:

updateAvatar() {
    var files = this.$els.avatar.files;
    var data = new FormData();
    data.append('avatar', files[0]);

    this.$http({
        url: 'me/avatar',
        method: 'PATCH',
        data: data
    }).then(function(response) {
        console.log('all good');
    }, function(response) {
        console.log('all bad');
    });
}

And here is the request being sent: https://sc-cdn.scaleengine.net/i/fd615420bca9795d901f71006f2ca803.png

20 Apr
3 years ago

El_Matella started a new conversation Strange Behaviour With File Upload

Hi, I am trying to build an avatar system but I am having some problems with file upload. It just doesn't detect the file in some case. Here is my controller:

public function avatar(Request $request)
{
    dd($request->hasFile('avatar'));
}

So, I am using postman to test this controller, and load a file. When I have the header Content-Type: multipart/form-data the controller returns false but when I delete this header, the controller returns true.

Of course, my application is using Vue and is using the Content-Type: multipart/form-dataso my Laravel server doesn't detect the file :/

What could I do? Thanks a lot for your answers!

EDIT: Here is my Vue Code, very simple using the Vue-Resource package:

updateAvatar() {
    var files = this.$els.avatar.files;
    var data = new FormData();
    data.append('avatar', files[0]);

    this.$http({
        url: 'me/avatar',
        method: 'PATCH',
        data: data
    }).then(function(response) {
        console.log('all good');
    }, function(response) {
        console.log('all bad');
    });
}

And here is a detail of the chrome network tab of the request I am sending to the server with this code: https://sc-cdn.scaleengine.net/i/fd615420bca9795d901f71006f2ca803.png

El_Matella left a reply on Why Eager Loads Makes Two Requests?

Thank you all for your very good answers and clear explanations, I get it now! Nice to know for the future and if I want to make my own ORM...

19 Apr
3 years ago

El_Matella started a new conversation Why Eager Loads Makes Two Requests?

Hi everyone. I was reading Laravel documentation on Eager Loading and I was wondering something. Here is the link of the paragraph I am talking about: https://laravel.com/docs/5.2/eloquent-relationships#eager-loading

More precisely, this extract:

$books = App\Book::with('author')->get();

foreach ($books as $book) {
    echo $book->author->name;
}

For this operation, only two queries will be executed:

select * from books

select * from authors where id in (1, 2, 3, 4, 5, ...)

So my question is: Why Eloquent does two requests for that type of operation and doesn't use an inner join to perform this? Is it better for performance? If yes, why? If not, why is it built like this?

Thanks a lot for your answers, and have a good night!

24 Mar
3 years ago

El_Matella left a reply on Token Based Authentication Video

Ok, thank you for your answers!

So for the moment, I'm going to use the generate token on login, destroy it on logout.

El_Matella started a new conversation Token Based Authentication Video

Hi everyone,

I've been watching the Token Based Authentication Video and I have some problems understanding if the out of the box api auth guard is really working (or finished?) like the session guard or if it is me.

First of all: Does the out of the box AuthController is supposed to work with the api auth guard? When I tried to use it, I got some attempt() method doesn't exist.

Second of all: How are we supposed to use this api guard? Let's imagine I want to build a single page app making requests against a Laravel backend. When am I supposed to generate the token for the user? Do I have to change the token some time? Is the token supposed to be stored on the client side to "remember him"?

Thanks a lot for your answers and have a very good day :)

PS: For the moment, I made a login method in a controller to handle login. This method returns api_token to the client. But I am kind of really sure that this is not best practice:

public function login(Request $request)
{
        $this->validate($request, [
            'email' => 'required', 'password' => 'required',
        ]);

        $user = User::where('email',$request->input('email'))->first();
        if(!password_verify($request->input('password'), $user->password)) {
            abort(401,'Bad Creditentials');
        }

        $user_array = $user->toArray();
        $user_array['api_token'] = $user->api_token;
        return $user_array;
}

I add the api_token in the $user_array at the end because I have the following in my User model:

protected $hidden = [
     'password', 'remember_token', 'api_token'
];
09 Mar
3 years ago

El_Matella left a reply on Prevent Using ->with() When Relationship Is Already Fetched

Maybe you should do the eager loading on the Post and not on the comments, like so:

$post = Post::with('comments')->find(1);

    foreach($post->comments as $comment) {
        echo $comment->text . ' on post ' . $post->name; 
    }

This should make a single query on the posts table

06 Mar
3 years ago

El_Matella left a reply on A Twitter Like Feed

Sorry to respond this late!

Your answer seems to be a very good option for me, I looked at the Polymorphic Relationships Documentation and it seems that I should be able to retrieve all the information I need. Thank you very much for the tip! I wasn't a big fan of mixing data that does not represented the same thing in a table. But with that actions table, it feels like it's right :)

04 Mar
3 years ago

El_Matella started a new conversation A Twitter Like Feed

Hi, I have some problem resolving an SQL request problem. And I wonder if that is even possible. Let's imagine a twitter user page. On that page, they are the tweets a user has posted, but also the tweets a user has retweeted. But not in the order of the initial tweet, but in the order of the tweet/retweet.

Let's take an example. Let's say, Bootstrap sends a tweet. After that, I tweet something. And after that, I retweet the Bootstrap tweet. My user profile will show the bootstrap tweet in first position, then my tweet. So the ordering of the tweets take in consideration the time of the retweet, not the time from the initial tweet. Otherwise, I would have my tweet in first position, and the bootstrap one in second position.

So I have three tables:

users:
    - id
    - username
tweets: 
   - id
   - user_id
   - content
   - timestamps
retweet_user:
   - tweet_id
   - user_id
   - timestamps

What happens, is that when a user tweets something, it doesn't have an entry in the "retweet_user" table, because it already has an entry on the tweet table (with user_id).

I managed to make this request, which lists the tweets that I want, but not in the regular order obviously:

$tweets = Tweet::with('user')
    ->where('user_id',$user->id)
    ->orWhereHas('retweeters', function($query) use($user) {
        $query->where('id',$user->id);
    })->orderBy('id','desc')->get();

So here are the two solutions I found for my problem:

  • The easy one: When a user tweets, an entry is also made in the retweet_table, and I juste have to sort the results by the timestamp of this table.
  • The one I would like to do: Order the results by a virtual field called "time" for example. If the result is from the first where('user_id',$user->id'), it stores the created_at from the tweets table. If the result is from the orWhereHas(...), it stores the value of the created_at from the pivot table. I just would have to orderBy this virtual field, and it would work! Is this possible?

Thanks for the advices, and let me know if I was not clear in my explanations,

Many thanks! :)

El_Matella left a reply on CSS On The Site

I was not a big fan of the black either, but now, with the nice background image, it looks nice :)

El_Matella left a reply on Blade If Else On Single Line

I think that you could try:

{{ $var === "hello" ? "Hi" : "Goodbye" }}

El_Matella left a reply on How To Authenticate With Credentials And Get The User?

Isn't it like a middleware problem accessing the route directly? Like the CSRF token or so?

El_Matella left a reply on URI To Follow A User

Thanks to both of you for the answers!

@ohffs, I don't feel very confident about creating a complete new follower resource, as I don't think that it is that important in my application.

@martinbean , I like your way of doing it, I think that I might use this. So the pattern would be:

POST /users/{user}/follow
POST /users/{user}/unfollow
GET /users/{user}/followers

El_Matella started a new conversation URI To Follow A User

Hi, I am building a small system of users, and I would like my users to be able to "follow" other users.

But I am kind of stuck with how to choose a good URI for that action. Right now, I would turn for:

POST /users/{user}/followers to follow a user
DELETE /users/{user}/followers to unfollow a user
GET /users/{user}/followers to get the followers of the user (obviously)

What do you think about that?

I accept any kind of Advice/Notice/Insult

Thank you, and have a nice day :)

02 Mar
3 years ago

El_Matella left a reply on Vue Instances Organization

Thanks for the answer and the components advice tip!

I'm now using the following structure:

  • Vue Instance is bounded to the body tag. In my article template I created a global component, which can register local components. I didn't registered the global component into the vue instance because the templates and data associated with the component and the variables are not always present.

Anyway, thanks again for the tip and have a nice day!

01 Mar
3 years ago

El_Matella started a new conversation Vue Instances Organization

Hi,

I am having some organizations concerns about the use of Vue.js and Laravel. I don't understand how I am suppose to declare my Vue instances, in a general template file, and then in my extended templates files.

Here is an example of a "general template file":

<!DOCTYPE html>
<html>
<head>
    <title>My title</title>
</head>
<body>
<nav>
    <ul>
        <li v-for="item in navbarItems">@{{ item }}</li>
    </ul>
</nav>
@yield('content')
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.17/vue.min.js"></script>
<script type="text/javascript">
    var vueFirstInstance = new Vue({
        el: 'nav',
        data: {
            navbarItems: ['item1','item2','item3']
        }
    });
</script>
@yield('javascript')
</body>
</html>

As you can see here, I'm using Vue to generate a navigation list.

But then I would like tu use Vue in an other blade template to display an article for example:

@extends('layouts.app')

@section('content')
<article>
    <h1>@{{ article.title }}</h1>
    <p>@{{ article.content }}</p>
</article>
@endsection

@section('javascript')
<script type="text/javascript">
    var secondVueInstance = new Vue({
        el: 'article',
        data: {
            article: {
                title: 'A fake title',
                content: 'Lorem Ipsum Dolor'
            }
        }
    });
</script>
@endsection

So now, I have 2 Vue instances... It works, but I don't feel very confident about that, is this the proper use of the library or should I organize me differently?

Thanks for the advices and have a good day :)

29 Feb
3 years ago

El_Matella left a reply on Convert HTTP To HTTPS In Url()

Indeed, when I switched to https, I didn't had to make any change in my code and the url function just followed

El_Matella left a reply on Common Question About Laravel ?

Hi, you should check at this package and website, they have a lot of tutorials and documentation about how to make DataTable work with Laravel Server-Side implementation: http://datatables.yajrabox.com/

Good luck!

23 Feb
3 years ago

El_Matella left a reply on Getting Custom Attribute Of Model Tru Ajax Request

Hi, You need to use the $appends property on your model. In User.php:

protected $appends = ['full_name'];

Here is the doc for that: https://laravel.com/docs/5.2/eloquent-serialization#appending-values-to-json

Hope it helps

22 Feb
3 years ago

El_Matella started a new conversation Lumen Installer Bug?

Hi, I am having a problem trying to install the lumen installer on my El Capitan computer. This is the command line I launch:

composer global require "laravel/lumen-installer"

I also tried it as sudo but it gives me the following error:

Your requirements could not be resolved to an installable set of packages.

Here is the complete output of the command:

Changed current directory to /Users/mmarteau/.composer
Using version ^1.0 for laravel/lumen-installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel/lumen-installer v1.0.1
    - Conclusion: remove symfony/process v3.0.1
    - Installation request for laravel/lumen-installer ^1.0 -> satisfiable by laravel/lumen-installer[v1.0.0, v1.0.1].
    - Conclusion: don't install symfony/process v3.0.1
    - laravel/lumen-installer v1.0.0 requires symfony/process ~2.3 -> satisfiable by symfony/process[v2.3.0, v2.3.1, v2.3.10, v2.3.11, v2.3.12, v2.3.13, v2.3.14, v2.3.15, v2.3.16, v2.3.17, v2.3.18, v2.3.19, v2.3.2, v2.3.20, v2.3.21, v2.3.22, v2.3.23, v2.3.24, v2.3.25, v2.3.26, v2.3.27, v2.3.28, v2.3.29, v2.3.3, v2.3.30, v2.3.31, v2.3.32, v2.3.33, v2.3.34, v2.3.35, v2.3.36, v2.3.37, v2.3.4, v2.3.5, v2.3.6, v2.3.7, v2.3.8, v2.3.9, v2.4.0, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.5.0, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.2].
    - Can only install one of: symfony/process[v2.3.0, v3.0.1].
    - Can only install one of: symfony/process[v2.3.1, v3.0.1].
    - Can only install one of: symfony/process[v2.3.10, v3.0.1].
    - Can only install one of: symfony/process[v2.3.11, v3.0.1].
    - Can only install one of: symfony/process[v2.3.12, v3.0.1].
    - Can only install one of: symfony/process[v2.3.13, v3.0.1].
    - Can only install one of: symfony/process[v2.3.14, v3.0.1].
    - Can only install one of: symfony/process[v2.3.15, v3.0.1].
    - Can only install one of: symfony/process[v2.3.16, v3.0.1].
    - Can only install one of: symfony/process[v2.3.17, v3.0.1].
    - Can only install one of: symfony/process[v2.3.18, v3.0.1].
    - Can only install one of: symfony/process[v2.3.19, v3.0.1].
    - Can only install one of: symfony/process[v2.3.2, v3.0.1].
    - Can only install one of: symfony/process[v2.3.20, v3.0.1].
    - Can only install one of: symfony/process[v2.3.21, v3.0.1].
    - Can only install one of: symfony/process[v2.3.22, v3.0.1].
    - Can only install one of: symfony/process[v2.3.23, v3.0.1].
    - Can only install one of: symfony/process[v2.3.24, v3.0.1].
    - Can only install one of: symfony/process[v2.3.25, v3.0.1].
    - Can only install one of: symfony/process[v2.3.26, v3.0.1].
    - Can only install one of: symfony/process[v2.3.27, v3.0.1].
    - Can only install one of: symfony/process[v2.3.28, v3.0.1].
    - Can only install one of: symfony/process[v2.3.29, v3.0.1].
    - Can only install one of: symfony/process[v2.3.3, v3.0.1].
    - Can only install one of: symfony/process[v2.3.30, v3.0.1].
    - Can only install one of: symfony/process[v2.3.31, v3.0.1].
    - Can only install one of: symfony/process[v2.3.32, v3.0.1].
    - Can only install one of: symfony/process[v2.3.33, v3.0.1].
    - Can only install one of: symfony/process[v2.3.34, v3.0.1].
    - Can only install one of: symfony/process[v2.3.35, v3.0.1].
    - Can only install one of: symfony/process[v2.3.36, v3.0.1].
    - Can only install one of: symfony/process[v2.3.37, v3.0.1].
    - Can only install one of: symfony/process[v2.3.4, v3.0.1].
    - Can only install one of: symfony/process[v2.3.5, v3.0.1].
    - Can only install one of: symfony/process[v2.3.6, v3.0.1].
    - Can only install one of: symfony/process[v2.3.7, v3.0.1].
    - Can only install one of: symfony/process[v2.3.8, v3.0.1].
    - Can only install one of: symfony/process[v2.3.9, v3.0.1].
    - Can only install one of: symfony/process[v2.4.0, v3.0.1].
    - Can only install one of: symfony/process[v2.4.1, v3.0.1].
    - Can only install one of: symfony/process[v2.4.10, v3.0.1].
    - Can only install one of: symfony/process[v2.4.2, v3.0.1].
    - Can only install one of: symfony/process[v2.4.3, v3.0.1].
    - Can only install one of: symfony/process[v2.4.4, v3.0.1].
    - Can only install one of: symfony/process[v2.4.5, v3.0.1].
    - Can only install one of: symfony/process[v2.4.6, v3.0.1].
    - Can only install one of: symfony/process[v2.4.7, v3.0.1].
    - Can only install one of: symfony/process[v2.4.8, v3.0.1].
    - Can only install one of: symfony/process[v2.4.9, v3.0.1].
    - Can only install one of: symfony/process[v2.5.0, v3.0.1].
    - Can only install one of: symfony/process[v2.5.1, v3.0.1].
    - Can only install one of: symfony/process[v2.5.10, v3.0.1].
    - Can only install one of: symfony/process[v2.5.11, v3.0.1].
    - Can only install one of: symfony/process[v2.5.12, v3.0.1].
    - Can only install one of: symfony/process[v2.5.2, v3.0.1].
    - Can only install one of: symfony/process[v2.5.3, v3.0.1].
    - Can only install one of: symfony/process[v2.5.4, v3.0.1].
    - Can only install one of: symfony/process[v2.5.5, v3.0.1].
    - Can only install one of: symfony/process[v2.5.6, v3.0.1].
    - Can only install one of: symfony/process[v2.5.7, v3.0.1].
    - Can only install one of: symfony/process[v2.5.8, v3.0.1].
    - Can only install one of: symfony/process[v2.5.9, v3.0.1].
    - Can only install one of: symfony/process[v2.6.0, v3.0.1].
    - Can only install one of: symfony/process[v2.6.1, v3.0.1].
    - Can only install one of: symfony/process[v2.6.10, v3.0.1].
    - Can only install one of: symfony/process[v2.6.11, v3.0.1].
    - Can only install one of: symfony/process[v2.6.12, v3.0.1].
    - Can only install one of: symfony/process[v2.6.13, v3.0.1].
    - Can only install one of: symfony/process[v2.6.2, v3.0.1].
    - Can only install one of: symfony/process[v2.6.3, v3.0.1].
    - Can only install one of: symfony/process[v2.6.4, v3.0.1].
    - Can only install one of: symfony/process[v2.6.5, v3.0.1].
    - Can only install one of: symfony/process[v2.6.6, v3.0.1].
    - Can only install one of: symfony/process[v2.6.7, v3.0.1].
    - Can only install one of: symfony/process[v2.6.8, v3.0.1].
    - Can only install one of: symfony/process[v2.6.9, v3.0.1].
    - Can only install one of: symfony/process[v2.7.0, v3.0.1].
    - Can only install one of: symfony/process[v2.7.1, v3.0.1].
    - Can only install one of: symfony/process[v2.7.2, v3.0.1].
    - Can only install one of: symfony/process[v2.7.3, v3.0.1].
    - Can only install one of: symfony/process[v2.7.4, v3.0.1].
    - Can only install one of: symfony/process[v2.7.5, v3.0.1].
    - Can only install one of: symfony/process[v2.7.6, v3.0.1].
    - Can only install one of: symfony/process[v2.7.7, v3.0.1].
    - Can only install one of: symfony/process[v2.7.8, v3.0.1].
    - Can only install one of: symfony/process[v2.7.9, v3.0.1].
    - Can only install one of: symfony/process[v2.8.0, v3.0.1].
    - Can only install one of: symfony/process[v2.8.1, v3.0.1].
    - Can only install one of: symfony/process[v2.8.2, v3.0.1].
    - Installation request for symfony/process == 3.0.1.0 -> satisfiable by symfony/process[v3.0.1].


Installation failed, reverting ./composer.json to its original content.

I Googled it a little and self updated composer but nothing changes, if someone can help, it would be super :)

Have a good night everyone

18 Feb
3 years ago

El_Matella left a reply on Homestead/Laravel 5.2 - $path

Hi, did you try this laravel new command within the VM with homestead ssh ? If yes, I don't think that this is what you should do, you should use the laravel new command from your host machine (your mac), and the folders will sync later with homestead...

However, if you still want to use the command within the VM, you should also add the ~/.composer/vendor/bin to your VM path :/

14 Feb
3 years ago

El_Matella left a reply on How To Run Method Of Component ?

Ho okay sorry I didn't understood well your request. I think I got it... My mistake, you need to use the created hook as you did at first place. This works:

<div id="General">
  <my-component></my-component>
</div>

<template id="template">
  Hello World
</template>
Vue.component('my-component',{
    template: '#template',
  created: function() {
    window.componentInstance = this;
  },
  methods: {
    componentMethod: function() {
        alert('this is the component method alert');
    }
  }
});

new Vue({
    el: '#General'
});

componentInstance.componentMethod();

I made a small jsfiddle to try it: https://jsfiddle.net/8ndk3w8z/

El_Matella left a reply on How To Run Method Of Component ?

Outside of what?

El_Matella left a reply on How To Run Method Of Component ?

You should try to do it by adding a ready part to your component:

Vue.component('docs', {
  template: '#docs-template',
  props: ['gbo_kit_id', 'token'],
  data: function () {
    return {
      list: []
    }
  },
  methods: {
    fetchDocList: function () {
      var resource = this.$resource('/admin/gbo_kits/{gbo_kit_id}/docs/{id}');
      resource.get({gbo_kit_id: this.gbo_kit_id}).then(function (response) {
        this.$set('list', response.data.docs)
      });
    }
  },
  ready: function() {
    this.fetchDocList();
  }
});

El_Matella left a reply on Load An External Page In A Div

Hi, you should look at the Vue Resource package here: https://github.com/vuejs/vue-resource Jeffrey made a video about it here: https://laracasts.com/series/learning-vue-step-by-step/episodes/11

Hope it helps!

13 Feb
3 years ago

El_Matella left a reply on Column Indexing

Don't you want to create foreign keys?

$table->integer('country_id')->unsigned();
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
$table->integer('city_id')->unsigned();
$table->foreign('city_id')->references('id')->on('cities')->onDelete('cascade');
11 Feb
3 years ago

El_Matella left a reply on Angular - Laravel API - How To Organize URLs

Hi everyone, thank you for all your answers! @willvincent : Thank you for the links, I am going to read them all, this scotch.io website is full of great resources about this subject! @mehany : Thank you for the code, it helps a lot and I think that you have the best answer of this topic... However, I am not even going to use the same server to store the angular application and the laravel API so I don't even need to create this partials route, but I can now see the general organization. Thanks a lot!

Have a nice day everybody :)

08 Feb
3 years ago

El_Matella left a reply on Angular - Laravel API - How To Organize URLs

Hi @martinbean , thank you for your answer and for the lumen tip, I am going to dive into that.

I am still wondering how could I organize my URLs tho, question still opened :)

07 Feb
3 years ago

El_Matella left a reply on Passing Data From Laravel Blade To Vue.js

Hi,

In order to pass Laravel variables to your views, you can use the JavaScript package: https://github.com/laracasts/PHP-Vars-To-Js-Transformer

And then, you can do this in your controller:

JavaScript::put([
        'user' => User::first()
 ]);

And use it in your vue instance:

// You now have a javascript user var:
console.log(user);
new Vue({
    el: '#app',
    data: {
        user: user 
    }
});

Hope it helps!

El_Matella started a new conversation Angular - Laravel API - How To Organize URLs

Hello!

I would like to train me to make an e-commerce website using Laravel for Back-end and Angular JS for Front-end.

For the moment, my goal is to build a Laravel API communicating with an Angular JS front-end (I am not going to use Laravel views, I want the two technologies completely separate.)

But I don't know really how to organize URLs.

For example, I want my products URLs to follow this rule: my-ecommerce.com/category/product-slug .

But should my Laravel API follow the same rules as the front-end? In other words, should this front-end URL communication with api.mybackend.com/category/product-slug or api.mybackend.com/products/{id} ?

And if it is the second solution, how should I retrieve my product ID? This solution would imply a second Ajax request to retrieve the ID, am I wrong?

If someone knows about that or articles talking about the subject, I would love to see that :)

Have a good night, and thank you for your answers and advices!

13 Jan
3 years ago

El_Matella left a reply on Playing Around With Vue And Select2

The problem with the "ready lifecycle" is that if I load new data via Ajax, my selects won't work anymore, am I wrong?

El_Matella left a reply on Checkboxes And V-model

Thanks a lot @FourStacks and @harg for your tips and information, it helps a lot, have a very nice day :)

El_Matella left a reply on Checkboxes And V-model

@FourStacks thanks a lot for the demo, it helps a lot, and it behaves exactly like I would like it to behave :) !

I think I missed something during the Vue courses. Is the isSelected() method reloaded each time this.selectedProducts changes? I thought that this behavior was only for computed properties, that's why I placed it there at the beginning.

@harg I thought about this solution at the beginning too, but the thing is, I load my products from an API with ajax, and I didn't know how to add a property.. Thanks for the help anyway!

El_Matella started a new conversation Checkboxes And V-model

Hi, I am trying to make a small script using Vue, but I am having some problems.

First, here is a jsFiddle that shows my problem: https://jsfiddle.net/El_Matella/s2u8syb3/

Now, basically, I want to use a computed property on a checkbox. So for the moment I have:

<input v-model="isSelected(product)" v-on:click="toggleProduct(product)" type="checkbox">

Here is my computed isSelected function:

compute: {
    isSelected: function(product){
        for(var i = 0; i < this.selectedProducts.length; i++){
        if(this.selectedProducts[i].id == product.id) {
          return true;
        }
      }
      return false;
    }
  }

Here is my toggleProduct function:

methods: {
    toggleProduct: function(product){
        for(var i = 0; i < this.selectedProducts.length; i++){
        if(this.selectedProducts[i].id == product.id) {
          this.selectedProducts.splice(i,1);
          return true;
        }
      }
      this.selectedProducts.push(product);
    }
  },

And here is my example data:

data: {
    products:[{id:1},{id:2}],
    selectedProducts:[]
  },

The goal is to make a selection module, and selectedProducts should contain the products that have been selected. But the checkbox logic doesn't work.

Don't hesitate to tell me if the jsfiddle or the question is not enough clear, I will try to reformulate it,

Thanks for the help and have a nice day!

11 Jan
3 years ago

El_Matella started a new conversation Playing Around With Vue And Select2

Hi everyone,

For those who don't like to read, I created a small jsFiddle for this question: https://jsfiddle.net/El_Matella/u5uwsxj5/

I am working on a small Vue project, and I am having some trubles working with Vue and Select2.

The problem I have right now is that I cannot succeed in putting the default value at the beginning:

Here is my HTML code:

<div id="general">
  <table>
    <tr v-for="product in products">
      <td>{{ product.id }}</td>
      <td>
        <select v-select="categorie" v-model="product.categorie.id">
          <option v-for="categorie in categories" v-bind:value="categorie.id">
            {{ categorie.name }}
          </option>
        </select>
      </td>
    </tr>
  </table>
</div>

As you can see, I am trying to list some products in a table. And I would like to put a select2 field in one cell, displaying the right default value for every product.

Here is the main Vue code:

new Vue({
    el: '#general',
  data: {
    products: [
        {
        id: 1,
        name: 'First Product',
        categorie: {
          id: 1,
          name: 'First Category'
        }
      },
      {
        id: 2,
        name: 'Second Product',
        categorie: {
            id: 2,
          name: 'Second Category'
        }
      }
    ],
    categories: [
        {
        id: 1,
        name: 'First Category'
      },
      {
        id: 2,
        name: 'Second Category'
      }
    ]
  }
});

In this code, there is 2 products belonging to a different category. And there is also a listing of all the categories existing.

I also tried to create a small custom Directive:

Vue.directive('select', {
  bind: function () {
    $(this.el).select2();
  },
  update: function (newValue, oldValue) {
    // do something based on the updated value
    // this will also be called for the initial value
  },
  unbind: function () {
    // do clean up work
    // e.g. remove event listeners added in bind()
  }
})

Here, I just use "bind" and I stopped here because I am not getting the result I want.

So how could I fix this issue? Thanks a lot for the help and don't hesitate to tell me that my question is bad, I will try to refactor it :)

Have a nice week, and thanks for the answers!

09 Dec
3 years ago

El_Matella left a reply on Update/Create All In One

You could try something like

$i = 0;
// Update existing prices
foreach($product->prices as $price){
    $price = $data['prices'][$i];
    $price->save();
    $i++;
}
// Add new ones
$newprices = [];
for($j = $i; $j < count($data['prices']); $j++){
    $newprices = new Price($data['prices'][$j]);
}
$product->prices()->saveMany($newprices);

I think that should work. But you may encounter problems and adapt the code if your $data['prices'] has less items than your $product->prices collection

22 Nov
3 years ago

El_Matella left a reply on Development Environment On Windows

@Nick385 thanks for the video, I used Git Bash as the video and it works...

Still doesn't know why it doesn't work with cmder...

Thanks anyway!