davy_yg

davy_yg

Member Since 2 Years Ago

Jakarta

Experience Points
72,370
Total
Experience

2,630 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
349
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 15
72,370 XP
Nov
18
11 hours ago
Activity icon

Started a new Conversation Laravel.log

Normally laravel.log is divided into many dates. Mine is only showing laravel.log, any clue how to make it divided into many dates?

Nov
17
1 day ago
Activity icon

Replied to Storage Session Error

So those random session cache files to storage session right?

Activity icon

Replied to Calling View

So all modules should have this register views since it is non standard ?

Activity icon

Replied to Related Table

Cek the first video, it has no with - in it and it still works. Is it true?

Activity icon

Replied to Related Table

So to make table relation you have to use with in the Eloquent

and define the table relation:

public function productInventory()
    {
    return $this->hasOne(ProductInventory::class, 'sku', 'sku');
    }

when you use with so it's automatically knows the relation by calling this function correct?

Activity icon

Replied to Related Table

It's still not relating the table.

I want to call productinventory column named quantity. I thought I have to call productInventory() function to make the relation get quantity field.

It only loads ProductPriceList columns and ignore ProductInventory column (especially quantity).

Activity icon

Replied to Calling View

ServiceProvider.php

public function registerViews()
    {
    $viewPath = resource_path('views/modules/productInventory');

    $sourcePath = __DIR__ . '/../Resources/views';

    $this->publishes([
        $sourcePath => $viewPath
    ], 'views');

    $this->loadViewsFrom(array_merge(array_map(function ($path) {
        return $path . '/modules/productInventory';
    }, \Config::get('view.paths')), [$sourcePath]), 'productInventory');
    
}

Would you call this a package since it's only a module. It has ServiceProvider.php and ProductController.php and Views. I thought a package is something that you uploaded on git and you have to install it through composer require package_name ?

Activity icon

Started a new Conversation Related Table

Hello,

I would like to select related table:

HomeController.php

use Modules\ProductPriceList\Models\ProductPriceList;
...

$stock = ProductPriceList::where('product_catalog_id', $data->id)->productInventory()->quantity->first();

ProductPriceList.php

 public function productInventory()
    {
    return $this->hasOne(ProductInventory::class, 'sku', 'sku');
    }

In ProductInventory table has quantity field. Am I writing the selection correctly on HomeController.php ?

I also get this error message:

[2019-11-17 13:05:15] development.ERROR: Class 'App\Http\Controllers\ProductPriceList' not found

Nov
16
2 days ago
Activity icon

Started a new Conversation Calling View

ProductInventoryController.php

<?php

namespace Modules\ProductInventory\Http\Controllers;

use App\Exports\StockTemplateExport;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Cache;
use Maatwebsite\Excel\Excel;
use Modules\ProductCatalog\Models\ProductCatalog;
use Modules\ProductInventory\Http\Requests\StockBulk;
use Modules\ProductInventory\Http\Requests\Store;
use Modules\ProductInventory\Http\Requests\Update;
use Modules\ProductInventory\Models\ProductInventory;
use Modules\ProductInventory\Repositories\ProductInventoryRepository;
use Modules\ProductInventory\TableView\IndexTableView;
use Modules\ProductPriceList\Models\ProductPriceList;
use Yajra\Datatables\Datatables;

class ProductInventoryController extends Controller
{
    protected $repository;

    public function __construct(ProductInventoryRepository $repository)
    {
    $this->repository = $repository;
    }

    public function index()
    {
    $items = $this->repository->listAll()->paginate();

    return (IndexTableView::make($items))->view('productInventory::index');
    }

