PaulDiamant

Experience

1,820

1 Best Reply Awards

  • Member Since 2 Years Ago
  • 3 Lessons Completed
  • 0 Favorites

14th December, 2017

PaulDiamant left a reply on Call To A Member Function IsAdmin() On Null • 6 months ago

Try using the Auth facade to get the user, not through the request object in the middleware.

8th November, 2017

PaulDiamant started a new conversation Question About Database Design For Product Orders • 7 months ago

I'm working on an ecommerce platform, and have a products table, orders table and orders_products table. Should I save the price of the single item in the orders_products table or fetch it every time the user goes to their cart and after they make a purchase?

6th November, 2017

PaulDiamant left a reply on Socialite And Angular 4 • 7 months ago

Your only option is to use their JavaScript sdk.

PaulDiamant left a reply on Laravel - Like \ Dislike System • 7 months ago

'likeable_id' is either the post or reply ID, likeable type is the model class name, for example likeable_type can be 'App\Post' or 'App\Reply'

posts id, user_id, channel_id, post_title, post_text, slug replies id, user_id, post_id, reply_text

likes id, body - text likeable_id - integer likeable_type - string like_type - tinyint 0 = dislike 1 = like

Like Model

class Like extends Model
{
    public function likeable()
    {
        return $this->morphTo();
    }
}

Place this in your post/reply model:

 public function likes()
    {
        return $this->morphMany('App\Like', 'likeable');
    }

4th November, 2017

PaulDiamant left a reply on Help With Building A Query To Retrieve Colors • 7 months ago

@vapenation I did this just now and added 2 tables, and changed the product_colors and product_sizes table to a belongsToMany relationship basically.

colors:
    id, value, hex
sizes:
    id, value

product_colors:
    product_id, color_id
product_sizes:
    product_id, size_id

And now my query looks like:

$cat_ids = [1, 2, 3, 4];
        $products = Product::whereHas('categories', function ($q) use ($cat_ids) {
            return $q->whereIn('id', $cat_ids);
        })->with(['colors', 'sizes', 'brand'])->get();
        $colors = collect($products->pluck('colors'))->flatten()->pluck('value', 'id');
        dd($colors->toArray());

The results:

array:6 [▼
  1 => "Yellow"
  3 => "Black"
  5 => "Orange"
  4 => "Gray"
  2 => "White"
  6 => "Purple"
]

PaulDiamant left a reply on Help With Building A Query To Retrieve Colors • 7 months ago

@kpasokhi How badly will that affect performance if I have 2000 products for example?

PaulDiamant left a reply on Help With Building A Query To Retrieve Colors • 7 months ago

@vapenation No, a product can have multiple colors.

PaulDiamant started a new conversation Help With Building A Query To Retrieve Colors • 7 months ago

I have the following db structure:

products: id, product_id, name, desc, etc...
categories: id, name, slug
product_category: product_id, category_id
product_colors: id, product_id, hex, name

I also have the route: /category/{slug}, where a user sees all products under a category, with a sidebar for filtering them by price and other categories. What is the best way to retrieve all product colors specifically the products that were loaded under a category, distinct values also, so there won't be duplicate colors.

Product.php:

public function categories() {
    return $this->belongsToMany(Category::class, 'product_category');
}

public function colors() {
    return $this->hasMany(ProductColor::class);
}

Category.php

public function product() {
    return $this->belongsToMany(Product::class, 'product_category');
}

ProductColor.php

public function product() {
    return $this->belongsTo(Product::class);
}

2nd November, 2017

PaulDiamant left a reply on Get Products Under A Category With Pivot Table • 7 months ago

@Snapey I've got the same structure as you posted above, but the queries I provided in the previous post are both different, the first one is the one I wrote in a raw DB::select and the second one is what Eloquent generates, yet it doesn't work simply because the INNER JOIN is correct in what Eloquent generates:

inner join `product_categories` on `products`.`id` = `product_categories`.`product_id`

What I wrote:

 INNER JOIN `product_categories` ON `product_categories`.`category_id` = ?

And this is the products method in Category model:

public function products() {
        return $this->belongsToMany('App\Product', 'product_categories', 'category_id', 'product_id');
    }

PaulDiamant left a reply on Get Products Under A Category With Pivot Table • 7 months ago

@aginev

I've tried many things now and finally created a raw db expression with the following:

public function countCategoryProducts($category_id) {
        $category_id = filter_int($category_id);
        $count = DB::select('SELECT COUNT(*) as AGGREGATE FROM `products` INNER JOIN `product_categories` ON `product_categories`.`category_id` = ? WHERE `product_categories`.`product_id` = `products`.`id`', [$category_id]);
        return $count[0];
    }

When I call the belongsToMany method, this is what I get:

select count(*) as aggregate from `products` inner join `product_categories` on `products`.`id` = `product_categories`.`product_id` where `product_categories`.`category_id` = ?  

Pretty similar, the only difference is that the second query flips the WHERE and ON hence it does not return the right count, I really have no idea how to achieve this using eloquent only, if anyone knows please let me know.

PaulDiamant left a reply on Get Products Under A Category With Pivot Table • 7 months ago

@aginev Its having count because I'm asking for the count of products explicitly using $category->products()->count(). Otherwise to get the products you just remove the parenthesis from the products().

PaulDiamant left a reply on Get Products Under A Category With Pivot Table • 7 months ago

@aginev Doesn't seem to work,

 public function products() {
        return $this->belongsToMany('App\Product', 'product_categories', 'category_id', 'product_id');
    }

The Query that runs:

 select count(*) as aggregate from `products` inner join `product_categories` on `products`.`id` = `product_categories`.`product_id` where `product_categories`.`category_id` = ?

And I believe the query checks for product ID as well which is not what I need, because I'm only checking against a category_id, is there a way to tell belongsToMany which columns to compare?

PaulDiamant started a new conversation Get Products Under A Category • 7 months ago

I have a pivot table 'product_categories' with the following structure:

product_id, category_id

I can get all categories under a product using belongsToMany, but how do I get all products under a category using Eloquent?

31st October, 2017

PaulDiamant left a reply on Distant Relationship, Select Brands That Products Use • 7 months ago

@shez1983 and how does prod.categories relate to the brands? Where would I put it?

PaulDiamant started a new conversation Distant Relationship, Select Brands That Products Use • 7 months ago

I'm working on an ecommerce app, and I have the following tables:

products:
id, name, description, category_id, brand_id, sku, created_at... etc
brands:
id, name
categories:
id,name,parent_id

Say I have this, to retrieve products with those categories, how will I also retrieve all brands that products use without having duplicates? Since different brands can have the same brand, so it won't be displayed in the filtering sidebar.

$products = Product::whereIn('category_id', [1, 2, 3])->get();

30th October, 2017

PaulDiamant left a reply on No Application Encryption Key Specified Random Errors • 7 months ago

@Bouba Are developing locally under local host or via php artisan serve? O have a feeling this might be caused by using a custom hostname on windows as shop.dev.

PaulDiamant left a reply on No Application Encryption Key Specified Random Errors • 7 months ago

@RamjithAp Tried this already, no change.

PaulDiamant started a new conversation No Application Encryption Key Specified Random Errors • 7 months ago

Sometimes I get a 500 error when I refresh too fast or submit a form, although it's very rare it's still annoying. I've on idea why it's happening... here's the log:

[2017-10-30 12:10:35] production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:42)
[stacktrace]
#0 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Support\helpers.php(1035): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(NULL)
#1 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(46): tap(NULL, Object(Closure))
#2 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(24): Illuminate\Encryption\EncryptionServiceProvider->key(Array)
#3 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(749): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
#4 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(631): Illuminate\Container\Container->build(Object(Closure))
#5 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(586): Illuminate\Container\Container->resolve('encrypter', Array)
#6 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(721): Illuminate\Container\Container->make('encrypter', Array)
#7 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(885): Illuminate\Foundation\Application->make('encrypter')
#8 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(813): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#9 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(780): Illuminate\Container\Container->resolveDependencies(Array)
#10 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(631): Illuminate\Container\Container->build('App\\Http\\Middle...')
#11 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(586): Illuminate\Container\Container->resolve('App\\Http\\Middle...', Array)
#12 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(721): Illuminate\Container\Container->make('App\\Http\\Middle...', Array)
#13 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(138): Illuminate\Foundation\Application->make('App\\Http\\Middle...')
#14 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#15 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#16 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Router.php(647): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Router.php(622): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#18 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Router.php(588): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#19 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Router.php(577): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#20 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#21 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#22 C:\xampp\shop\app\Http\Middleware\GeneralMiddleware.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#23 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): App\Http\Middleware\GeneralMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 C:\xampp\shop\vendor\fideloper\proxy\src\TrustProxies.php(56): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#26 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#27 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#28 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#29 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#32 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#34 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#35 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#38 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(149): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#41 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#42 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#43 C:\xampp\shop\public\index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#44 {main}
"} 
[2017-10-30 12:10:35] production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:42)
[stacktrace]
#0 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Support\helpers.php(1035): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(NULL)
#1 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(46): tap(NULL, Object(Closure))
#2 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(24): Illuminate\Encryption\EncryptionServiceProvider->key(Array)
#3 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(749): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
#4 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(631): Illuminate\Container\Container->build(Object(Closure))
#5 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(586): Illuminate\Container\Container->resolve('encrypter', Array)
#6 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(721): Illuminate\Container\Container->make('encrypter', Array)
#7 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(885): Illuminate\Foundation\Application->make('encrypter')
#8 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(813): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#9 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(780): Illuminate\Container\Container->resolveDependencies(Array)
#10 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(631): Illuminate\Container\Container->build('App\\Http\\Middle...')
#11 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Container\Container.php(586): Illuminate\Container\Container->resolve('App\\Http\\Middle...', Array)
#12 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(721): Illuminate\Container\Container->make('App\\Http\\Middle...', Array)
#13 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(215): Illuminate\Foundation\Application->make('App\\Http\\Middle...')
#14 C:\xampp\shop\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(189): Illuminate\Foundation\Http\Kernel->terminateMiddleware(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))
#15 C:\xampp\shop\public\index.php(60): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))
#16 {main}
"} 

26th October, 2017

PaulDiamant left a reply on Mail Markdown Vendor Broken • 7 months ago

@m1guelpiedrafita The problem was my indentation in the view, seems like laravel 5.5 doesn't accept indentation in email markdowns it all has to be in one line.

25th October, 2017

PaulDiamant started a new conversation Mail Markdown Vendor Broken • 7 months ago

I'm using laravel's default mail markdown and it seems to be broken: https://image.prntscr.com/image/jIdQCAGSSNiybiTSegk7Sg.png Same happens when viewing mailables in browser or actually sending them, any idea why?

4th October, 2017

PaulDiamant left a reply on Eloquent WhereHas Issue • 8 months ago

Fixed it this way:

        $posts = $apiKey->posts()
            ->when($bySlug !== false, function ($query) use ($bySlug) {
                return $query->where('slug', $bySlug);
            })
            ->when($byStatus !== false, function ($query) use ($byStatus) {
                return $query->where('status', $byStatus);
            })
            ->when($orderData !== false, function ($query) use ($orderData) {
                foreach ($orderData as $key => $order) {
                    $query->orderBy($key, $order);
                }
            });

        if($byAuthor)  {
            $posts = $posts->whereHas('author', function ($query) use ($byAuthor) {
                if($byAuthor !== false) {
                    $query->where('slug', $byAuthor);
                }
            });
        }

        if($byCategory) {
            $posts = $posts->whereHas('categories', function ($query) use ($byCategory) {
                if($byCategory !== false) {
                    $query->where('category_slug', $byCategory);
                }
            });
        }

        if($byTag) {
            $posts = $posts->whereHas('tags', function ($query) use ($byTag) {
                if($byTag !== false) {
                    $query->where('tag_slug', $byTag);
                }
            });
        }

        $posts = $posts->with(['categories', 'tags', 'author', 'apiKey'])->get();

