m.donicova

m.donicova

Valasske Mezirici

Member Since 3 Years Ago

Experience Points 14,170
Experience
Level
Lessons Completed 133
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

22 Jun
5 months ago

m.donicova started a new conversation Photo Gallery Thumbnails For Images With Various Dimension

I create the simple photo gallery with Laravel and Intervention image. Each photo I resize to width 640 px and then upload to server. For web I am using Bootstrap 3. I have problem. But some photo have landscape and other portrait orientation a this produce problem with grid in html http://trhy.muvalmez.cz/foto. Please how I solve this problem.

26 Mar
8 months ago

m.donicova left a reply on Migrate For Testing Database

The problem was on my hand the file I name env.testing, after rename to correct .env.testing migration is OK.

m.donicova left a reply on Migrate For Testing Database

I have two database production and testing

php artisan migrate create schema for production database php artisan migrate --env´=testingfail with Nothing to migrate and no schema in mysql and nothing to truncate.

Did you mean production database?

m.donicova left a reply on Migrate For Testing Database

Yes I run migration for production database.

25 Mar
8 months ago

m.donicova started a new conversation Migrate For Testing Database

I install L 5.6 and try use mysql as testing database in config/database.php i have

        'mysql_test' => [
            'driver' => 'mysql',
            'host' => env('DB_TEST_HOST', '127.0.0.1'),
            'port' => env('DB_TEST_PORT', '3306'),
            'database' => env('DB_TEST_DATABASE', 'testing'),
            'username' => env('DB_TEST_USERNAME', 'homestead'),
            'password' => env('DB_TEST_PASSWORD', 'secret'),
            'unix_socket' => env('DB_TEST_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

create env.testing

APP_NAME=Laravel
APP_ENV=testing
APP_KEY=base64:wPLFWzttKClidBk8oOv+lar7K9inLuzPXL4jp7zYesM=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql_test
DB_TEST_HOST=127.0.0.1
DB_TEST_PORT=3306
DB_TEST_DATABASE=testing
DB_TEST_USERNAME=homestead
DB_TEST_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

and phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>

        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="MAIL_DRIVER" value="array"/>
    </php>
</phpunit>

when I try php artisan migrate --env=testing I obtain Nothing to migrate

Where is problem in my setup MySQL as a testing db?

15 Dec
1 year ago

m.donicova left a reply on Laravel-mix Error Npm Run Watch

I upgarde node, delete node_modules again npm install and sti11 same problem

14 Dec
1 year ago

m.donicova left a reply on Laravel-mix Error Npm Run Watch

yes first I run

npm install

m.donicova left a reply on Laravel-mix Error Npm Run Watch

yes in vagrant ssh on homestead vm

m.donicova left a reply on Laravel-mix Error Npm Run Watch

This produce the same error

m.donicova started a new conversation Laravel-mix Error Npm Run Watch

Hi all,

on windows 7 I am using laravel Homested for developing. When in Laravel homestead i try run

npm run watch

I obtain error

> @ watch /home/vagrant/code/Laravel
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: 1: cross-env: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT

my package.json

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.17",
        "bootstrap-sass": "^3.3.7",
        "cross-env": "^5.1",
        "jquery": "^3.2",
        "laravel-mix": "^1.0",
        "lodash": "^4.17.4",
        "vue": "^2.5.7"
    }
}
30 Oct
1 year ago

m.donicova started a new conversation How Add HTML Tag To Flash Messages

In Controller I have this code

   $message = 'Položka '. $product->name. ' byla přidána do košíku';

    return redirect()->back()->with('message', $message);

and in view display it with

    @if(session('message'))
        <div id="success-alert" class="alert alert-success">
            <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
            {{ session('message') }}
        </div>
    @endif

Now I want to $product->name a display in view with bold tag. How i do this?

09 Oct
1 year ago

m.donicova left a reply on Problem In Code After Upgrade To Laravel 5.4

No this is my Order model

class Order extends Model
{
    protected $fillable = ['customer_id', 'status'];

