fdusautoir

Experience

27,370

2 Best Reply Awards

  • Member Since 3 Years Ago
  • 208 Lessons Completed
  • 0 Favorites

14th March, 2018

fdusautoir left a reply on Concatenation In Require • 3 months ago

Any help ? :/

13th March, 2018

fdusautoir started a new conversation Concatenation In Require • 3 months ago

Hi Everybody,

I have a very strange problem.

All this code below is working fine :

        payload.modules.forEach(function(mod) {

            var modules_path = '../../modules/';

            // Routes
            router.addRoutes(require('../../modules/'+mod.module_id+'/routes.js'));
            // Store
            store.registerModule(['modules', mod.module_id], require('../../modules/'+mod.module_id+'/store.js').default);

        });

But when I use the modules_path variable into my require like this :

        payload.modules.forEach(function(mod) {

            var modules_path = '../../modules/';

            // Routes
            router.addRoutes(require(modules_path+mod.module_id+'/routes.js'));
            // Store
            store.registerModule(['modules', mod.module_id], require('../../modules/'+mod.module_id+'/store.js').default);

        });

What can explains that ? That seems to be the same for me.

Thanks for your help :)

fdusautoir left a reply on Vue And Alias • 3 months ago

That's okay, in my webpack.mix.js file I've added this and that's works fine :

let src_path = 'resources/assets/js/';

mix.webpackConfig({
  resolve: {
    alias: {
      '@src': path.resolve(__dirname, src_path),
      '@store': path.resolve(__dirname, src_path + 'store/'),
      '@views': path.resolve(__dirname, src_path + 'views/'),
      '@components': path.resolve(__dirname, src_path + 'components/'),
      '@modules': path.resolve(__dirname, src_path + '/modules/'),
    }
  }
});

``

11th March, 2018

fdusautoir left a reply on Vue And Alias • 3 months ago

Mmm I don't think that is a clean way to achieve that. I'm thinking about webpack.mix and aliases but I don't understand how it works. @JeffreyWay any videos or help about this ?

9th March, 2018

fdusautoir left a reply on Vue And Alias • 3 months ago

@ejdelmonico @Cronix For sure that’s not answer to my question ;). Any help ?

fdusautoir started a new conversation Vue And Alias • 3 months ago

Hi Everybody.

How can I have alias in my vue files ? to prevent to use relative path everywhere ... That is not very convenient if I change the app structure in a future.

for example in my ./store/index.js I have in a function :

router.addRoutes([
            {
                path: '/clients',
                component: require('../../views/Clients.vue')
            },
        ]);
                

The best would be (as in Laravel) :

router.addRoutes([
            {
                path: '/clients',
                component: require(views_path('/Clients.vue'))
            },
        ]);

What is the best way to achieve that ?

Thanks for your help ! :)

17th April, 2017

fdusautoir left a reply on Request Fields In Model • 1 year ago

@leber, for sure but in this case, I don't need to check datas, in that case, I would pass the formRequest variable to my function.

fdusautoir left a reply on Request Fields In Model • 1 year ago

Thanks both for you answer, in fact, I just began phpunit and wonder if this way to proceed will be valid for testing in a simple way.

fdusautoir started a new conversation Request Fields In Model • 1 year ago

Hello Everybody,

I wonder if I took the right way in my application. For example, in my FooController I have :


public function submit(Foo $foo)
{
    $foo->submit();
    return back();
}


public function publish(Foo $foo)
{
    $foo->publish();
    return back();
}

And in my Foo model :


private function updateFields($status)
    {
        $this->update([
            'body'        => request('body'),
            'body_draft'  => request('body'),
            'status'     => $status,
            'difficulty' => request('difficulty') ?: $this->difficulty,
            'comment'    => request('comment') ?: $this->comment,
        ]);
    }
    
    public function submit()
    {
        $this->updateFields('submit');
        $this->archive('submit');
    }
    
    public function publish()
    {
        $this->updateFields('publish');
        $this->archive('publish');
    }


Is it a good way to proceed or it not recommend to use request in model and why ?

Thanks for your help ! :)

30th March, 2017

fdusautoir left a reply on Login Redirect When Errors • 1 year ago

Thanks for your help. In fact, that's a part of the answer. I solved the problem in two steps.

