commandantp

commandantp

Member Since 4 Years Ago

paris

Experience Points 5,290
Experience Level 2

4,710 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 13
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.

22 Mar
2 years ago

commandantp left a reply on All CURL Calls Fail With Error 6: Could Not Resolve Host - Suddenly On Production Server Only

@pspwebtech Thanks man! It fixed the problem! Any way we can prevent having to do that everytime / discovering it too late?

21 Mar
2 years ago

commandantp started a new conversation All CURL Calls Fail With Error 6: Could Not Resolve Host - Suddenly On Production Server Only

Hey guys, Thanks for reading. All the cURL call are failing on my production server but none on test/staging servers. At first I thought it was something with Socialite but now even the Send Mail doesn't work. Here is an example of the errors I get:

Error executing "SendRawEmail" on "https://email.eu-west-1.amazonaws.com"; AWS HTTP error: cURL error 6: Could not resolve host: email.eu-west-1.amazonaws.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html

Same problem with facebook.com / google.com / stripe.com .... Any idea on what I could check / what could go wrong ? I've been browsing around looking for an answer with no success :(

Thanks a lot!

09 Feb
2 years ago
05 Feb
2 years ago

commandantp left a reply on Last SSL Update On Forge Crashes My Config

Anyone can help guys? Still stuck :/

04 Feb
2 years ago

commandantp started a new conversation Last SSL Update On Forge Crashes My Config