    public function items()
    {
        return $this->belongsToMany('App\Product', 'order_product')->withPivot('quantity', 'price');
    }

    public function customer()
    {
        return $this->hasOne('App\Customer', 'id', 'user_id');
    }
}

m.donicova started a new conversation Problem In Code After Upgrade To Laravel 5.4

I have code

    public function index()
    {
        $orders = Order::with('items','customer')->orderBy('id', 'desc')->paginate(5);
        foreach ($orders as $order) {
            $items = Order::find($order->id)->items()->get();
            $sum_order[$order->id] = 0;
            foreach ($items as $item) {
                $sum_order[$order->id] += $item->pivot->quantity*$item->pivot->price;
            }
            $order['sum'] = $sum_order[$order['id']];
        }
        foreach ($orders as $order) {
            $order['name'] = ucfirst(substr($order->customer->firstname,0,1)).'.'.$order->customer->lastname;
        }
        return view('admin.orders', ['orders' => $orders]);
    }

this code work in instalattion Lravarl 5.3

now I upgrade to laravel 5.4 and code is broken, especially row

$order['name'] = ucfirst(substr($order->customer->firstname,0,1)).'.'.$order->customer->lastname;

produce the error Trying to get property of non-object

03 May
1 year ago

m.donicova left a reply on Autopopulate Select Option From Ajax Get Request

Thank you for your code, I must edit it to this

      $.getJSON('/free/'+id , function(data){
           $.each(data,function(item,value){
               $.each(value, function (id, option){
                   select.append(
                   $('<option>').attr('value',option).text(option)
                   );
               });
           });
       });

because JSON get obj with one item with value as array of numbers this code get right output

m.donicova started a new conversation Autopopulate Teh Select Option From Ajax Get Request

I have this in Controller to get array of nubers as free values

    public function getFreePlace($id)
    {
        $all = range(1,25);
        $occupied = DB::table('reservations')->where('date_id',$id)->pluck('place');
        $free = array_diff($all,$occupied->toArray());
        retrun $free;
    }

in view i have select

                  <div class="form_group">
                        <label for="place">Číslo místa:</label>
                        <select name="place" class="form-control">

                        </select>
                    </div>

and i want with ajax getFreePlace array as value for option for this select i try something like this

    $(document).ready(function() {

        $.ajaxSetup({
        headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
        });
    
        
        var id = $(this).data('id');
        var url = "/free/"+id;
    
        $.ajax({
    
        type: "GET",
        url: url,
        data: ,
        success:
        error:
        });
    });

in route i have

Route::get('/free/{id}', '[email protected]');

and in form i have hidden iput for id

 <input type="hidden" name="date_id" value="{{ $date_id }}" data-id="{{ $date_id }}">
24 Mar
1 year ago

m.donicova left a reply on Add To Cart With AJAX And Modal

Now I have another problem I have in master layout in navigation this code for number of products in cart

<a href="{{ URL::to('cart') }}"><i class="glyphicon glyphicon-shopping-cart"></i> Košík <span class="badge">{{ $cart_qty }}</span></a>

for $cart_gty i use view composer

        View::composer('layouts.master', function($view) {
            $cart_qty =  Session::get('cart') ? array_sum(array_column(Session::get('cart'), 'qty')) : 0;
            $view->with('cart_qty',$cart_qty);
        });

how I update this wehn i add product to cart with ajax (before I added wih controller and reload the page). Must I reload by JQUery.

I try find the better solution

m.donicova left a reply on Add To Cart With AJAX And Modal

ajaxSetup must be set for JQuery

$(document).ready(function() {
        $.ajaxSetup({
        headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
        });

        $('a#add').click( function() {
            var product_id = $(this).data('id');
            var url = "/ajaxadd";



            $.ajax({

            type: "POST",
            url: url,
            data: { product_id: product_id },
            success: function (data) {
            console.log(data);

            },
            error: function (data) {
            console.log('Error:', data);
            }
            });
        });
    });

m.donicova left a reply on Add To Cart With AJAX And Modal