First, I override the protected function login() with a FormRequest to be able to override the protected $redirectRoute variable.

Then to finish, I override the sendFailedLoginResponse() .

Now, if I validate form with missings data in the header OR if I failed validation, it redirects to the login form as expected. :)

29th March, 2017

fdusautoir left a reply on Login Redirect When Errors • 1 year ago

Thanks for your answer. I already try this with a return die()but nothing appends, it still redirect back with errors

fdusautoir started a new conversation Login Redirect When Errors • 1 year ago

Hi There !

I have a tiny login form in my header page with this code :


{!! Form::open(['route' => 'login']) !!}
    <input type="text" name="email">
    <input type="password" name="password"">
    <button type="submit">Login</button>
</form>
{!! Form::close() !!}
                                        

When I click the login button, it redirects to the same page with errors validations. All is OK at this point but I don't want this redirect()->back()native redirection which is not really clear for the user (the login form is in a submenu in the header). How to redirect to the 'real' login page with errors which is accessible at the php route('login.form') ?

Thanks for your help ! :)

4th March, 2017

fdusautoir left a reply on Multi Domains • 1 year ago

@mikefolsom You're right for the canonical. That was not a good example here. I just updated my post with a new example to explain that I want to achieve.

fdusautoir started a new conversation Multi Domains • 1 year ago

Hi there.

I have one site with multiple domains. For example :

  • example.fr
  • example.be
  • example.lu

Those have the same language and when I visit a page I just want to update the href on the canonical meta with the extension that is used to access the page. For example, if i'm on example.be/my-page . I want to have :

<meta name="canonical" href="example.be/mypage">

For example.lu/my-page :

<meta name="canonical" href="example.lu/mypage">

How to achieve that in a proper way ? In fact, it would be great if it would exists a $request->getDomainExtension() function .

Thanks for you help.

27th February, 2017

fdusautoir started a new conversation Optimisation Avg • 1 year ago

Hello !

I have a table with products and another one with product_ratings which store all ratings by user.

What is the best way to optimize queries to get the average rating on the product ?

Use eager loading on the product model with ratings relation or to add a rating column to the product table and update it only when a user rate the product ?

A simple question but I wonder if it could be increase performance with a lot of traffic.

15th February, 2017

fdusautoir left a reply on Markdown And Inline Attachments • 1 year ago

Someone to help me please ?

fdusautoir started a new conversation Markdown And Inline Attachments • 1 year ago

Hello Everybody !

I try to embed inline images in my mail template but I have an error :

Undefined variable: message (View: /Users/francois.dusautoir/Code/lvdp/resources/views/emails/request/received.blade.php)

received.blade.php

    
@foreach($request->files as $file)
![image]({{$message->embed($file->path)}})
@endforeach

** RequestReceived.php **

namespace App\Mail;

use App\Request;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class RequestReceived extends Mailable
{
    use Queueable, SerializesModels;

    public $request;
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this
            ->subject('Foo - Bar')
            ->markdown('emails.request.received');
    }

Relative to the documentation :

use the embed method on the $message variable within your email template. Laravel automatically makes the $message variable available to all of your email templates, so you don't need to worry about passing it in manually.

Any help here ? :/

14th February, 2017

fdusautoir left a reply on Dropzone And Laravel • 1 year ago

Not a mistake but my mistake. I tried to return response like json with instance of UploadedFile, that has no public properties and so I could'n see it in the browser console.

fdusautoir left a reply on PHPStorm Automatic Reformat • 1 year ago

It is checked. That's very strange ...

fdusautoir left a reply on Dropzone And Laravel • 1 year ago

The console image :

console

fdusautoir started a new conversation Dropzone And Laravel • 1 year ago

Hi everybody !

I want to implement dropzone into my form. When I click the submit button of the general form, it launch the dropzone queue, that's okay. All that I want for the moment is getting the filename from my Controller after sending it but I have an empty array for the file.

This is what i did :

In my contact.blade.php :


<form id="contact-form" class="form" action="{{action('[email protected]')}}" method="POST">

    ...
    // Some input fields 
    ...

    <!------ Fields  ------>
                <div class="form-group">
                    {!! Form::label('', 'Vous avez des croquis ?') !!}
                    <div id="files" class="dropzone" data-url="{{route('contact-form-file')}}"></div>
                </div>


</form>

In my contact.js :


