ThibaudDauce

Experience

31,110

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 456 Lessons Completed
  • 0 Favorites

8th April, 2016

ThibaudDauce left a reply on PHPStorm And Laravel Functions • 10 months ago

It's weird because it seems that it was working before the last version…

ThibaudDauce left a reply on PHPStorm And Laravel Functions • 10 months ago

Thank you a lot, my vendor directory is not excluded and it is still not working after removing the .idea directory.

I will try to find another place to ask my questions, but since I know a lot of Laravel users are using helpers methods and PHPStorm I hoped to find someone with the same problem.

Thanks again!

7th April, 2016

ThibaudDauce left a reply on PHPStorm And Laravel Functions • 10 months ago

No I don't have to use the IDE Helper :-) I know how magic static call works and I know that it's not my problem here :-) The IDEA doesn't need help to go to the function (the ctrl-clic works) and the IDEA doesn't need help to look the dockblock to check the @return tag, nothing fancy here. The return tag is a simple class and the IDEA doesn't need help to go to the class since the ctrl-clic works too (the problem could be the pipe in some of Laravel docblocks to specify multiple return type but the flash() function from Laracasts have only one class in its return tag).

This is working:

$toto = test()->success('');

if ( ! function_exists('test')) {
    /**
     * @return \Laracasts\Flash\FlashNotifier
     */
    function test()
    {
    }
}

But not when the function is defined in a separate file load with composer. The question is why PHPStorm manage to navigate to that file when I ctrl-clic on the function, but the autocompletion from the return tag is not working…

5th April, 2016

ThibaudDauce left a reply on PHPStorm And Laravel Functions • 10 months ago

Everything is indexed. The only thing not working are the return classes from helpers' functions like route(), view() or flash(). But I can ctrl-clic on the function to go to the declaration and see the @return in the docblock, so PHPStorm know the function and know the return type but don't want to autocomplete after the flash()->…I also can ctrl-clic on the class in the `@retu declaration to go to the class and see the methods inside.

ThibaudDauce left a reply on PHPStorm And Laravel Functions • 10 months ago

I don't use all these call static and Facades things in Laravel because I don't like it :-)

My problem is on classic function with classic docblocks and a classic return class (there is no magic here)…

ThibaudDauce left a reply on PHPStorm And Laravel Functions • 10 months ago

I shouldn't have to use IDE Helper, flash() for instance is a simple function with great doc blocks

    /**
     * Arrange for a flash message.
     *
     * @param  string|null $message
     * @return \Laracasts\Flash\FlashNotifier
     */
    function flash($message = null)
    {
        $notifier = app('flash');

        if ( ! is_null($message)) {
            return $notifier->info($message);
        }

        return $notifier;
    }

PHPStorm can navigate to \Laracasts\Flash\FlashNotifier and see the success method inside… I don't understand why he put yellow under `flash()->success

4th April, 2016

ThibaudDauce started a new conversation PHPStorm And Laravel Functions • 10 months ago

Hi, Since the new version of PHPStorm, I have trouble using Laravel helpers. For example, PHPStorm can't find the method route() on the object returned by redirect():

<?php
return redirect()->route('home.index');

Idem with view()->with() or flash()->success() Do you have an idea how to fix this problem?

13th March, 2016

ThibaudDauce started a new conversation Get All Fields When Extending Validation • 11 months ago

Hi,

I want to build complex validation logic when extending the validator. For exemple I want to check if a value is present in my database if another field is equal to "foo". But in the documentation I can't find a way to get the other fields when validating a specific field:

Validator::extend('foo', function($attribute, $value, $parameters, $validator) {
            return $value == 'foo';
});

Do you have an idea to get all fields (all data) passed to the validator when checking a field? With the current implementation of extend method, it seems that it's impossible to build a custom "required_if" for example (need access to the other fields).

4th March, 2015

ThibaudDauce started a new conversation Test A Blade Template • 1 year ago

Hi,

I'm currently trying to test a Blade template but I don't know how to do that. I want to be sure that all the method calls on my object are corrects (no errors in Blade) and also that some information can be see in the HTML.

What can I do?

Thanks,

1st October, 2014

ThibaudDauce left a reply on Mac Doesn't Recognise Composer • 2 years ago

Did you run "composer install" in your project directory ?

