2016-11-15 9 views
0

私はlaravel 4によく慣れていませんが、試しています。 ゲストはログインまたは登録前にカートにアイテムを追加してから、そのコンテンツをlaravel 4.2でログインしたままにしておくことができますか?laravel 4.2を使用してログインまたは登録する前に、ゲストがカートにアイテムを追加する方法を教えてください。

これは私のカートテーブル

Schema::create('carts', function (Blueprint $table) { 
     $table->increments('id'); 
     $table->integer('user_id')->unsigned(); 
     $table->integer('product_id')->unsigned(); 
     $table->string('quantity'); 
     $table->string('total'); 
     $table->timestamps(); 
     $table->foreign('user_id')->references('id')->on('users'); 
     $table->foreign('product_id')->references('id')->on('products'); 
    }); 

マイusersテーブル

Schema::create('users', function (Blueprint $table) { 
     $table->increments('id'); 
     $table->string('name'); 
     $table->string('username')->unique();   
     $table->string('email')->unique(); 
     $table->boolean('active')->default(0); 
     $table->string('confirmation_code')->nullable(); 
     $table->string('password',60); 
     $table->rememberToken(); 
     $table->timestamps(); 
    }); 

CartControllerが考えと

​​

誰でも以下のようになりますか?前もって感謝します。

+0

に従うことができ 、おかげで私はセッションを使用しようとしましたが、私は右ですか? – manniL

+0

あなたは実際にこの問題を克服しようとしましたか?あなたが本当にこの問題について考えるなら、それを解決する多くの方法があり、それは論理的に考えることに終わります。 一時ゲストユーザを作成して、カートテーブルでuser_idを使用できるようにすることができます。 ユーザーセッションにカートデータを保存し、ユーザーがサインアップした後にカートテーブルに保存することができます。 –

答えて

関連する問題