$("#files").dropzone({
        url: $('#files').attr('data-url'),
        autoProcessQueue: false,
        uploadMultiple: true,
        parallelUploads: 3,
        maxFiles: 3,
        paramName: 'file',

        init: function() {
            var myDropzone = this;

            $('#contact-form').submit(function(e) {
                if(complete) {
                    return true;
                }

                var $button = $(this).find('button');
                $button.addClass('proceed');
                myDropzone.processQueue();
                return false;
            });
        },


        sending: function(file, xhr, formData) {
            formData.append("_token", $('meta[name="csrf-token"]').attr('content'));
            formData.append("foo", 'bar');   //  Test
        },

    });


In my contactController.php :


class ContactController extends Controller
{
    public function uploadFile(Request $request)
    {
        return response()->json($request->all());
    }
}


In my console :

!(http://img11.hostingpics.net/pics/738830Capturedecran20170214a112537.png)

Someone to help me at this point ? :(

12th February, 2017

fdusautoir left a reply on PHPStorm Automatic Reformat • 1 year ago

@hendranucleo That's right. Just press enter and that reformat what I just wrote.

fdusautoir started a new conversation PHPStorm Automatic Reformat • 1 year ago

Hi There,

This is my settings :

Settings

When I write a function in a php file for example, this is what I get :

function test() {
    return 'Hello World';
}

If I run Code > Reformat Code I get exactly what I want refers to my settings :

function text()
{
    return 'Hello World';
}

My question is : How to get this automatically when I'm writing ? That's very constraining to do it manually each time.

Thanks for you help . :)

8th February, 2017

fdusautoir left a reply on Laravel Mix And BrowserSync • 1 year ago

Any help ? :(

6th February, 2017

fdusautoir left a reply on Laravel Mix And BrowserSync • 1 year ago

Someone can help me ? :/

fdusautoir left a reply on Laravel Mix And BrowserSync • 1 year ago

I think the module.exports.plugins is not the good way to achieve it

fdusautoir left a reply on Using Assets Like Images In App.scss (Has To Be Compiled By Webpack) • 1 year ago

Put your images in your assets folder and define the url in your scss files relative to this path.

for example :

assets/sass/app.scss assets/images/back.jpg

body {
    background: url('../images/back.jpg');
}

All your images will be compiled in your public after after the run dev command.

fdusautoir left a reply on Using Nl2br() In A Controller • 1 year ago

Have you tried this :


/**
   * Update the Assignment.
   *
   * @param  Request  $request
   * @return Response
   */
  public function update(Request $request, $id)
  {

    $assignment = Assignment::findOrFail($id);
    $assignment->brief = nl2br($request->brief); 
    $assignment->save();

  }

fdusautoir started a new conversation Laravel Mix And BrowserSync • 1 year ago

Hi everybody !

I try to use browserSync with laravel Mix. Any errors with npm run watch but nothing appends when I update a a view file for example. I precise that I installed brothersync with npm install --save-dev browser-sync-webpack-plugin

Did I do a mistake in the webpack.mix.js file ?



const { mix } = require('laravel-mix');
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');

const extract = [
    'jquery',
    'sweetalert',
    'vegas',
    'simplelightbox',
    'swiper',
];

mix.js([
    'resources/assets/js/home.js',
    'resources/assets/js/app.js',
    'resources/assets/js/contact.js',
], 'public/js/app.js')
    .extract(extract)
    .version();

mix.sass('resources/assets/sass/main.scss', 'public/css/all.css');

module.exports.plugins = new BrowserSyncPlugin({
    host: 'lvdp.dev'
});



Thanks for your help (I'm on the last version of Laravel. Updated yesterday).

fdusautoir left a reply on Flash Message With FormRequest • 1 year ago

You're right ! Thanks a lot ! :)

5th February, 2017

fdusautoir started a new conversation Flash Message With FormRequest • 1 year ago

Hi Everybody !

I attempt to pass a flash message when a form validation failed but I have an error. Validation is OK, I'm redirected to the form page with errors bag etc. but when I attempt to override the protected failedValidation() function, I have this following message : Class App\Http\Requests\sendContactRequest does not exist

What's wrong ?



<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class sendContactRequest extends FormRequest
{


    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'      => 'required',
            'phone'     => 'required',
            'email'     => 'required',
            'comment'   => 'required'
        ];
    }


    /**
     * Handle a failed validation attempt.
     *
     * @param  \Illuminate\Validation\Validator  $validator
     * @return mixed
     */

    protected function failedValidation(Validator $validator)
    {
        alert()->warning('oops ... error');
        return parent::failedValidation($validator);
    }

}

Thanks for your help :)