PaulDiamant started a new conversation Eloquent WhereHas Issue • 8 months ago

I have the following code in an API I built. My problem is that when I pass either a category or tag slug the whereHas methods are being called, and then run the WHERE conditional to retrieve posts under the category/tag. Problem is having posts with no tags or categories, because the whereHas only works on posts that have at least one category and tag, hence the posts being retrieved without specifying a category or tag are only posts with tags/categories. How can I make this work with fetching all posts while also calling the whereHas method on the model.

 $posts = $apiKey->posts()
            ->when($bySlug !== false, function ($query) use ($bySlug) {
                return $query->where('slug', $bySlug);
            })
            ->when($byStatus !== false, function ($query) use ($byStatus) {
                return $query->where('status', $byStatus);
            })
            ->when($orderData !== false, function ($query) use ($orderData) {
                foreach ($orderData as $key => $order) {
                    $query->orderBy($key, $order);
                }
            })
            ->whereHas('author', function ($query) use ($byAuthor) {
                if($byAuthor !== false) {
                    $query->where('slug', $byAuthor);
                }
            })
            ->whereHas('categories', function ($query) use ($byCategory) {
                if($byCategory !== false) {
                    $query->where('category_slug', $byCategory);
                }
            })
            ->whereHas('tags', function ($query) use ($byTag) {
                if($byTag !== false) {
                    $query->where('tag_slug', $byTag);
                }
            })
            ->with(['categories', 'tags', 'author', 'apiKey'])->get();

25th September, 2017

PaulDiamant started a new conversation Laravel Passport And Web Authentication • 8 months ago

What is the best way to avoid code duplication ? Im creating a website along with an app for it. Both will consume the same database so and I know that laravel has built in authentication but it only accommodates for web apps and not API's . Is it possible to use passport for authentication for both web and app api's? I'm a tad confused on whether I should separate api routes from web app routes or create conjoined routes for both api and website, but then again how would the authentication work via a session or access tokens

15th September, 2017

PaulDiamant left a reply on Laravel And An API For Mobile Application • 9 months ago

@NicoBeta So I shouldn't use sessions for authentication and instead use tokens for both web and mobile app? Or one API that can be consumed by many applications that also verifies the request origin, so for example if the request was made by web the session must be valid or if the request was made via an app then it checks for JWT token.

PaulDiamant started a new conversation Laravel And An API For Mobile Application • 9 months ago

I'm developing a website which will probably require an app as well, however I was wondering how I should go about handling user authentication for mobile apps that can retrieve the same data that Laravel does, from the database. I know that API's should be stateless using a token, and I've used JWT before and also heard of OAuth, is there a difference between those two? Should I also create API routes for managing the website so I can also integrate HTTP calls in the app to those API routes?

On another subject, I am going to use Ionic/Angular or something to create a hybrid app, unless it is not recommended....

21st August, 2017

PaulDiamant left a reply on General Question About Packages • 10 months ago

@martinbean OctoberCMS is based on Laravel, so I want to create something similar under Laravel. An installation route will be available to install and migrate all databases. I just don't know how to approach this concept in a better way, to allow other users to create plugins etc, for example a plugin that add points to the users.

PaulDiamant started a new conversation General Question About Packages • 10 months ago

I'm planning to make a forum software, similar to PHPBB etc in Laravel and allow other people to create plugins of their own. Is it sensible that plugins to the system will be made as separate packages? Considering the forum system itself isn't going to be a package but a whole laravel installation which will install the forum on the server, including database migrations etc. Same goes for themes, should there be a config file for the forum with the theme name and then load it via the correct folder when rendering views?

19th August, 2017

PaulDiamant left a reply on Laravel Mix Doesn't Hash The Files In Production! • 10 months ago

mix.js('resources/assets/js/app.js', 'Public/js').version()

12th August, 2017

PaulDiamant started a new conversation Npm Install Fails On Ubuntu With Proxy Error • 10 months ago

Fresh new installation of laravel 5.4, and when I use npm install to get the dependencies I get the following error;

! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settin
gs.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config