Hey guys. I had to update the SSL on the server, which I did. But since then the redirect that I had doesn't work anymore. Not sure what's happening... If I leave the old nginx config neither blog nor site is available.

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/go.com/before/*;

server {
    listen 443 ssl;
    server_name .go.com;
    
    location /blog/ {
        #return 301 http://blog.go.com;
        proxy_set_header X-Original-Host $host;
        proxy_set_header X-Is-Reverse-Proxy "true";
        proxy_pass_header Set-Cookie;
        proxy_cookie_path / /blog/;
        proxy_pass http://blog.go.com/;
        expires off;
    }
    
    # location /wp-admin/ {
    #     return 301 http://go.com/blog$request_uri;
    # }

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/go.com/server/*;

    location / {
        return 301 https://go.com$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name .go.com;
    root /home/forge/go.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/go.com/166494/server.crt;
    ssl_certificate_key /etc/nginx/ssl/go.com/166494/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;
            
    location /blog {
        return 301 http://go.com$request_uri;
    }
    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/go.com/server/*;
[etc...]

If I modify to the following I can access site but the blog is still not working

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/go.com/before/*;

server {
    listen 80;
    server_name .go.com;
    
    location /blog/ {
        #return 301 http://blog.go.com;
        proxy_set_header X-Original-Host $host;
        proxy_set_header X-Is-Reverse-Proxy "true";
        proxy_pass_header Set-Cookie;
        proxy_cookie_path / /blog/;
        proxy_pass http://blog.go.com/;
        expires off;
        # return 301 http://go.com$request_uri;
    }
    
    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/go.com/server/*;

    location / {
        return 301 https://go.com$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name .go.com;
    root /home/forge/go.com/public;
    
    location /blog/ {
        return 301 http://go.com$request_uri;
    }

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/go.com/166494/server.crt;
    ssl_certificate_key /etc/nginx/ssl/go.com/166494/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;
            
    include forge-conf/go.com/server/*;

Any idea? Thanks!!!

25 Jul
3 years ago

commandantp left a reply on Forge - PHP7 Update

Any update?

11 May
3 years ago

commandantp left a reply on Monitoring Tab Removed?

Damn I just noticed here too. It's not very nice to remove it without any notice to clients... Any backup solutions to add PaperTrail?

26 Feb
3 years ago

commandantp left a reply on Redirect Blog.mysite.com To Mysite.com/blog

Thanks @willvincent Indeed just tried reverse proxying and it works. Now I'm confused because I think cookies got lost on the way or someone ate them ! In Nginx I have the following config in a server block.

Everthing works except the cookies for the WP Admin panel don't get passed through so I can't login in.

What should I add?

 location /blog/ {
  proxy_set_header X-Original-Host $host;
  proxy_set_header X-Is-Reverse-Proxy "true";
  proxy_pass_header Set-Cookie;
  proxy_cookie_path / /blog/;
  proxy_pass http://blog.example.com/;
}

Thanks!

23 Feb
3 years ago

commandantp started a new conversation Redirect Blog.mysite.com To Mysite.com/blog

Hi guys,

Struggling here. I have a site.com with a blog.site.com. I would like to use instead site.com/blog . However site.com and blog.site.com are on different servers and I cannot move the folder located in blog.site.com in the site.com server.

The blog in wordpress and server is Apache The site is Laravel and nginx server handled with Forge.

How can I achieve it and also not have Laravel start for the site.com/blog/ ?

Thank you so much!!

21 Feb
3 years ago

commandantp started a new conversation Many To Many Softdelete & Count?

Hi,

Running in an issue here. Take the Post, Comments example. I have a soft delete for the comments.

When a comment is deleted then the deleted_at is updated.

The problem: All the comments have been soft deleted, now when I do a Post::find(1)->comments()->exists() it will return true even if all the comments have been soft deleted. Same a ->count() will return 1 and when I check what is returned it returns the last one entered. However it only returns the last one and not the previous one.

Any idea what is happening and/or how to solve this? I cannot use detach() because we need to keep an history.

Thanks!

commandantp left a reply on Softdelete On ManyToMany Polymorphic Relations.

Hi @exonet Did you solve that?

Thanks.

18 Jan
3 years ago

commandantp started a new conversation Make Blade Run Through .vue On Build?

Would that be possible? Have Blade process the .vue files before ? Would be nicer to access data.

commandantp left a reply on Vue.js Acces Parent Methods

@belisar do you know if the disptach event can return a promise? It would be great to have $dispatch().then(do ...) ?

Thanks!

17 Jan
3 years ago

commandantp left a reply on Failed To Resolve Directive: Link & Unknown Custom Element: <router-view>

Make sure you don't already load vue somewhere else if you see that message....

16 Jan
3 years ago

commandantp left a reply on Use Parent Component's Method

Also, Trying: @click.prevent="this.$parent.$options.methods.getNextStep('login')" Works but returns the message currentStep is not defined. Tried adding it in the props of Start.vue but it won't change anything.

Thanks... :-)

commandantp started a new conversation Use Parent Component's Method

Hi,

I've looked around to find something that works but didn't so far. The closest topic: https://laracasts.com/discuss/channels/general-discussion/vuejs-acces-parent-methods

So Here it is: I have:

  • app.blade.php
  • View.vue < is in the main app
  • Start.vue < is in View.vue

In View.vue:

<template>
    <onboarding-content :is="currentStep"></onboarding-content>
</template>

<script>

import Start from './onboarding/steps/Start.vue';
import Login from './onboarding/steps/Login.vue';

export default {

    props: ['is'],

    data() {
        return {
            currentStep: 'start'
        }
    },

    components: {
        Start,
        Login
    },

    methods: {
        // Change current step view
        getNextStep: function (nextStep) {
            currentStep = nextStep;
            console.log('Parent. new step: ' + currentStep);
        },

        test: function() {
            console.log('Parent. new step: ' + currentStep);
        }
    }
}
</script>

In Start.vue:

<template>
<p><a @click.prevent="getNextStep('login')">Start <i class="icon arrow-right"></i></a></p>
        </div>
    </div>
</template>
<script>
    export default {

        props: ['is'],
</script>

I want to trigger the parent component method getNextStep on click of the button.

I can't figure how to make it work...
I have many parts like Start.vue & Login.vue and I am trying to move from one to the other. Trying to avoid repeating the same method everytime.

Thank you so much!!!

I know I should use a router, but right now the router doesn't work either...  https://laracasts.com/discuss/channels/vue/failed-to-resolve-directive-link-unknown-custom-element-router-view
                    
                    
                    

commandantp started a new conversation Using Vueify With Blade?

Hi,

How would you handle links to pages of your app that are not vue ? I have a part of the app that's in Vue and the rest classic blade. I don't think I can call {{ URL::route() }} within a .vue template or calling {{ asset() }}

What would you suggest?

Thanks!

commandantp started a new conversation Failed To Resolve Directive: Link & Unknown Custom Element: <router-view>

Hi,

Don't understand what's happening. I keep getting those errors and the link won't display / work no matter what I do. I followed both the example from the documentation & tried a few other tutorials too. Always the same problem.

My HTML:

<body>
    <div id="app">
      <h1>Hello App!</h1>
      <p>
        <!-- use v-link directive for navigation. -->
        <a v-link="{ path: '/hello' }">Go to Foo</a>
      </p>
      <!-- route outlet -->
      <router-view></router-view>
    </div>

    <script src="./js/main-vue.js"></script>
</body>

My main-vue.js:

var Vue = require('vue')
var VueRouter = require('vue-router')

Vue.use(VueRouter)
Vue.config.debug = true;

// Set up our route


var router = new VueRouter();

router.map({
    '/hello': {
        component: {
            template: '<p>hello!</p>'
        }
    }
});



var App = Vue.extend({});

router.start(App, '#app');

See the full error log:

main-vue.js:3583[Vue warn]: Failed to resolve directive: link
main-vue.js:3589Error: Warning Stack Trace
    at warn (main-vue.js:3589)
    at assertAsset (main-vue.js:4513)
    at compileDirectives (main-vue.js:9635)
    at compileElement (main-vue.js:9257)
    at compileNode (main-vue.js:9214)
    at compileNodeList (main-vue.js:9396)
    at compileNodeList (main-vue.js:9397)
    at compileNodeList (main-vue.js:9397)
    at compile (main-vue.js:9001)
    at VueComponent.Vue._compile (main-vue.js:10642)
main-vue.js:3583[Vue warn]: Unknown custom element: <router-view> - did you register the component correctly?
main-vue.js:3589Error: Warning Stack Trace
    at warn (main-vue.js:3589)
    at checkComponentAttr (main-vue.js:4080)
    at checkComponent (main-vue.js:9461)
    at compileElement (main-vue.js:9253)
    at compileNode (main-vue.js:9214)
    at compileNodeList (main-vue.js:9396)
    at compileNodeList (main-vue.js:9397)
    at compile (main-vue.js:9001)
    at VueComponent.Vue._compile (main-vue.js:10642)
    at VueComponent.Vue.$mount (main-vue.js:11634)
backend.js:201 [vue-devtools] ready.

The only positive thing is that #! is added in the URL meaning something happens? Node 5.4.1 & npm 3.5.3 & browserify & Laravel Elixir

Thanks for your help! Sorry going crazy on this one, duplicating from another site, but maybe you had the same pb...

15 Jan
3 years ago

commandantp left a reply on Laravel Route Redirecting To The Right Controller When Using Parameters [architecture Question]

Ah yes this is great love that call_user_func_array, saw it in a package not long ago didn't think of using it. It will allow me to keep the verbose readable. After discussion with @bestmomo I will also just load all the steps views at once in the DOM and then store the datas in Session and save them in batch.

...Will need to think about a user going a step back too 8-)

commandantp started a new conversation Laravel Route Redirecting To The Right Controller When Using Parameters [architecture Question]

Hi,

So building a few pages on the same template and loading the content via AJAX. Most of the content are forms. Views are defined by step number (1,2,3,4,5....32) Here is how I built my route:

Route::get('onboarding/', [
    'as' => 'get-onboarding-start',
    'uses' => 'OnboardingController@getStart'
]);
Route::get('onboarding/{i}', [
    'as' => 'get-onboarding-step',
    'uses' => 'OnboardingController@getNextStep'
]);
Route::post('onboarding/{i}', [
    'as' => 'post-onboarding-step',
    'uses' => 'OnboardingController@postStepForm'
]);

Now one method in the controller cannot handle all the work. Meaning I will need to redirect to another method based on the $i (step number).

I am afraid that it is not simple to read if I put a big blog of switch case $i = 1,2,3... At the same time I don't want to write 32 different routes.

What would you propose ? A/ Hard code all the routes meaning: 'onboarding/username' then 'onboarding/email' etc... etc... The good point is that it is super simple to read in the views and you know exactly what the next step is... no need to check what the number corresponds to. B/ Catch all as coded now and redirect to different methods in the controller C/ Something better, super easy to read and with little lines of code... which is .... ??

I posted as well on SOF here > http://bit.ly/1QaHTmn

Thanks a lot for your help!

13 Jan
3 years ago

commandantp left a reply on Socialite - Logging In With Facebook/twitter - Potential Issues

With Facebook you could have it return with an empty email if it has not been validated by them. Had to handle that case separately. Twitter no idea.

commandantp left a reply on Google API Call Back And Homestead

work around: in your etc/hosts add a local.yourdomain.com pointing to your local site and in Google auth use the local.yourdomain.com it will work around it.

If you don't have a domain your can try to use example.com

commandantp started a new conversation Intern / Someone With Spare Time To Help On Project?

Sorry if it's not correct to post that here.

Looking for someone to join my team. Working on a website related to photography. It is already up and running but under improvements. All made with love & Laravel. Intern welcome. :)

Just ping me in pm if you want more details.

Sorry if this wasn't the best place to post it // where else can I find Laravelers :-) I will delete if needed.

commandantp left a reply on Try Catch Not Being Handled In Artisan Command

@JeroenVanOort thanks, you pointed out the right solution. The error was an Invalid Request error which I catched in the handler but not the Command. It does work now within the Command. It did follow the rest of the command after catching my error. Do you know if it possible in the error exception handler to pass arguments to it from a controller or command?

commandantp started a new conversation Try Catch Not Being Handled In Artisan Command

Hi,

I have a try catch block in one of the command. Problem is when error occurs Laravel takes over and my catch block never happens. I read the error docs on L5.1 but not sure how it works with the ErrorHandler. Here is my block:

try {
                            $re = \Stripe\Refund::create([
                                'charge'    => $booking->stripe_charge_id,
                            ]);
                        } catch(\Stripe\Error\InvalidRequest $e) {
                            // Since it's a decline, \Stripe\Error\Card will be caught
                            $body = $e->getJsonBody();
                            $err  = $body['error'];

                            $err_status     = $e->getHttpStatus();
                            $err_type       = array_key_exists('type'   , $err)       ? $err['type']      : '';
                            $err_code       = array_key_exists('code'   , $err)       ? $err['code']      : '';
                            $err_param      = array_key_exists('param'  , $err)       ? $err['param']     : '';
                            $err_message    = array_key_exists('message', $err)       ? $err['message']   : '';
}

Is it something like in Exceptions/handler.php:

// Stripe exceptions
        if ($e instanceof \Stripe\Error\InvalidRequest) {
            // Do something ?
        }

If yes how do I get the variables I had in my ongoing command? I need specific error responses depending on the case.

Thanks!

11 Jan
3 years ago

commandantp left a reply on Scaling With Laravel And Forge

Any Laracast on load balancing around ? Couldn't find it but it says you can do it.

08 Jan
3 years ago

commandantp left a reply on [General Architecture] Where Do You Put Services You Create ?

Thanks Mike! I like that.

In which case would I prefer to work with jobs? I kept those for things that needs to work on schedules.

commandantp started a new conversation [General Architecture] Where Do You Put Services You Create ?

Hey guys,

Used to calling composer with vendors packages but there is quite a lot of logic I would like to take out of my controllers.

Do you know where I should put them and call them ? For example I'm doing an API call via guzzle in a controller to get a timezone. It is not good practice to do it there. Where should I create that service? the service providers folders always has a register and boot so I don't think it's there. Other example with Stripe payments I call directly in controllers when I could create a service for that.

Using Laravel 5.1

Thanks!

29 Dec
3 years ago

commandantp left a reply on Laravel Socialite With Stripe Connect

Did you find a solution? :)

28 Dec
3 years ago

commandantp left a reply on Laravel Cashier & Stripe Connect For Marketplace

@jekinney Thanks, already had a look at it. A few problems, having several currencies is not supported. For connect accounts you also need to trigger payments later on.

So surprised no-one worked around has worked with Stripe Connect

23 Dec
3 years ago

commandantp left a reply on Laravel Cashier & Stripe Connect For Marketplace

Up. In case someone is working with it ?

08 Dec
3 years ago

commandantp left a reply on Laravel Cashier & Stripe Connect For Marketplace

not related to Stripe Connect for marketplaces...

07 Dec
3 years ago

commandantp started a new conversation Laravel Cashier & Stripe Connect For Marketplace

Hey guys,

Any advice on using Laravel Cashier & Stripe Connect (for marketplace) ? If you have already used it in that way, what did you change to adapt it?

Thanks!

Have a nice day!!

09 Oct
3 years ago

commandantp left a reply on Fzaninotto/Faker Not Working In Forge

Same problem any solution?

Thanks!

commandantp left a reply on Where Select With Count Hasmany Relationship

Did you try Country::where('active', true)->where('name', '=', $aCountryName)->first()->resorts()->count() ?

commandantp started a new conversation Count Number Of Cities Distinct For All The Users

Hi,

This one should be easier but can't get my head around it. 3 Models => User, Address, City

User has an address and the address has a city.

I would like to count the number of cities that users saved as an address. I should not count duplicates.

Any idea how to do that? I started with $users->whereHas('address', function($q) {$q-> .... But I don't know how to compare the city_id of that address relation.

Thanks!

commandantp left a reply on Search Results To Be Grouped When Duplicates With Additional Conditions

Thanks a lot for your help! Sadly, it won't work for me as it loads the same as my join query from the OP. I think I need to look into something else because through the stypesUser I get a pivot and thus cannot access the other relations. For example $user->first()->pivot()->first()->currency()->symbol Currency being a model attached to the stypesUser.

07 Oct
3 years ago

commandantp left a reply on Search Results To Be Grouped When Duplicates With Additional Conditions

class Stype4User extends Model {

    protected $fillable = array(
        'price' ,
        'duration'
    );

    /**
    * The database table used by the model.
    *
    * @var string
    */
    protected $table = 'stypes_4_user';

    
    /**
    * The relationship between Stype4User and shooting ServiceType. 
    *
    */
    public function shootingType() {
        return $this->belongsTo('App\ServiceType');
    }
}
class User extends Model implements AuthenticatableContract,
                                    AuthorizableContract,
                                    CanResetPasswordContract
{
    use Authenticatable, Authorizable, CanResetPassword, SoftDeletes;

    protected $fillable = array(
        'username'  ,
    );

    /**
    * The database table used by the model.
    *
    * @var string
    */
    protected $table = 'users';
    /**
    * Defining the relationship with Stype4User
    *
    */
    protected $touches = array('stypesUser');
    public function stypesUser() {
        return $this->belongsToMany('App\ServiceType', 'stypes_4_user', 'user_id')
        ->withPivot('id', 'price', 'duration')
        ->withTimeStamps();
    }
class ServiceType extends Model {

    protected $fillable = array(
        'stype_name',
        'stype_description'
    );

    /**
    * The database table used by the model.
    *
    * @var string
    */
    protected $table = 'service_types';

    /**
    * The relationship between Stype4User and ServiceType. 
    *
    */
    public function stypesUser() {
        return $this->hasOne('App\Stype4User', 'service_type_id');
    }
}

@pmall I was trying to return at first just the minimum for one user. Which at the end of the day will be easy if I can get the result return as shown above. Thanks for your help, I appreciate the time you take!

commandantp left a reply on Search Results To Be Grouped When Duplicates With Additional Conditions

Thanks everyone for your input. @pmall thanks for the uppercase - must have forgotten it writing code in here. I like your min() thought I will need to access the min() just for one user, but this can be easy once I have the result I want - see below:

I will recap with more detailed for understanding: Say I have 2 users in my database:

// Table users :
UserA entries => ['id' => 1, 'name' => 'UserA']
UserB entries => ['id' => 2, 'name' => 'UserB']
// Table services_4_user
s4uA1 entries => ['id' => 1, 'service_id' => 1, 'user_id' => 1, 'price' => 10, 'duration'=>20]
s4uA2 entries => ['id' => 2, 'service_id' => 1, 'user_id' => 1, 'price' => 30, 'duration'=>50]
s4uB1 entries => ['id' => 3, 'service_id' => 1, 'user_id' => 2, 'price' => 20, 'duration'=>30]
s4uB2 entries => ['id' => 4, 'service_id' => 1, 'user_id' => 2, 'price' => 30, 'duration'=>40]

Now we are looking to return all those results. If I am following what I showed in the OP without the groupBy('users.id') it will return 4 results basically. If you add the groupBy('users.id'), it will return 2 results BUT only the s4uA1 and s4uB1 will be in my response. I need to return an object/collection that has the following infos:

$users_available =  [1] => ['user_id' => '1', 'name' => 'UserA', 's4u' => [[s4uA1], [s4uA2]]]

I simplified but this is what I need. Then in my view I just call a foreach on $users_available and I have all the datas available without having to recall the DB.

Thanks for your help!!

06 Oct
3 years ago

commandantp left a reply on Search Results To Be Grouped When Duplicates With Additional Conditions

Thanks Eric for your input! Not sure I understand what the two where clauses you added do?

I need to return the users that have two services or more in one grouped result. I need to access in the user array the two (or more) services.

Thanks!

edit - otherwise in my view I need a

@foreach($users as $user)

        {{ App\Service::where('service_id', '=', $service_id)->where('user_id', '=', $user->user_id)->get() }}

I would like to avoid to relaunch the DB when I am sure I can get that in my search controller. Thanks :-)