whoops another stupid mistake url must be

var url = "/ajaxadd"

m.donicova left a reply on Add To Cart With AJAX And Modal

of course I edit in many times and I one of the edit i must remove on click function now I have this

    $(document).ready(function() {

        $('a#add').click( function() {
            var product_id = $(this).data('id');
            var url = "/ajaxadd/";

            $.ajaxSetup({
                headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $.ajax({

            type: "POST",
            url: url,
            data: { id: product_id },
            success: function (data) {
            console.log(data);

            },
            error: function (data) {
            console.log('Error:', data);
            }
            });
        });
    });

in this time I have the

MethodNotAllowedHttpException in RouteCollection.php line 218: error in routes I have

Route::post('/ajaxadd', '[email protected]');

PS: skype nepouzivam

m.donicova left a reply on Add To Cart With AJAX And Modal

I smething try but It seems to be wrong

in view I have

<a href="#" id="add" class="btn btn-primary" data-id="{{ $product->id }}">Koupit</a>

and the script

    $(document).ready(function() {

        var product_id = $(this).data('id');
        var url = "/ajaxadd/";
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        $.ajax({

            type: "POST",
            url: url,
            data: { id: product_id },
            success: function (data) {
            console.log(data);

            },
            error: function (data) {
            console.log('Error:', data);
            }
        });
    });

and in the controller I have

    public function ajaxAdd(Request $request) {
        $id = $request->input('product_id');
        $session = $request->session();
        $cartData = ($session->get('cart')) ? $session->get('cart') : array();
        if (array_key_exists($id, $cartData)) {
            $cartData[$id]['qty']++;
        } else {
            $cartData[$id] = array(
                'qty' => 1
            );
        }
        $request->session()->put('cart', $cartData);
        //return redirect()->back()->with('message', 'Product Added Successfully!');
        return response()->json(['msg' => $id], 200);
    }

but this is not function

22 Mar
1 year ago

m.donicova started a new conversation Add To Cart With AJAX And Modal

Hi all I have a simple shop in Laravel where i have for add the product to cart this

<div class="buy">
        <form method="POST" action="{{ URL::to('addcart') }}" class="form-inline" role="form">
            {{ csrf_field() }}
            <input type="hidden" name="product_id" value="{{ $product->id }}">
            <button type="submit"  class="btn btn-primary">Koupit</button>
          </form>
</div>

and for addcart I have

public function postAdd(Request $request) {
        $id = $request->input('product_id');
        $session = $request->session();
        $cartData = ($session->get('cart')) ? $session->get('cart') : array();
        if (array_key_exists($id, $cartData)) {
            $cartData[$id]['qty']++;
        } else {
            $cartData[$id] = array(
                'qty' => 1
            );
        }
        $request->session()->put('cart', $cartData);
        return redirect()->back()->with('message', 'Product Added Successfully!');
    }

now I want for click on submit button show the modal with the information that the product was added to cart a in the same modal to display the actual cart and dispaly two button one for continue in shopping and another for checkout.

I think this must bu some ajax call but in dont know where to start. Is there any example how to solve this? For design I am using the bootstrap and the full code I have on github https://github.com/mardon/MaMushashop

09 Oct
2 years ago

m.donicova started a new conversation Sum Of Price Column In Pivot Table

I have Order an Product and I use pivot table for adding product to order

Schema::create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned()->index();
            $table->string('status');
            $table->timestamps();
        });

Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->text('description');
            $table->string('slug')->unique;
            $table->decimal('price',10,2);
            $table->timestamps();
        });

Schema::create('order_product', function (Blueprint $table) {
            $table->integer('order_id')->unsigned()->index();
            $table->foreign('order_id')->references('id')->on('orders');
            $table->integer('product_id')->unsigned()->index();
            $table->foreign('product_id')->references('id')->on('products');
            $table->integer('quantity');
            $table->decimal('price',10,2);
            $table->timestamps();
        });

now I try select all orders with sum of all products

02 Oct
2 years ago

m.donicova left a reply on Eloquent Relationship For Order, Order_items And Products