4th February, 2017

fdusautoir left a reply on Webpack Mix And Url() • 1 year ago

Thanks a lot.

'Mix will look there for all your js/css/images/fonts and compile those to your public folder.'

I don't know it for your last answer and that is really great ! :-)

fdusautoir started a new conversation Webpack Mix And Url() • 1 year ago

Hi there.

I've a problem with my my shell npm run dev command. Everything is working well but when it's time to compile my sass files, I've this error :


 ERROR  Failed to compile with 6 errors

These dependencies were not found in node_modules:

* ../images/load-2.svg
* ./overlays/02.png
* ../../fonts/lvdp/lvdp.eot
* ../../fonts/lvdp/lvdp.woff
* ../../fonts/lvdp/lvdp.ttf
* ../../fonts/lvdp/lvdp.svg

This is my webpack.mix.js :


const { mix } = require('laravel-mix');


mix.js([
    'resources/assets/js/vendor/modernizr.js',
    'resources/assets/js/vendor/classie.js',
    'resources/assets/js/vendor/sweetalert.js',
    'resources/assets/js/vendor/simple-lightbox.jquery.js',
    'resources/assets/js/vendor/vegas.js',
    'resources/assets/js/vendor/swiper.jquery.js'
], 'public/js/vendor.js')
    .version();

mix.js([
    'resources/assets/js/menu.js',
    'resources/assets/js/contact.js',
    'resources/assets/js/home.js',
    'resources/assets/js/newsletter.js'
], 'public/js/app.js')
    .version();

mix.sass('resources/assets/sass/main.scss', 'public/css/all.css');

And here it's my package.json



{
  "private": true,
  "scripts": {
    "dev": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.15.2",
    "jquery": "^3.1.0",
    "laravel-mix": "^0.6.0",
    "lodash": "^4.16.2"
  }
}

That's seems to be with the use of url() in css. What is the way to say webpack to ignore url() value ?

Any help ? :)

20th August, 2016

fdusautoir started a new conversation Replicate Model With Relationships • 1 year ago

Hi there,

I want to replicate a template with all his relations ships with Eloquent. I did this and it works like a charm :

$clone = $template->quote->replicate();
        $clone->push();

        foreach($template->quote->categories as $category)
        {
            $clone->categories()->attach($category);
        }
        
        foreach($template->quote->subcategories as $subcategory)
        {
            $clone->subcategories()->attach($subcategory, ['quote_category_id' => $subcategory->pivot->quote_category_id]);
        }
        
        foreach($template->quote->tasks as $task)
        {
            $clone->tasks()->attach($task, ['quote_subcategory_id' => $task->pivot->quote_subcategory_id]);
        }
        
        foreach($template->quote->subtasks as $subtask)
        {
            $clone->subtasks()->attach($subtask, ['quote_task_id' => $subtask->pivot->quote_task_id]);
        }

        $clone->push();

Now, I want to do a little bit of refactoring and make it more easier. I try this but when I push at the end, only the quote line is replicate and not all the relations that I loaded before :

$quote     = $template->quote->load('categories','subcategories', 'tasks', 'subtasks');
        $new_quote = $quote->replicate();
        $new_quote->push();

How to have the same result as above with this solution ?

15th August, 2016

fdusautoir left a reply on Convention Tables Naming • 1 year ago

@FrancescoZaffaroni You're right. It's a great work to change all the database but it's worth it. :)

fdusautoir left a reply on Convention Tables Naming • 1 year ago

@simondavies @SaeedPrez @FrancescoZaffaroni The basics laravel conventions are greats for simple database. In this case, I prefix categories with quotes_ because it deals with quotes. In this database, I have others categories tables which are attached to their parents. For example, specifications_categories.

In this case and to follow your advices, I have now :

  • quotes
  • quotes_categories
  • category_quote ( to follow Laravel conventions)

Then I have 2 models :

  • Quote
  • QuoteCategory

In the Quote Model I have :