    public function create()
    {
    return view('productInventory::create', compact('sku'));
 }

I wonder why you can call this - productInventory::create

Activity icon

Started a new Conversation SQL Syntax

Hello,

I am trying to find the right syntax for SQL to query the db:

How do you translate this laravel SQL query to database:

ProductPriceList::leftJoin('product_inventories as pi', 'pi.sku', '=', 'product_price_lists.sku')
        ->where('product_price_lists.sku', '!=', '')
        ->join('product_catalogs', 'product_price_lists.product_catalog_id', '=', 'product_catalogs.id')
        ->where('product_catalogs.is_archive', '0')
        ->autosort()
        ->orderBy('quantity', 'desc')
        ->select('product_price_lists.*')
        ->with('ProductInventory')
        ->has('productCatalog');

This is what I try:

SELECT a.* WITH b FROM product_price_lists a LEFT JOIN product_inventory b ON b.sku = a.sku
WHERE a.sku != ''
JOIN product_catalogs c a.product_catalog_id = c.id
WHERE c.product_catalogs.is_archive = '0'
ORDER BY 'quantity' DESC
        

SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH b FROM product_price_lists a LEFT JOIN product_inventory b ON b.sku = a.sku' at line 1

Activity icon

Replied to Storage Session Error

I wonder why it even ask for that file. In my other computer the same file and db works just fine. After I copy it to my second my computer that error appears.

Why it even ask for that file?

Activity icon

Started a new Conversation Storage Session Error

After moving one web file and it's database to a new laptop, I get this error message:

file_put_contents(D:\xampp72\htdocs\aws_admin\storage\framework/sessions/fBEsflR577tG4HbxEzgo2VrDSOz48PSrsjovpAFT): failed to open stream: No such file or directory 

Which I do not understand what?

ref: https://laravel.com/docs/5.7/session

Why is it error? And what is storage/sessions for?

Activity icon

Replied to Transfering Data Through A Cross Cable

I do have home router. It is static ip for transfer right? So It doesn't have any effect on the router setting?

Activity icon

Replied to Transfering Data Through A Cross Cable

Yes, it is a cross cable

Activity icon

Started a new Conversation Transfering Data Through A Cross Cable

Does anyone ever successfully transfer data through a cross cable?

I have google for solution yet none works yet on my laptop.

How to set the ip address for both computer?

This is my current settings:

PC that share files:

IP address: 192.168.0.50
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.0.1

PC that will take the share files:

IP address: 192.168.0.70
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.0.1

 Preferred DNS Server: 8.8.8.8

I tested ping to: 192.168.0.50 Detination host unreachable

Any clue why?

I am using this cross cable:

ref: https://helpdeskgeek.com/networking/connect-two-computers-using-a-crossover-cable/

Nov
15
3 days ago
Activity icon

Awarded Best Reply on Video Does Not Appears

It finally works. I think because of my AV has the wrong set up. Now, the video works!

Activity icon

Replied to Video Does Not Appears

It finally works. I think because of my AV has the wrong set up. Now, the video works!

Nov
14
4 days ago
Activity icon

Replied to Video Does Not Appears

youtube videos work just fine. Vimeo web takes forever to loads - The connection has timed out.

Activity icon

Replied to Video Does Not Appears

Already enable the flash players. In all browsers: chrome, firefox and edge all of them do not show the videos. Either I enable or disable the pop blocker still does not do any good.

Activity icon

Started a new Conversation Video Does Not Appears

When I try to watch one of the Vue video:

https://laracasts.com/series/practical-vue-components/episodes/1

No video appears on my firefox browser. Any clue why?

Activity icon

Replied to Can't Find The Api

Registering controller is through routes then it is not through service provider, correct? I read the service provider doc already.

ref: https://laravel.com/docs/6.x/providers

watching videos on related topic is a good idea.

Activity icon

Replied to Can't Find The Api

Now, I understand about how to register the Routes/web.php part. Now, what about the controller?

ServiceProvider.php

<?php

namespace Modules\BankAccount\Providers;

use Illuminate\Database\Eloquent\Factory;

class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
    /**
    * Boot the application events.
    *
    * @return void
    */

public function boot()
    {
    $this->registerMenu();
    $this->registerTranslations();
    $this->registerConfig();
    $this->registerViews();
    $this->registerFactories();
    $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
    }

    /**
    * Register the service provider.
    *
    * @return void
    */

public function register()
    {
    $this->app->register(RouteServiceProvider::class);
    }

    /**
    * Register menu.
    *
    * @return void
    */

protected function registerMenu()
    {
    // if ($this->app->bound('laravolt.menu')) {
    //     $parent = app('laravolt.menu');

    //     $parent->add('Bank Account', route('bankAccount.index'))
    //         ->data('icon', 'circle outline')
    //         ->active('bank-account/*');
    // }
    }

    /**
    * Register config.
    *
    * @return void
    */

protected function registerConfig()
    {
    $this->publishes([
        __DIR__ . '/../Config/config.php' => config_path('bankAccount.php'),
    ], 'config');
    $this->mergeConfigFrom(
        __DIR__ . '/../Config/config.php',
        'bankAccount'
    );
    }