ThibaudDauce left a reply on Business Logic And Models • 2 years ago

Hi @codeatbusiness

Thanks for your answer but I'm already using repositories :)

My problem is if I want to use another persistance "service" I will have to update all my objects and I don't want to. Single Responsibility Pattern told us that an object needs to have only one reason to change. I don't think my business logic object have to change if I change my database layout.

To improve my first example with an interface, I can do this:

<?php

interface SquareModelContract {

  public function getWidth();
}

class Square {

  protected $model;

  public function __construct(SquareModelContract $model) {
    $this->model = $model;
  }

  public function model() {
    return $this->model;
  }

  public function area() {
    return $this->model()->getWidth() * $this->model()->getWidth();
  }
}

One implementation with Eloquent:

<?php
class SquareModel extends Eloquent implements SquareModelContract {

  protected $table = 'squares';
  protected $fillable = ['width'];

  public function foo() {
    return $this->belongsTo('Foo');
  }

  public function getWidth() {
    return $this->width;
  }
}

One implementation with some king of storage:

<?php

class SquareModel extends FileORM implements SquareModelContract {

  protected $file = 'squares';
  protected $fields = ['width'];

  public function foo() {
    return $this->getRelationFromFile('Foo');
  }

  public function getWidth() {
    return $this->width;
  }
}

ThibaudDauce started a new conversation Business Logic And Models • 2 years ago

Hi,

How do you manage the separation between business logic methods and database relative methods (like relations)?

I was thinking about a business logic object construct with in parameter a database object. What do you think about it? (access the model like we access the presenter in laracasts/presenters). I'm afraid that it will be slow to build all business logic objects from a collection of models for example...

Example:

<?php

class Square {

  protected $model;

  public function __construct(SquareModel $model) {
    $this->model = $model;
  }

  public function model() {
    return $this->model;
  }

  public function area() {
    return $this->model()->width * $this->model()->with;
  }
}

class SquareModel extends Eloquent {

  protected $table = 'squares';
  protected $fillable = ['width'];

  public function foo() {
    return $this->belongsTo('Foo');
  } 
}

What do you think about this method? Do you have any other idea?

16th September, 2014

ThibaudDauce left a reply on Interfaces And Depedencies • 2 years ago

Thanks for your answer.

That was my first idea (add a interface for my models and leave it empty). I didn't think about checking the type in my repository, it's a good idea :)

But do you think I can do both, cast the Car interface and check if it's a good implementation ?

ThibaudDauce left a reply on Two Different User Classes? • 2 years ago

Yes, I had the same problem with my application.

I made a lot of work to have inheritance in Eloquent ORM on my github (https://github.com/ThibaudDauce/EloquentInheritanceStorage) but it didn't seem good enough for me. I tried to improve Single Table Inheritance pattern (look at it on google)

Today I'm working with two models (Student and Villager inherited from Customer) with one table thanks to my MoloquentInheritance package. Schemas (even if there is no schema in MongoDB) are a bit different for the two models and it works for authentification. You can try my solution if you want, there is no guarantee that it will work but it may give you some ideas.

ThibaudDauce started a new conversation Interfaces And Depedencies • 2 years ago

Hi,

I have a problem with repositories :(

Assume I have a EloquentCar model, I also have a CarRepository interface and one implementation: EloquentCarRepository that use my Eloquent Car model.

If I want to switch from Eloquent to an other ORM implementation like Mongo, I change my EloquentCar model in a MoloquentCar model. I need to build a new implementation of my CarRepository but I can't because in the interface I wrote:

<?php
    public function save(EloquentCar $car);

My goal is to have two interfaces: my Car and my CarRepository. And I want that each implementation comes with both classes (like EloquentCar and EloquentCarRepository or MoloquentCar and MoloquentCarRepository). But I can't figure out how...

Thanks for your help.

26th August, 2014

ThibaudDauce started a new conversation Namespace Order • 2 years ago

Hi,

Is it better to namespace like this: namespace Commands\Places; namespace Commands\Customers; namespace Repositories\Places; namespace Repositories\Customers;

Or like this: namespace Places\Commands; namespace Places\Repositories; namespace Customers\Commands; namespace Customers\Repositories;

I was wondering what was the pros and cons for each approach...

Thanks!

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.