public function categories() 
    {
        return $this->belongsToMany('QuaiDesBalises\QuoteCategory', 'category_quote', 'quote_id', 'category_id');
    }

If I don't specify the pivot table I have this error :

Table 'quote_quote_category' doesn't exist

Then, when I specify the pivot table and not the local and foreign keys, I have this error :

Unknown column 'category_quote.quote_category_id' in 'field list

To finish, when I specify the pivot table and the local / foreign keys, that's works. So, if we follow Laravel, we should have this database :

quotes

  • id
  • name

quotes_categories

  • id -name

quote_quote_category

  • quote_id
  • quote_category_id

Finally, we can consider that Laravel except to be accurate in the naming of fields in pivot tables

fdusautoir started a new conversation Convention Tables Naming • 1 year ago

Hi there,

I want to have your opinion about convention naming for database tables.

EXAMPLE :

quotes *id *name

quotes_categories *name *desc

**quotes_has_categories ** *quote_id *quote_category_id

**The question is simple : ** In the quotes_has_categories table, what's the best way to name the foreign key for the category id : quote_category_id or category_id.

11th August, 2016

fdusautoir left a reply on Relations With Multiple Foreign Keys • 1 year ago

Anybody to help me ? :/

fdusautoir started a new conversation Relations With Multiple Foreign Keys • 1 year ago

Hy everybody ! We have done this CMD: CMD

After that, we created Models with this relationships:

*Models Quote

class Quote extends Model
{
 public function specification()
   {
     return $this->belongsTo('QuaiDesBalises\Specification');
   }
  public function categories()
   {
       return $this->belongsToMany('QuaiDesBalises\QuoteCategory', 'quotes_routes', 'quote_category_id', 'quote_id');
   }
}

*Models QuoteCategory

class QuoteCategory extends Model
{

    protected $guarded = ['id'];
   protected $table = 'quotes_categories';
    
    
    /*  
      --------------------------------------
          Relations
      -------------------------------------- 
    */ 
    
  public function quote()
   {
      return $this->belongsToMany('QuaiDesBalises\Quote', 'quotes_routes', 'quote_id', 'quote_category_id');
   }
    
  public function subcategories()
   {
       return $this->belongsToMany('QuaiDesBalises\QuoteSubcategory', 'quotes_routes', 'quote_category_id', 'quote_subcategory_id');
  }
}

*Models QuoteSubategory

class QuoteSubcategory extends Model
{
    protected $guarded = ['id'];
protected $table = 'quotes_subcategories';
    
    /*  
      --------------------------------------
           Relations
      -------------------------------------- 
    */ 
    
   public function lines()
   {
        return $this->belongsToMany('QuaiDesBalises\QuoteLine', 'quotes_routes', 'quote_subcategory_id', 'quote_line_id');
    }
    
    public function category()
    {
        return $this->belongsToMany('QuaiDesBalises\QuoteCategory', 'quotes_routes', 'quote_subcategory_id', 'quote_category_id');
    }

}

*Models QuoteLine

class QuoteLine extends Model
{
    public function subcategories(){

       return $this->belongsTo('QuaiDesBalises\QuoteSubcategory');
   }
}

After this, we wanted to get the categories from the quote, so we've done this code in a controller;

public function index() {
        
        
        $quote = Quote::find(1);
        
        dd($quote->categories->all());
}

We have done this seeder:

public function run()
    {
        DB::table('quotes_routes')->insert([
            'quote_id'             => 1,
            'quote_category_id'    => 1,
            'quote_subcategory_id' => 1,
            'quote_line_id'        => 1
        ]);
        
        DB::table('quotes_routes')->insert([
            'quote_id'             => 1,
            'quote_category_id'    => 1,
        'quote_subcategory_id' => 1,
        'quote_line_id'        => 2
      ]);
        
     DB::table('quotes_routes')->insert([
        'quote_id'             => 1,
        'quote_category_id'    => 1,
        'quote_subcategory_id' => 1,
        'quote_line_id'        => 3
       ]);
       
       DB::table('quotes_routes')->insert([
        'quote_id'             => 1,
        'quote_category_id'    => 1,
        'quote_subcategory_id' => 1,
            'quote_line_id'        => 4
      ]);
   }

We get 4 sames categories from the code controller instead of 1. How can it work with the relations ?