    /**
    * Register views.
    *
    * @return void
    */

public function registerViews()
 {
    $viewPath = resource_path('views/modules/bankAccount');

    $sourcePath = __DIR__ . '/../Resources/views';

    $this->publishes([
        $sourcePath => $viewPath
    ], 'views');

    $this->loadViewsFrom(array_merge(array_map(function ($path) {
        return $path . '/modules/bankAccount';
    }, \Config::get('view.paths')), [$sourcePath]), 'bankAccount');
    }

    /**
    * Register translations.
    *
    * @return void
    */

public function registerTranslations()
    {
    $langPath = resource_path('lang/modules/bankAccount');

    if (is_dir($langPath)) {
        $this->loadTranslationsFrom($langPath, 'bankAccount');
    } else {
        $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'bankAccount');
    }
    }

    /**
    * Register an additional directory of factories.
    *
    * @return void
    */

public function registerFactories()
    {
    if (! app()->environment('production')) {
        app(Factory::class)->load(__DIR__ . '/../Database/factories');
    }
    }

    /**
    * Get the services provided by the provider.
    *
    * @return array
    */

public function provides()
    {
    return [];
    }
}

In this case, it seems like the other dev do not register the controller as we do not use it. I am just supposing if in the future I need the module controller as well? So it's possible to register it and make the program read the module controller as well right? Looks like the view is also registered. But I do not see the point of registering it? since the controller that controls the view is not registered.

Activity icon

Replied to Can't Find The Api

Which RouteServiceProvider.php?

modules/ProductInventory/Providers/RouteServiceProvider.php

<?php

namespace Modules\ProductInventory\Providers;

use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
    /**
    * The module namespace to assume when generating URLs to actions.
    *
    * @var string
    */

protected $moduleNamespace = 'Modules\ProductInventory\Http\Controllers';

/**
    * Called before routes are registered.
    *
    * Register any model bindings or pattern based filters.
    *
    * @return void
    */

public function boot()
    {
    parent::boot();
    }

    /**
    * Define the routes for the application.
    *
    * @return void
    */
    
public function map()
    {
    $this->mapWebRoutes();
    }

    /**
    * Define the "web" routes for the application.
    *
    * These routes all receive session state, CSRF protection, etc.
    *
    * @return void
    */

protected function mapWebRoutes()
    {
    Route::middleware('web')
        ->namespace($this->moduleNamespace)
        ->group(__DIR__ . '/../Routes/web.php');
    }   
}

app/Providers/RouteServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\URL;

class RouteServiceProvider extends ServiceProvider  
{
    /**
    * This namespace is applied to your controller routes.
    *
    * In addition, it is set as the URL generator's root namespace.
    *
    * @var string
    */

    protected $namespace = 'App\Http\Controllers';

    /**
    * Define your route model bindings, pattern filters, etc.
    *
    * @return void
    */
    
public function boot()
    {
    if ($this->app->environment('production', 'staging')) {
        URL::forceScheme('https');
    }

    parent::boot();
    }

 /**
    * Define the routes for the application.
    *
    * @return void
    */

public function map()
    {
    $this->mapApiRoutes();

    $this->mapWebRoutes();

    //
    }

    /**
    * Define the "web" routes for the application.
    *
    * These routes all receive session state, CSRF protection, etc.
    *
    * @return void
    */

protected function mapWebRoutes()
    {
    Route::middleware('web')
         ->namespace($this->namespace)
         ->group(base_path('routes/web.php'));
    }

    /**
    * Define the "api" routes for the application.
    *
    * These routes are typically stateless.
    *
    * @return void
    */

protected function mapApiRoutes()
    {
    Route::prefix('api')
         ->middleware('api')
         ->namespace($this->namespace)
         ->group(base_path('routes/api.php'));
    }
}

I think the default laravel RouteServiceProvider.php still remains default.

Activity icon

Replied to Can't Find The Api

I finally find where it is located:

modules/ProductInventory/Routes/web.php

Route::group(
[
    'prefix' => '',
    'as' => '',
    'middleware' => ['web', 'auth'],
],
function () {
    Route::resource('productInventory', 'ProductInventoryController')
        ->only('index', 'create', 'store');

    Route::get('productInventory/template-stock', '[email protected]')
        ->name('productInventory.templateStock');

    Route::get('productInventory/get-all-sku', '[email protected]')
        ->name('productInventory.getAllSku');

    Route::get('productInventory/get-product/{sku}', '[email protected]')
        ->name('productInventory.getProductCatalog');

    Route::get('productInventory/get-stock-bulk', '[email protected]')
        ->name('productInventory.get-stock-bulk');

    Route::get('productInventory/get-stock-bulk-data', '[email protected]')
        ->name('productInventory.get-stock-bulk-data');

    Route::post('productInventory/post-stock-bulk', '[email protected]')
        ->name('productInventory.post-stock-bulk');

    Route::post('productInventory/proses-stock-bulk', '[email protected]')
        ->name('productInventory.proses-stock-bulk');
}
);