7th August, 2017

PaulDiamant left a reply on Https: Not Working In Laravel • 10 months ago

@Dunsti He gets an exception which means it works. OT: Is it a local or remote host?

6th August, 2017

PaulDiamant started a new conversation Multiple Authentication Across Subdomains • 10 months ago

I'm creating an ecommerce platform where users can make their own shops and get a subdomain. Laravel can handle authentication but how will I go about handling authentication in different sub domains? So each subdomain has its own session and there's one table of users for all stores globally.

14th June, 2017

PaulDiamant started a new conversation Route Not Found Exception No Longer Working • 1 year ago

When I output a link for example with

<a href="{{ route('noroute') }}">test</a>

Laravel won't throw an exception anymore but show me an error page 500. I installed a new laravel and there it shows me the ErrorException of route not found.

(2/2) ErrorException
Route [sdfds] not defined. (View: D:\WampServer\www\resources\views\welcome.blade.php)

I've no idea what happened, I haven't touched the exception handler or anything.

2nd June, 2017

PaulDiamant started a new conversation Issue With Auth Guards And Middleware • 1 year ago

Greetings,

In my laravel app, I have added an 'admin' guard pointing to an Admin model. Login, logout and auth methods work well. However when I attach the 'auth' middleware with the param guard to it like so: 'auth:admin', auth methods will no longer return default guard which is 'web', if used in the following way:

\auth()->check()

The following will consider the user logged in when used in the 'auth:admin' middleware, without the auth:admin middleware, \auth()->check() checks for the default 'web' guard and \auth()->guard('admin')->check() would check for the admin guard.

Does using 'auth:admin' middleware cause the default auth to change to the specified guard? Because I have also tried making a custom admin auth middleware which works fine now.

1st June, 2017

PaulDiamant started a new conversation Custom Exception Handling • 1 year ago

I made a simple human captcha package and I've added an exception and also included the file in the boot method in the provider.

require __DIR__ . '/Exceptions/CaptchaInvalidException.php';

My exception class:

<?php

namespace PKicker\Captcha\Exceptions;

class CaptchaInvalidException extends \Exception
{

}

report function in App\Exceptions\Handler.php

    {
        if($exception instanceof CaptchaInvalidException) {
            die('Test');
        }
        parent::report($exception);
    }

And it just returns a 500 http error, I can't figure out why.

10th May, 2017

PaulDiamant left a reply on Unable To Set Default Date Mutation • 1 year ago

That was my problem, trying to display the date while saved data has been saved with the old format. Thank you.

PaulDiamant started a new conversation Unable To Set Default Date Mutation • 1 year ago

When I try the following in my model, it works as it's the default format. protected $dateFormat = 'Y-m-d H:i:s';

However when I make the slightest change to it: protected $dateFormat = 'Y-m-d H:i';

The above won't work and throw me the following error: The separation symbol could not be found Unexpected data found. Unexpected data found. Trailing data (View: D:\WampServer\www\resources\views\pages\profile.blade.php)

17th February, 2017

PaulDiamant left a reply on Mix Babel Preset Stage-2 • 1 year ago

Yes, we can use a custom babelrc file so I defined the stage-2 there and now it works.

28th January, 2017

PaulDiamant started a new conversation Mix Babel Preset Stage-2 • 1 year ago

Hey, I'm trying to add stage-2 to the babelConfig in laravel mix modules to be able to use something in VueJS with mapping getters and actions

for example: computed: { ...mapStage... }

babelConfig() {
        let file = this.Paths.root('.babelrc');

        // If the user has defined their own .babelrc file,
        // the babel-loader will automatically fetch it.
        // Otherwise, we'll use these defaults.
        return this.File.exists(file) ? '?cacheDirectory' : '?' + JSON.stringify({
            'cacheDirectory': true,
            'presets': [
                ['es2015', 'stage-2']
            ]
        });
    }

I've edited the babel config in Mix.js inside laravel-mix/src/Mix.js to this and added the stage-2 preset and also installed it's module.

But it still doesn't seem to work properly, any ideas?

