|
@@ -2,6 +2,9 @@
|
|
|
|
|
|
namespace Packages\Product\Http\Controllers;
|
|
namespace Packages\Product\Http\Controllers;
|
|
|
|
|
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
|
|
+use Packages\Product\Models\Draft;
|
|
|
|
+use Packages\Product\Models\Attachment;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
use Facade\Ignition\Support\Packagist\Package;
|
|
use Facade\Ignition\Support\Packagist\Package;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
@@ -9,6 +12,7 @@ use Illuminate\Support\Facades\Facade;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Support\Str;
|
|
|
|
+use Packages\Product\Traits\Attachments;
|
|
use Packages\Product\Http\Requests\ProductRequest;
|
|
use Packages\Product\Http\Requests\ProductRequest;
|
|
use Packages\Product\Http\Requests\ProductRequestEdit;
|
|
use Packages\Product\Http\Requests\ProductRequestEdit;
|
|
use Packages\Product\Models\Product;
|
|
use Packages\Product\Models\Product;
|
|
@@ -55,11 +59,30 @@ class ProductController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
//**************************************************** page create products *****************
|
|
//**************************************************** page create products *****************
|
|
- public function create()
|
|
|
|
|
|
+ public function create(Request $request)
|
|
{
|
|
{
|
|
$categories = Category::orderBy('parent_id')->where('parent_id', 0)->get();
|
|
$categories = Category::orderBy('parent_id')->where('parent_id', 0)->get();
|
|
|
|
|
|
- return view('product::product.create', compact('categories'));
|
|
|
|
|
|
+ if( !$request->has('draft_id') ){
|
|
|
|
+ $draft = new Draft();
|
|
|
|
+ $draft->object_type = 'Packages\Product';
|
|
|
|
+ $draft->save();
|
|
|
|
+ dd($draft->id);
|
|
|
|
+ return view('product::product.create', ['draft_id' => $draft->id] , compact('categories'));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ $draft = Draft::find( $request->draft_id );
|
|
|
|
+ if( is_null( $draft ) ){
|
|
|
|
+ return redirect()->route( 'product::product.create', compact('categories') );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $args = [
|
|
|
|
+
|
|
|
|
+ 'draft' => $draft
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ return view('product::product.create', compact('categories', 'args'));
|
|
}
|
|
}
|
|
|
|
|
|
// *********************************************************save products ******************
|
|
// *********************************************************save products ******************
|