If I have modules folder in my root project directory will it automatically read the modules/ProductInventory/Routes/web.php ?

Activity icon

Replied to Can't Find The Api

It's not anywhere in my routes folder.

There is another thing: this path works just fine: http://127.0.0.1:8000/productInventory/create

Yet, the routes is not listed in any file in my routes folder: productInventory/create

I search my whole web project:

Searching 60561 files for "/productInventory/create"

0 matches

This is strange.

Activity icon

Started a new Conversation Can't Find The Api

Hello this is strange that I cannot find where the api is located?

 methods : {
        getSku: function () {
            axios
                .get('/productInventory/get-all-sku')
                .then(response => {
                   this.list_sku = response.data;
                });
        },

If I type on the browser: http://127.0.0.1:8000/productInventory/get-all-sku

I can see the api.

As far as I know all api address should be listed here:

routes/api.php

<?php

use Illuminate\Http\Request;

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::get('/search', '[email protected]')->name('cari.barang');
Route::get('/checkphone', '[email protected]')->name('cari.telepon');
Route::get('/checkemail', '[email protected]')->name('cari.email');

//product or price
Route::get('/stock/{priceId}', '[email protected]')->name('cari.email');

I wonder why this api : .get('/productInventory/get-all-sku')

Is not listed in the routes/api.php and still works just fine?

Activity icon

Replied to Vue2

I read the doc but still do not understand it. It seems like laracasts videos on vue scattered all around the place. It will takes me some times to watch all of them.

ref: https://vuejs.org/v2/api/#mounted

My guess mounted is where you populate all the value of the data, true? besides props:

mounted() {
        this.sku = this.prop_sku;
        this.quantity = this.prop_quantity;
        this.type = this.prop_type;
        this.product_stock = this.prop_product_stock;

        this.getSku();
        this.getProductCatalog();
        this.countTotal();
    },

Whereas props is where you define the data type:

props: {
        category_id: null,
        parent_id: null,
        prop_sku: String,
        prop_quantity: Number,
        prop_type: String,
        prop_product_stock: Number,
        list_sku: {
            default: []
        }
    },

ref: https://vuejs.org/v2/guide/components-props.html#ad

Nov
13
5 days ago
Activity icon

Replied to Redis

How to install redis on Win 10?

Activity icon

Commented on Installation And A Visitor Counter

I don't understand how to install redis in Win 10. I downloaded the redis-5.0.6.tar file and do not know how to run it. I also watched the video part 1 - 0:40 sec and do not know where to look for the same screen in Win 10. Any clue how to install redis on Win 10?

Activity icon

Started a new Conversation Redis

I am trying to install redis to make my website faster.

I watched this tutorial: https://laracasts.com/series/learn-laravel-and-redis-through-examples/episodes/1

There are part that I don't understand. For example: 0:40 sec

Where do you get that screen:

learn-redis git:(master) brew install redis

Note: I am using Win 10.

I open my cmd type:

C:\xampp\htdocs\sesa>brew install redis

'brew' is not recognized as an internal or external command, operable program or batch file.

In my laravel project directory and get an error.

Any clue why?

Activity icon

Replied to Searching Products Slow - Cache Image?

Or perhaps has something to do with the internet speed as well. Using a lot of repository and packages does effect the web speeds at all?

I heard using cache will makes website loads faster? Is it true? What kind of cache?

The Js already uses vuejs. Shouldn't it be optimized already?

Ever heard of Redis?

Activity icon

Replied to Searching Products Slow - Cache Image?

through input / search bar which hits the database.

Activity icon

Awarded Best Reply on Two Language

I already find solution to this problem:

FormServiceProvider.php

SemanticForm::macro(
        'textTranslateable',
        function ($name, $label = null, $options = []) {
            $locales = config('locales');
            $model = $this->model;

            $test = array();
            $test['en'] = $options['value'];
            $test['id'] = $options['value_2'];

            return view(
                'components.field.text-translatable',
                compact('locales', 'model', 'name', 'label', 'options', 'test')
            )->render();
        }
    );

voucher/edit.blade.php

<div class="field">
                       {!! SemanticForm::textTranslateable('description', 'Description', ['required' => true, 'value' => $voucherTrans->first()->description, 'value_2' => $voucherTrans->slice(1, 1)->first()->description]) !!}
                  </div>
Activity icon

Replied to Two Language

I already find solution to this problem:

FormServiceProvider.php

SemanticForm::macro(
        'textTranslateable',
        function ($name, $label = null, $options = []) {
            $locales = config('locales');
            $model = $this->model;

            $test = array();
            $test['en'] = $options['value'];
            $test['id'] = $options['value_2'];

            return view(
                'components.field.text-translatable',
                compact('locales', 'model', 'name', 'label', 'options', 'test')
            )->render();
        }
    );

voucher/edit.blade.php

<div class="field">
                       {!! SemanticForm::textTranslateable('description', 'Description', ['required' => true, 'value' => $voucherTrans->first()->description, 'value_2' => $voucherTrans->slice(1, 1)->first()->description]) !!}
                  </div>
Activity icon

Started a new Conversation Searching Products Slow - Cache Image?

When searching products are slow? What should we do?

ref: https://www.bitcatcha.com/blog/10-frustrating-reasons-why-your-website-speed-is-slow/

I heard someone suggest about cache images?

ref: http://image.intervention.io/use/cache

What is cache images? Is it decreasing the image resolution or quality?

Activity icon

Replied to Vue2

Yes, it's someone else code. Yet, it will help me learn much about vue. I only know basic about vue:

What is mounted? Is it where you get the props value being passed to the component ?

AddToWishlist.vue

mounted() {
        this.product_name = this.props_product_name;
        this.data_wishlist = this.props_data_whislist;
        this.rounded = this.props_rounded;
        this.price_id = this.props_price;
        this.id_whislist = this.props_id;
        this.$bus.$on('updateWishlist', data => {
            this.changeWishlsit(data);
        });

        this.$bus.$on('changeCartButton', data => {
            this.changeCartButton(data);
        });

        this.$bus.$on('syncWishlistButton', data => {
           this.syncWishlistButton(data);
        });
    },

ref: https://vuejs.org/v2/api/#mounted

I am on this tutorial: https://www.vuemastery.com

Nov
12
6 days ago
Activity icon

Replied to Vue

Vue.js is detected on this page. Devtools inspection is not available because it's in production mode or explicitly disabled by the author.

ref: https://github.com/vuejs/vue-devtools/issues/190

When you use vue.js do you have to pick two version the dev version and the production version?

Activity icon

Started a new Conversation Vue2

app.js

Vue.component('cart-sidebar', require('./components/CartSidebar.vue').default);

CartSidebar.vue

<cart-button
                            :props_product_name="cart.name"
                            :props_price='cart.price_id'
                            :props_qty='cart.qty'
                            :props_product_id='cart.id'
                            :props_sidebar="true"
                            :props_maturity="cart.kematangan || '-1'"
                    ></cart-button>

I wonder where you get cart.name from?

Activity icon

Replied to Vue

Now, that I already installed it through add-ons, how to use it?

Activity icon

Replied to WhereTranslation

I think I find part of the solutions:

Step 3: Models

    The translatable model Country should use the trait Dimsav\Translatable\Translatable.
    The convention for the translation model is CountryTranslation.

public function getTranslationModelName()
    {
    return $this->translationModel ?: $this->getTranslationModelNameDefault();
    }

    /**
    * @return string
    */

Translatable.php

public function getTranslationModelNameDefault()
    {
    $modelName = get_class($this);

    if ($namespace = $this->getTranslationModelNamespace()) {
        $modelName = $namespace.'\'.class_basename(get_class($this));
    }

    return $modelName.config('translatable.translation_suffix', 'Translation');
    }
Activity icon

Replied to WithTrashed

Is this deleting a model or a row?

$flight = App\Flight::find(1);

$flight->delete();
Activity icon

Replied to WithTrashed

If not using SoftDeletes trait then ->delete() will permanently delete the data, right?

Activity icon

Replied to WhereTranslation

I already read it once but do not understand why the table is not there. Why they use product_categories and product_category_translations table?

Activity icon

Started a new Conversation WhereTranslation

I wonder if this is laravel package?

ProductsCatalogRepository.php

$category = ProductCategory::whereTranslation('name', $name)->first();

ref: https://packagist.org/packages/dimsav/laravel-translatable

See the name column is in: product_category_translations

and ProductCategory table does not exist:

ProductCategory.php

class ProductCategory extends ModelTranslate implements HasMedia
{
use HasMediaTrait;

public $translatedAttributes = ['name', 'description', 'flag_product'];

protected $guarded = [];

protected $searchableColumns = ["description", "name"];

that exist only product_categories table.

Activity icon

Replied to WithTrashed

Another thing: How to soft delete data?

I thought both of them permanent delete and soft delete using ->delete();

Activity icon

Replied to WithTrashed

I probably understand it now. So to list all model that has been soft deleted I must use ->withTrashed().

Is it a list of data of a model that is being Transhed (listed in deleted_at ) ?

In my product_price_lists a few data are marked with deleted_at dates. So that's examples of withTrashed ?

Activity icon

Replied to WithTrashed

I only 1.5 year using Laravel. The other 6 months I am using CI. But I think I am going to focus on laravel. It's better off that way.

I cannot see the result of my query it's someone else code. So can you still see the result of the deleted model or data?

Activity icon

Started a new Conversation WithTrashed

ProductsCatalogRepository.php

 public function getWishlist(User $user)
{
    $idUser = $user->id;
    if ($user) {
         return ProductPriceList::has('productCatalog')->whereHas('productWishlist', function ($q) use ($idUser) {
            $q->where('user_id', $idUser);
         })->with('productCatalog')->withTrashed()->paginate(8);
    }
}

What is withTrashed for? Showing deleted model? What is soft deleted?

ref: https://laravel.com/docs/5.8/eloquent

Nov
11
1 week ago
Activity icon

Started a new Conversation Two Language

Hello,

I am trying to pull data for description for edit form in two languages:

edit.blade.php

<div class="field">
                       {!! SemanticForm::textTranslateable('description', 'Description', ['required' => true, 'value' => $voucherTrans->first()->description]) !!}
                  </div>

FormServiceProvider.php

 SemanticForm::macro(
        'textTranslateable',
        function ($name, $label = null, $options = []) {
            $locales = config('locales');
            $model = $this->model;

            return view(
                'components.field.text-translatable',
                compact('locales', 'model', 'name', 'label', 'options')
            )->render();
        }
    );

text-translatable.blade.php

 @foreach($locales as $key => $value)
    <?php $active = ''; ?>
    <?php if ($key == config('app.locale')) $active = 'active'; ?>
    <div class="ui segment bottom attached tab {{ $active }}" data-tab="tab{{ $name.$key }}">
        
        <input type="text" name="{{ $name }}[{{ $key }}]" value="{{ $options['value'] }}" style="direction: {{ $value['direction'] }}">
    </div>
@endforeach

VoucherController.php

public function edit($id)
    {
    $voucher = $this->voucher_repo->getEdit($id);

    $voucherTrans = VoucherTranslation::where('voucher_id', $id)->get();
    // dd($voucherTrans);

    return view('voucher.edit', compact('voucher', 'voucherTrans'));
    }

The result of: dd($voucherTrans);

Array[0] #original: array:6 [ "id" => 11 "voucher_id" => 14 "locale" => "en" "description" => "Brand New" "created_at" => "2019-11-11 15:15:36" "updated_at" => "2019-11-11 15:15:36" ] #changes: []

Array[1] #original: array:6 [ "id" => 12 "voucher_id" => 14 "locale" => "id" "description" => "Baru Release" "created_at" => "2019-11-11 15:15:36" "updated_at" => "2019-11-11 15:15:36" ]

I only successful showing the en (English version) but do not know how to show the id (Indonesian version). Right now, the Indonesian version is filled with the English version - "Brand New" which is not suppose to be like that.

Any clue how to fix this?

Activity icon

Replied to 'description' Of Non-object

It's getting so close.

text-translatable.blade.php

<input type="text" name="{{ $name }}[{{ $key }}]" value="{{ $options['value'] ? $options['value'] : '' }}" style="direction: {{ $value['direction'] }}">

FormServiceProvider.php

SemanticForm::macro(
        'textTranslateable',
        function ($name, $label = null, $options = []) {
            $locales = config('locales');
            $model = $this->model;

            if($options[] == null){
                $options['value'] = null;
            }

            return view(
                'components.field.text-translatable',
                compact('locales', 'model', 'name', 'label', 'options')
            )->render();
        }
    );

I am trying to say if options['value'] is undefine then it should be set to null so that my form create will works or use empty value, except for edit.

Any clue how to ?