memoLee

Experience

280

0 Best Reply Awards

  • Member Since 1 Month Ago
  • 0 Lessons Completed
  • 0 Favorites

20th September, 2018

memoLee started a new conversation How To Manage ProductsController And ImagesController From The Same Form? • 1 month ago

I have seperated databases; products and images. and they has own controller. Also I created relations between them. Now I dont know how to use different Controller for the same form. I want to store images and products to database with Add Product button. Note : I want to use imagesController not the Image model.

Here my [email protected] :

  /**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request, Product $product)
{
    request()->validate([
        'name'      => 'required|string',
        'description' => 'required|max:5000',
        // 'image' => 'required|file|image|mimes:jpeg,png,gif,webp',
        'price' => 'required|numeric',
        'compare_price' => 'required|numeric',
        'charge_tax' => 'boolean',
        'sku' => 'required|unique:products',
        'inventory' => 'required|numeric',
        // 'barcode' => 'required', required??
        'track_inventory' => 'required|boolean',
        'width' => 'required|numeric',
        'height' => 'required|numeric',
        'depth' => 'required|numeric',
        'weight' => 'required|numeric',
        'weight_type' => 'required',
        'extra_shipping_fee' => 'required|numeric',
    ]);


    $product = Product::create([
        'user_id'    => auth()->id(),
        'name'      => request('name'),
        'description' => request('description'),
        // 'image_path' => request()->file('image')->store(auth()->id().'images', 'public'),
        'price' => request('price'),
        'compare_price' => request('compare_price'),
        'charge_tax' => request('charge_tax'),
        'sku' => request('sku'),
        'inventory' => request('inventory'),
        'track_inventory' => request('track_inventory'),
        'width' => request('width'),
        'height' => request('height'),
        'depth' => request('depth'),
        'weight' => request('weight'),
        'weight_type' => request('weight_type'),
        'extra_shipping_fee' => request('extra_shipping_fee'),
    ]);

    

    if (request()->wantsJson()) {
        return response($product, 201);
    }

    return redirect('/products')
    ->with('flash', 'Product has been stored!');
}

And here my Images controller :

    /**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request, Product $product)
{
    if ($request->hasFile('images')) {
        foreach ($request->file('images') as $image) {
            $product->images()->create([
             'image_path' => $image->store(auth()->id().'images', 'public')
             ]);
        }
    }

}

12th September, 2018

memoLee left a reply on There Is Two Package.json File. What Should I Do? • 1 month ago

You may misunderstood me. I mean one of this is laravel package.json and the other is templates package.json . I added on stackoverflow and it has a snapshot of the app directory of template. Please check it out there.

https://stackoverflow.com/questions/52301950/there-is-two-package-json-file-one-of-this-came-fom-template-what-should-i-do

memoLee left a reply on There Is Two Package.json File. What Should I Do? • 1 month ago

Got it but with what ? webpack ? Also how can I merge two of package.json files?

memoLee left a reply on There Is Two Package.json File. What Should I Do? • 1 month ago

These files not compiled files . Do I need that ?

memoLee left a reply on There Is Two Package.json File. What Should I Do? • 1 month ago

what about saas and js files of template ?

memoLee started a new conversation There Is Two Package.json File. What Should I Do? • 1 month ago

I have a project builded with laravel and need to add a template. But the template has own package.json node_modules etc.

What is the right way the handling this issue. Any help appreciated.

5th September, 2018

memoLee left a reply on How To Handle Multi Tabbed Modal Form Validation ? • 1 month ago

Ahh, got it. thank you.You are my life saver :) @bobbybouwmann

I have a issue, with login page. Can you please also help me on this issue. Anyone didn't answered. https://laracasts.com/discuss/channels/laravel/login-and-register-on-the-same-page-laravel-56

4th September, 2018

memoLee left a reply on How To Handle Multi Tabbed Modal Form Validation ? • 1 month ago

Thank you so much! Last question, Can I use axios instead of Ajax for this situation?(Template builded by jquery + BS4. So, I can't use vue. it will be too heavy, right?)

memoLee left a reply on Validation Rules And Modal Dialog • 1 month ago

Can you please, help me to solve my multi tabbed modal problem? @bobbybouwmann

here my question on laracasts:https://laracasts.com/discuss/channels/general-discussion/how-to-handle-multi-tabbed-modal-form-validation

3rd September, 2018

memoLee started a new conversation How To Handle Multi Tabbed Modal Form Validation ? • 1 month ago

I am working on a modal that adds the product. The modal has seperated tabs which is needed to add product details. The question is that how can I handle validation.

Each tab has own form. And submit button is the same (in the modal footer not included the forms). shouldn't be single form? Also the "required" rule is not working. Any help please ?

30th August, 2018

memoLee started a new conversation Login And Register On The Same Page. Laravel 5.6 • 1 month ago

I am new on laravel. My login and register page is the same. So when I fill the register page with wrong credentials, errors appear on both login and register forms.

When the registration fail it should be focus on register page but it is focusing the login page.

What is the easiest way to make it work? Any suggestions? I don't know how to use error bags It would be fine if someone also tell me how to do it. Many thanks.

Here the code;

Laravel
<div id="login_content">
    <div class="logo">
        <img src="assets/img/logo/ml-logo.png" alt="logo" class="logo-img">
    </div>
    <h1 class="login-title">
        Sign In to your account
    </h1>
    <div class="login-body">
        <form method="POST" action="{{ route('login') }}">
            @csrf
            <div class="form-group label-floating is-empty">
                <label class="control-label">Email</label>
                <input type="email" name="email" class="form-control"  value="{{ old('email') }}" required>

                @if ($errors->has('email'))
                    <span class="invalid-feedback">
                        <strong>{{ $errors->first('email') }}</strong>
                     </span>
                @endif

            </div>
            <div class="form-group label-floating is-empty">
                <label class="control-label">Password</label>
                <input type="password" name="password" class="form-control" required>

                @if ($errors->has('password'))
                    <span class="invalid-feedback">
                        <strong>{{ $errors->first('password') }}</strong>
                    </span>
                @endif

            </div>
            <a href="javascript:void(0)" class="forgot-pass pull-right">Forgot Password?</a>
            <div class="checkbox inline-block">
                <label>
                    <input type="checkbox" class="checkbox-inline" value="">
                    Remember Me
                </label>
            </div>
            <button type="submit" class="btn btn-info btn-block m-t-40">Sign In</button>
            <div class="login-options">
                <span>OR</span>
                <hr/>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <button class="btn btn-facebook btn-block"><i class="zmdi zmdi-facebook"></i> Sign In with
                        Facebook
                    </button>
                </div>
                <div class="col-xs-12">
                    <button class="btn btn-google btn-block"><i class="zmdi zmdi-google-plus"></i> Sign In with
                        Google
                    </button>
                </div>
                <div class="col-xs-12">
                    <button class="btn btn-twitter btn-block"><i class="zmdi zmdi-twitter"></i> Sign In with Twitter
                    </button>
                </div>
            </div>
        </form>
    </div>
    <div class="login-footer p-15">
        <p>
            Don't have an account? <a href="javascript:void(0)" data-toggle="register">Create an account</a>
        </p>
    </div>
    <div id="register_wrapper">
        <ul class="card-actions icons right-top">
            <li>
                <a href="javascript:void(0)" data-toggle="register">
                    <i class="zmdi zmdi-close"></i>
                </a>
            </li>
        </ul>
        <div class="logo">
            <img src="assets/img/logo/ml-logo.png" alt="logo" class="logo-img">
        </div>
        <h1 class="login-title">
            Create an account
        </h1>
        <div class="login-body">
            <div class="col-xs-12">
                <button class="btn btn-facebook btn-block"><i class="zmdi zmdi-facebook"></i> Sign Up with Facebook
                </button>
            </div>
            <div class="col-xs-12">
                <button class="btn btn-google btn-block"><i class="zmdi zmdi-google-plus"></i> Sign Up with Google
                </button>
            </div>
            <div class="col-xs-12">
                <button class="btn btn-twitter btn-block"><i class="zmdi zmdi-twitter"></i> Sign Up with Twitter
                </button>
            </div>
            <form class="clear-both"  method="POST" action="{{ route('register') }}">
                @csrf
                <h2 class="text-center p-t-20">
                    Or sign up below
                </h2>
                <div class="form-group label-floating is-empty">
                    <label class="control-label">Name</label>
                    <input type="text" name="name" class="form-control" required>
                    @if ($errors->has('name'))
                        <span class="invalid-feedback">
                                    <strong>{{ $errors->first('name') }}</strong>
                                </span>
                    @endif
                </div>

                <div class="form-group label-floating is-empty">
                    <label class="control-label">Email</label>
                    <input type="email" name="email" class="form-control" required>

                    @if ($errors->has('email'))
                        <span class="invalid-feedback">
                                    <strong>{{ $errors->first('email') }}</strong>
                                </span>
                    @endif
                </div>

                <div class="form-group label-floating is-empty">
                    <label class="control-label">Password</label>
                    <input type="password" name="password" class="form-control" required>

                    @if ($errors->has('password'))
                        <span class="invalid-feedback">
                                    <strong>{{ $errors->first('password') }}</strong>
                                </span>
                    @endif
                </div>

                <div class="form-group label-floating is-empty">
                    <label class="control-label">Confirm Password</label>
                    <input type="password" name="password_confirmation" class="form-control" required>
                </div>

                <div class="checkbox inline-block">
                    <label>
                        <input type="checkbox" class="checkbox-inline" value="">
                        I agree to the <a href="javascript:void(0)">terms of services</a>
                    </label>
                </div>
                <button type="submit" name="submit" class="btn btn-info btn-block m-t-40">Create my account</button>
            </form>
        </div>
        <div class="login-footer p-15">
            <p>
                Already have an account? <a href="javascript:void(0)" data-toggle="register">Sign In</a>
            </p>
        </div>
    </div>
</div>
Edit Your Profile
Update

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