No one ot this is function in my application

m.donicova started a new conversation Eloquent Relationship For Order, Order_items And Products

Hi I have Order, Order_items, Customer and Product in my application

order migration and relatioship

Schema::create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id');
            $table->string('status');
            $table->timestamps();
        });

public function customer()
    {
        return $this->hasOne('App\Customer','id');
    }

customer

Schema::create('customers', function (Blueprint $table) {
            $table->increments('id');
            $table->string('firstname');
            $table->string('lastname');
            $table->string('street');
            $table->string('city');
            $table->string('psc');
            $table->string('email');
            $table->string('phone');
            $table->timestamps();
        });

order_items

Schema::create('order_items', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id');
            $table->integer('product_id');
            $table->integer('quantity');
            $table->decimal('price',10,2);
            $table->timestamps();
        });

public function product()
    {
        return $this->hasOne('App\Product','id');
    }
}

and Product

Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->text('description');
            $table->string('slug')->unique;
            $table->decimal('price',10,2);
            $table->timestamps();
        });

in administartion I have controller for one order detailas, where i need to dispaly customer information, order_items with product name

public function detail($id)
    {
        $order = Order::find($id);

        return view('admin.detail', ['order' => $order]);

    }

and view

@extends('layouts.admin')

@section('content')
    <div class="row">
        {{ $order->customer->firstname }}
    </div>
    <ul>
    @foreach ($order->items as $item)
        <li>{{ $item->product->name }}</li>
    @endforeach
    </ul>
@stop

but this is not function, where is my mistake to work with relationship

30 Sep
2 years ago

m.donicova left a reply on Disable Registration In Built-in Registration Laravel 5.3

I disable Auth::routes()

and added

// Login Routes... Route::get('login', ['as' => 'login', 'uses' => 'Auth\[email protected]']); Route::post('login', ['as' => 'login.post', 'uses' => 'Auth\[email protected]']); Route::post('logout', ['as' => 'logout', 'uses' => 'Auth\[email protected]']);

// Registration Routes... // Route::get('register', ['as' => 'register', 'uses' => 'Auth\[email protected]']); // Route::post('register', ['as' => 'register.post', 'uses' => 'Auth\[email protected]']);

// Password Reset Routes... Route::get('password/reset', ['as' => 'password.reset', 'uses' => 'Auth\[email protected]']); Route::post('password/email', ['as' => 'password.email', 'uses' => 'Auth\[email protected]']); Route::get('password/reset/{token}', ['as' => 'password.reset.token', 'uses' => 'Auth\[email protected]']); Route::post('password/reset', ['as' => 'password.reset.post', 'uses' => 'Auth\[email protected]']); });

m.donicova left a reply on Disable Registration In Built-in Registration Laravel 5.3

Method App\Http\Controllers\Auth\RegisterController::showRegistrationForm() does not exist

m.donicova left a reply on Disable Registration In Built-in Registration Laravel 5.3

Laravel version 5.3.9 have not AuthController

m.donicova started a new conversation Disable Registration In Built-in Registration Laravel 5.3

I use built-in authentication in laravel 5.3 , but I want disable user registration. What is the best solution for this?

m.donicova left a reply on How To Add A New Element To Every Item Of Collection?

Yes, you help this i my code

    $orders = Order::all();
        
        $orders->map(function ($order) {
            $order['price'] = $order->items->sum('price');
            return $order;
        });

m.donicova started a new conversation How To Add A New Element To Every Item Of Collection?

How to add a new element to every item of collection?

I have Order and Order_items, Order hasMany Order_items public function items() { return $this->hasMany('App\Order_item'); }

i want to Order::all collection add to each order price whis is Order::find(1)->items->sum('price')

07 Jan
2 years ago

m.donicova left a reply on Session Store Not Set On Request.

If you mean permisson to storage directory i was set recursively to 777

m.donicova started a new conversation Session Store Not Set On Request.

I develop my minieshop on localhost with windows when i move the application to Ubuntu 14.04 i get error

Session store not set on request.