05 Oct
3 years ago

commandantp started a new conversation Search Results To Be Grouped When Duplicates With Additional Conditions

Hi guys,

A little help welcome on that one. I basically have users associated with a service that has a price. The same user can have twice the same service but with a different price & time.

To give you an overview, if you search for the service you need the users that have this service returned and if a user has several time the service with different price or duration I should show the lowest price - like "starting at xxx"

I would get twice the same user when he has two services. Now I used groupBy('user.id') to group them but it is not enough because it only takes the first result (the first service). Here is the code of the search:

$users_available =  user::where('activated', '=', 1)
->whereHas('serviceUser', function($q)use($stype)
{
    $q->where('service_type_id', '=', $stype);
})
->join('service_4_user', function($join)use($stype)
{
    $join->on('user_id', '=', 'users.id')
    ->where('service_type_id', '=', $stype);
})
->groupBy('users.id')
->get();

Any idea how I can get the data service_4_users.price & service_4_user.duration the lowest attached to the result and not just the first one that was created?

Thanks for your time!

Ask me if you need clarification.

03 Oct
3 years ago

commandantp started a new conversation Undefined Method Each() Using Factory->create()

Hey guys,

Following the docs I'm trying to add relationship to the models I create for testing. However this:

$users = factory(App\User::class, 3)
           ->create()
           ->each(function($u) {
                $u->posts()->save(factory(App\Post::class)->make());
            });

returns BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder::each()'

If I try with ->make() instead of ->create() it works.

On 5.1. Any idea what's happening?

[EDIT] NEVERMIND you can delete this post, it happens to be the number users you create. If you create only 1 each won't work Thanks!

22 Mar
4 years ago

commandantp left a reply on Help - JOB_TOO_BIG Pheanstalk

up... can't find anything on this....

commandantp started a new conversation Help - JOB_TOO_BIG Pheanstalk

Guys,

Made a mistake pushed some code on the prod sever but there was a bug and it pushed a job to the queue without deleting it once done. Now I can't push anything in the queue anymore, I get: Pheanstalk_Exception JOB_TOO_BIG: job data exceeds server-enforced limit

What can I do?

Thanks!

20 Mar
4 years ago