10th August, 2016

fdusautoir left a reply on Problem With Relations • 1 year ago

Is there someone to help me please ? My project is stopped because of this problem :(

fdusautoir started a new conversation PROBLEM WITH RELATONSHIPS • 1 year ago

Hy everybody ! We have done this CMD: CMD

After that, we created Models with this relationships:

*Models Quote

//class Quote extends Model
//{
  //public function Specification()
   // {
   //    return $this->belongsTo('QuaiDesBalises\Specification');
   // }
   //public function categories()
   // {
     //   return $this->belongsToMany('QuaiDesBalises\QuoteCategory', 'quotes_routes', 'quote_category_id', 'quote_id');
   // }
//}

*Models QuoteCategory

//class QuoteCategory extends Model
//{

   // protected $guarded = ['id'];
    //protected $table = 'quotes_categories';
    
    
    ///*  
     //  --------------------------------------
      //     Relations
      // -------------------------------------- 
    //*/ 
    
   // public function quote()
   // {
    //    return $this->belongsToMany('QuaiDesBalises\Quote', 'quotes_routes', 'quote_id', 'quote_category_id');
   // }
    
    //public function subcategories()
  //  {
    //    return $this->belongsToMany('QuaiDesBalises\QuoteSubcategory', 'quotes_routes', 'quote_category_id', 'quote_subcategory_id');
  // }
//}

*Models QuoteSubategory

//class QuoteSubcategory extends Model
//{
//  protected $guarded = ['id'];
 //protected $table = 'quotes_subcategories';
    
//  /*  
  //     --------------------------------------
   //        Relations
    //   -------------------------------------- 
   // */ 
    
    //public function lines()
   // {
   //     return $this->belongsToMany('QuaiDesBalises\QuoteLine', 'quotes_routes', 'quote_subcategory_id', 'quote_line_id');
  //  }
    
   // public function category()
   // {
 //       return $this->belongsToMany('QuaiDesBalises\QuoteCategory', 'quotes_routes', 'quote_subcategory_id', 'quote_category_id');
 //   }

//}

*Models QuoteLine

//class QuoteLine extends Model
//{
   // public function Subcategories(){

   //     return $this->belongsTo('QuaiDesBalises\QuoteSubcategory');
   // }
//}

After this, we wanted to get the categories from the quote, so we've done this code in a controller;

//public function index() {
        
        
//      $quote = Quote::find(1);
        
//      dd($quote->categories->all());
//}

We have done this seeder:

//public function run()
   // {
    //     DB::table('quotes_routes')->insert([
    //      'quote_id'             => 1,
    //      'quote_category_id'    => 1,
       //   'quote_subcategory_id' => 1,
            'quote_line_id'        => 1
    //    ]);
        
      //  DB::table('quotes_routes')->insert([
     //     'quote_id'             => 1,
        //  'quote_category_id'    => 1,
       //   'quote_subcategory_id' => 1,
      //    'quote_line_id'        => 2
      //  ]);
        
      //  DB::table('quotes_routes')->insert([
       //   'quote_id'             => 1,
     //     'quote_category_id'    => 1,
       //   'quote_subcategory_id' => 1,
       //   'quote_line_id'        => 3
      //  ]);
       
      //  DB::table('quotes_routes')->insert([
      //    'quote_id'             => 1,
       //   'quote_category_id'    => 1,
        //  'quote_subcategory_id' => 1,
        //  'quote_line_id'        => 4
//       ]);
  // }

We get 4 sames categories from the code controller instead of 1. How can i do ? Do you know how to do this with eloquent ?

fdusautoir left a reply on Tables And Relations • 1 year ago

Any ideas ? :-(

9th August, 2016

fdusautoir left a reply on Tables And Relations • 1 year ago

This is the MCD that I made but I don't know if this is the good way to achieve it and if it is, how to proceed with the relations to do it ? (Because we refer to multiple foreign keys in this case) Mcd

fdusautoir started a new conversation Tables And Relations • 1 year ago

Hi everybody !

I have a special case in my projet and I would like to know your way of thinking to achieve it in the best way. Consider 4 tables :

  1. projects - *A table which contains some projects.
  2. projects_categories - A table which contains some categories. __A category belongs to a project.__
  3. projects_subcategories - A table which contains some subcategories. __A subcategorie belongs to a category.__
  4. projects_lines - A table which contains some lines. __A line belongs to a subcategory.__

I want to have a flexible system. Project A and Project B can have both the same categories but not have the same subcategories. Project B and Project C can have both the same categories and subcategories but not have the same lines in their subcategories. In fact, I know I have to use a pivot table each time, but I have the problem from a moment.

I begin to create a projects_has_categories table to list all projects and their categories (with project_id and project_category_id foreign keys). Then I create a projects_categories_has_subcategories table (with project_category_id and project_subcategory_id foreign keys). The problem is if I put the project_category_id foreign key I refer to the category id and not the relation because I want to refer at the same time at the project_id.

What's your opinion about the way I did that ? What's the best way to achieve that I want to do ?

Thank's for your help. I'm lost :(

30th March, 2016

fdusautoir started a new conversation Route Helper In Config/services.php • 2 years ago

Hi Everybody ! :)

I get an error when I try to use the route helper in my config/services.php file for socials connections.


    'facebook' => [
        'client_id' => 'xxxxxx',
        'client_secret' => 'xxxxxx,
        'redirect' => route('social.redirect', 'facebook'),
    ],
    
    'twitter' => [
        'client_id' => 'xxxxxx,
        'client_secret' => 'xxxxxx',
        'redirect' => route('social.redirect', 'twitter'),
    ],
    
    'google' => [
        'client_id' => 'xxxxxx,
        'client_secret' => 'xxxxxx',
        'redirect' => route('social.redirect', 'google'),
    ],

    Fatal error: Uncaught exception 'ReflectionException' with message 'Class log does not exist'

I get a this fatal error when I write this, if I write the full link directly, no errors.

Any helps ?

28th March, 2016

fdusautoir started a new conversation Laravel 5.2 - Socialite - First And Last Name • 2 years ago

Hi Everyone ! :)

Is there a way with Socialite to get first and last name within Facebook, Twitter, Google plus API ? For the moment, I can only retrieve the full name ...

Any Help ? :)