PaulDiamant left a reply on Webpack Mix Returns Errors With Babel • 1 year ago

Seems to be fixed now normally with a fresh install of Laravel on windows, thank you all for the help. I can finally get to work.

27th January, 2017

PaulDiamant left a reply on Laravel 5.4 Dev Npm Run Dev Error • 1 year ago

@GilG, I'm experiencing the same issue, gonna quit and wait till they fix it, hate workarounds.

PaulDiamant left a reply on Webpack Mix Returns Errors With Babel • 1 year ago

@Spec

{
  "private": true,
  "scripts": {
    "dev": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.15.2",
    "bootstrap-sass": "^3.3.7",
    "jquery": "^3.1.0",
    "laravel-mix": "^0.5.8",
    "lodash": "^4.16.2",
    "vue": "^2.0.1"
  }
}

PaulDiamant left a reply on Webpack Mix Returns Errors With Babel • 1 year ago

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\pauld\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 silly lifecycle @~predev: no script for predev, continuing
7 info lifecycle @~dev: @
8 verbose lifecycle @~dev: unsafe-perm in lifecycle true
9 verbose lifecycle @~dev: PATH: C:\Users\pauld\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;D:\wamp64\www\blog\node_modules\.bin;C:\Users\pauld\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\pauld\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Skype\Phone;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\wamp\bin\php\php7.0.4;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;D:\wamp64\bin\php\php7.0.10;C:\Program Files\nodejs;C:\Ruby23-x64\bin;C:\Users\pauld\AppData\Roaming\Composer\vendor\bin;D:\Program Files\Microsoft VS Code\bin;C:\Users\pauld\AppData\Local\Microsoft\WindowsApps;C:\Users\pauld\AppData\Local\atom\bin;C:\Users\pauld\AppData\Local\.meteor;C:\Users\pauld\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
10 verbose lifecycle @~dev: CWD: D:\wamp64\www\blog
11 silly lifecycle @~dev: Args: [ '/d /s /c',
11 silly lifecycle   'node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
12 silly lifecycle @~dev: Returned: code: 2  signal: null
13 info lifecycle @~dev: Failed to exec dev script
14 verbose stack Error: @ dev: `node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
14 verbose stack Exit status 2
14 verbose stack     at EventEmitter.<anonymous> (C:\Users\pauld\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (C:\Users\pauld\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:885:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid @
16 verbose cwd D:\wamp64\www\blog
17 error Windows_NT 10.0.14393
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\pauld\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
19 error node v7.4.0
20 error npm  v4.1.2
21 error code ELIFECYCLE
22 error @ dev: `node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
22 error Exit status 2
23 error Failed at the @ dev script 'node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the  package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

PaulDiamant left a reply on Webpack Mix Returns Errors With Babel • 1 year ago

I had to update it from 4.5.5 to 7.4.0.

PaulDiamant started a new conversation Webpack Mix Returns Errors With Babel • 1 year ago

When I run npm run 'script', it gives me an error saying the new 'laravel-mix' pacakge inside node-modules cannot recognize new ES2015 code, such as let variable, Class etc... Do I need to install babel or something else globally for this to work?

Example:

D:\wamp64\www\blog\node_modules\laravel-mix\src\Mix.js:11 class Mix { ^^^^^

25th October, 2016

PaulDiamant started a new conversation Laravel Authentication Session/database, 1 Session Per IP/user_id • 1 year ago

Hello, in my sessions.php config file, I set the auto expire on close to true and the session type to 'database' so it's stored in the database everytime a user goes on the site and logs in. Now, it works fine but the sessions just keep stacking up with the same user_id and IP address, I want to have a list of active sessions within the last 10 minutes only, NO USER ID or IP address duplicates because they don't get deleted... how would I go about doing it?

20th July, 2016

26th March, 2016

PaulDiamant started a new conversation Changing The Route Not Found Exception. • 2 years ago

Changing the route not found exception. How do I go about changing the execption when a route was not found as well as redirecting back when someone is attempting to access a POST route which also returns an annoying error? I haven't been able to find a solution for this.

Edit Your Profile
Update

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