fdusautoir left a reply on Laravel 5.2 - Auth Middleware • 2 years ago

Just as simple as that ... Thanks a lot @bestmomo :)

fdusautoir started a new conversation Laravel 5.2 - Auth Middleware • 2 years ago

Hi there !

I have a problem with auth middleware. I have something like this in my view :

@if(Auth::check())
    Hi {{Auth::user()->firstname}}, you are connected !
@else
    ... Form to connect ...
@endif

Then, I can login within my app and see the message Hi François, you are connected ! but when I put middleware in my routes files, it systematically redirects me to the default login page written in the middleware.

My routes.php file :

Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => [ 'localize' ]
], 
function()
{   
    
    $this->group(['middleware' => ['web']], function () {
        
        $this->get('/', ['as' => 'home', 'uses' => 'HomeController@index']);
    });
        
        
    $this->group(['middleware' => ['auth'], 'prefix' => 'account'], function () {
        
        $this->get('/', ['as' => 'profile', 'uses' => 'AccountController@getIndex']);
        
    });
    
});
        

What's wrong ? :(

26th March, 2016

fdusautoir left a reply on Laravel Localization • 2 years ago

That's great ! :) Thanks a lot @bobbybouwmann

fdusautoir started a new conversation Laravel Localization • 2 years ago

Hi there :)

I have a problem with the package Laravel Localization**. For example, I have a page named albums in two languages. If I access from URL directly with mydomain.dev/les-albums (french) or mydomain.dev/en/albums (english) . All is OK.

My problem is with blade. How does that work ? If I tried

{{route('albums')}}

That tells me Route [albums] not defined..

Here is my routes file :

Route::group([
    'prefix' => Language::setLocale(),
    'middleware' => [ 'localize' ]
], 
function()
{   
    
    $this->group(['middleware' => ['web']], function () {
    
        $this->get('/', function () {
            return view('pages.welcome');
        });
        
        // Albums
        
        $this->get(LaravelLocalization::transRoute('routes.albums'), ['uses' => 'AlbumsController@index']);
    
    });
});

Here is my routes.php file in resources/lang/en/routes

<?php 
    
    
    return [
        
        'albums'        => 'albums',
        'album'         => 'albums/{slug}',
        
    ];

Any help please ? :)

Edit Your Profile
Update

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