calin.ionut

calin.ionut

Member Since 2 Years Ago

Experience Points
6,340
Total
Experience

3,660 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
36
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 2
6,340 XP
Jan
13
2 weeks ago
Activity icon

Replied to How To Override Email Verify In Laravel 6 ?

I figured out:

I use session('verified') in the view :)

Activity icon

Replied to How To Override Email Verify In Laravel 6 ?

@bugsysha

Thank you!

In the VerificationController i set the $redirectTo where I want to redirect after verify email. Do you know how to send a session in the view ? To tell the user that the email was validated.

Activity icon

Started a new Conversation How To Override Email Verify In Laravel 6 ?

I have created a notification (EmailVerificationNotification.php) in app/Notifications:

<?php

namespace App\Notifications;

use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\URL;

class EmailVerificationNotification extends Notification
{
    use Queueable;

    public function __construct()
    {
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        $verifyUrl = URL::temporarySignedRoute('verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]);

        return (new MailMessage)
            ->view('store.emailTemplate.emailVerify', ['verifyUrl' => $verifyUrl])
            ->subject('Email verification '.env('APP_NAME'));
    }

    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

and in the User model:

  public function sendEmailVerificationNotification()
    {
        $this->notify(new EmailVerificationNotification());
    }

and I get :

Illuminate\Routing\Exceptions\UrlGenerationException
Missing required parameters for [Route: verification.verify] [URI: email/verify/{id}/{hash}].

How can I get the verifyUrl ???

Activity icon

Replied to How To Implement Email Verification ?

@snapey that's the case.

I don't want the user to allow if it's not verified.

Activity icon

Replied to How To Implement Email Verification ?

@bugsysha

I just leave them as they are.

but how about this:

If the user enters another email (for example not his - and of course it can't be verified), and then later another user want to register with that email address (his email address) ?

He can't .... because the account already exists with that email address. Right?

Activity icon

Started a new Conversation How To Implement Email Verification ?

I am not sure if I understood correctly the mechanism of email verification (Laravel 6). (https://laravel.com/docs/6.x/verification)

Currently I am using:

$this->middleware('auth');

in every controller that needs the user to be authenticated.

Should I use only:

$this->middleware('verified');

or both of them ?

$this->middleware('auth');
$this->middleware('verified');

I want to implement the email confirmation (because most of the users when creating an account they use fake emails...).

For example, How do you proceed if the user has not confirmed the email in 60 min ?

Implement a cron job to test if the user has not verified the email account in 60 min, and then delete the account?

Dec
29
4 weeks ago
Activity icon

Replied to How To Use V-model On Components ?

This is how I got rid of the error:

on the editor component:

 <tinymce-editor v-model="newValue" :init="options"></tinymce-editor>
props: ['value'],
computed: {
    newValue: {
        get: function() {
            return this.value;
        },
        set: function(newValueData) {
            this.$emit('input', newValueData)
        }
    }
},

and on the other component

<editor :value="Description" @input="(newDescription) => {Description = newDescription}"/>

and now it works!

Dec
28
4 weeks ago
Activity icon

Replied to How To Use V-model On Components ?

@bobbybouwmann so if I understand correctly ... in my case:

on Editor component:

<tinymce-editor v-model="value" :init="options"></tinymce-editor>

props: {
            value: {
                type: String,
                required: true
            }
        },
        watch: {
            value() {
                this.$emit('input', this.value);
            }
        },

and on ProductDetails

<editor :value="Description" @input="(newDescription) => {Description = newDescription}"/>

but I get

Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value"

What I did wrong?

Activity icon

Started a new Conversation How To Use V-model On Components ?

I want to use vue-tinymce editor in a separate component ... like this

Editor component:

<template>
    <tinymce-editor v-model="value" :init="options"></tinymce-editor>
</template>

<script>
    import Vue from 'vue';
    import Editor from '@tinymce/tinymce-vue';
    import 'tinymce/tinymce.min';
    import 'tinymce/themes/silver/theme.min';
    import 'tinymce/plugins/image/plugin.min';
    import 'tinymce/plugins/link/plugin.min';
    import 'tinymce/plugins/lists/plugin.min';

    Vue.component('tinymce-editor', Editor);
    export default {
        name: "Editor",
        props: ['value'],
        components: {Editor},
        data() {
            return {
                options: {
                    plugins: 'link, image, lists',
                    height: 400,
                    branding: false,
                    toolbar: "undo redo | styleselect | link image lists | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"
                }
            }
        },
    }
</script>

and this component I am using in another component:

<template>
    <div>
        <editor :value="Description"/>
    </div>
</template>

<script>
    import Editor from "../../components/Editor";
    export default {
        name: "ProductDetails",
    data() {
            return {
                Description: ''
            }
        }   
    }
</script>

How can I use v-model for the editor in ProductDetails component ?

Activity icon

Started a new Conversation Add New Entry To A Collection

I need to add an entry to a collection.

I have the following:

$feeds = DB::table('feeds')->select('Name as feed', 'FeedID')->orderBy('Name', 'ASC')->get();

and I want to add to the existing collection as the first entry:

['feed' => 'No feed', 'FeedID' => -1]

How can I do it ?

Dec
12
1 month ago
Activity icon

Replied to Eloquent Many-to-many Get Data From A Table Using Condition From Another Table

@nakov using this query:

$products = Product::where('Stock', '<>', 1)
            ->whereHas(['categories' => function($query) {
                return $query->where('IsActive', 1);
            }])
            ->with('categories') // this will eager load the categories
            ->get();

I get

Call to a member function getRelationExistenceQuery() on array
Activity icon

Started a new Conversation Eloquent Many-to-many Get Data From A Table Using Condition From Another Table

I have created the relationship between product and category table (many-to-many)

I can get the product categories for a single product:

$product = Product::where('Stock', '<>', 0)->find(4264);
$categories = $product->categories;

But how about get more more products and set a condition for the category. Example: get only the products that belongs to an active category ???

I know if using a loop on products then an if (check the categories if its active) can solve the problem.....but I was wondering if its possible something like this (using a single query):

$products = Product::where('Stock', '<>', 1)->categories('IsActive', 1)->get();
Nov
26
2 months ago
Activity icon

Replied to Laravel 6 Error Class 'Illuminate\Support\Facades\Input' Not Found

Solved using

use Illuminate\Http\Request;

and

return Redirect::back()->withInput($request->all())->withErrors($validator);
Activity icon

Replied to Laravel 6 Error Class 'Illuminate\Support\Facades\Input' Not Found

I have the same problem after upgrading from laravel 5 to 6 when redirect back

return Redirect::back()->withInput(Input::all())->withErrors($validator);

it`s not working any more in laravel 6.

So i have tried with Request (like @mabdullahsari suggested)

return Redirect::back()->withInput(Request::all())->withErrors($validator);

but I got an error:

Non-static method Illuminate\Http\Request::all() should not be called statically

How should I use Request instead of Input::all() in laravel 6 ????

Nov
22
2 months ago
Activity icon

Replied to Best Vue Date Range Picker

@fylzero does is support selecting a date range ?

Activity icon

Started a new Conversation Best Vue Date Range Picker

I am looking for VUE (no JQuery) date picker that can do also do a range date picker similar to this: https://github.com/Innologica/vue2-daterange-picker (this one it`s a little buggy)

Any best date range picker out there ? Which date picker you guys using ???

Thx

Nov
12
2 months ago
Activity icon

Started a new Conversation Load Laravel.log In A Web Interface

Hi!

I am creating a new admin for my ecommerce (laravel 6)

I want to display the log (laravel.log) file in the admin - every time I have to SSH and see if there are any errors in the log.

I found 2 third party packages: https://github.com/rap2hpoutre/laravel-log-viewer and https://github.com/danielme85/laravel-log-to-db

Is anyone done this ? View log errors in admin or in a web interface ?

I was thinking to store the all the log info in DB using that package... do you think is a good ideea ?

Nov
01
2 months ago
Activity icon

Replied to How To Enable RuntimeCompiler In Laravel-mix ???

@nakov I figure it out :)

There is nothing to do with runtimecompiler .....

I forgot from the beginning when i start using this component "v-runtime-template" to use the component this line:

components: {VRuntimeTemplate},

and that's it

So the final usage is this

<template>
<div class="table-responsive">
            <table class="table">                
                <v-runtime-template :template="dataContent"></v-runtime-template>
            </table>
        </div>
</template>

<script>
import VRuntimeTemplate from 'v-runtime-template';
export default {
     name: "BasicTable",
      components: {VRuntimeTemplate}, // the line that I forgot
      data() {
          return {
              dataContent: '',
          }
      },
}
</script>

The dataContent is the html data from the api server. It also contains vue code, example:

<router-link :to="{ name: 'category-details', params: { CategoryID: 1}}">Category 1</router-link>

and now the vue code is recognized with VRuntimeTemplate component :)

Oct
31
2 months ago
Activity icon

Replied to How To Enable RuntimeCompiler In Laravel-mix ???

@nakov

And if you installed the package, don't you just need to include the component? I don't really understand the usage of the package, but you can import the component directly.
import VRuntimeTemplate from "v-runtime-template";
and use it in your component?

I imported directly in the component where I needed.

About the first part....

  1. I added the alias in webpack.mix.js
mix.webpackConfig({
        resolve: {
            alias: { 'vue$': 'vue/dist/vue.runtime.js' }
        }
    })
  1. created in the laravel project the path
vue/dist/vue.runtime.js

and in the file:

Vue.module.exports = {
    runtimeCompiler: true
};

and when compiling in the console browser i get this error:

You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
Activity icon

Replied to How To Enable RuntimeCompiler In Laravel-mix ???

For me it`s not working .... no matter what the method I use to import Vue

the error is the same:

TypeError: Cannot set property 'exports' of undefined
Activity icon

Replied to How To Enable RuntimeCompiler In Laravel-mix ???

@nakov

My app.js is this:

import Vue from 'vue';
import VueRouter from 'vue-router';
import router from './routes';
import App from "./App";

Vue.use(VueRouter);
window.axios = require('axios');

Vue.module.exports = {
    runtimeCompiler: true
};

let app = new Vue({
    el: '#app',
    components: { App },
    router: router,
});
Activity icon

Replied to How To Enable RuntimeCompiler In Laravel-mix ???

If set I get this error:

TypeError: Cannot set property 'exports' of undefined
Activity icon

Started a new Conversation How To Enable RuntimeCompiler In Laravel-mix ???

I want to use this component:

https://github.com/alexjoverm/v-runtime-template

and it says that

// vue.config.js
module.exports = {
  runtimeCompiler: true
};

I ma using Laravel 6 with Vue.

How to enable runtimeCompiler in laravel-mix ???

Oct
30
2 months ago
Activity icon

Started a new Conversation Add Custom Field To Query

Hello,

I want to create a simple API and for categories I want to return a json with custom data:

ex:

$categories = $categories->select('CategoryID', 'MenuOrder', 'IsActive', 'Name', 'Slug' )->where($filterCondition)->orderBy($orderBy, $orderType)->paginate($paginate)->appends($queries);

I need 1 more field "Url" - which is not in the DB - I have to generate it using a function that accept CategoryID and Slug for each record.

How can I add custom field (Url) in categories ?

Using a loop for $categories (create an array with the fields...generate the url....etc) I don't think is a good idea (for performance) .... so I was thinking modifying the query - when each row is extracted from the DB ... to generate the Url for each entry directly.

or Is there any better soluttion (faster) ?

The return data is a Json which will be loop on the client (using vue) to display data ......

Oct
26
3 months ago
Activity icon

Started a new Conversation Create Dynamic Events For A Vue Component

Anyone can help me with this question ?

The details are here

https://stackoverflow.com/questions/58569596/create-dynamic-events-for-a-vue-component

Oct
23
3 months ago
Activity icon

Replied to Fit Pagination On Mobile Devices

I think I just solved :)

Created a custom pagiation mobile-pagination-template.blade.php:

@if ($paginator->hasPages())
    <ul class="pagination pagination">
        {{-- Previous Page Link --}}
        @if ($paginator->onFirstPage())
            <li class="page-item disabled"><span class="page-link">‹</span></li>
        @else
            <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">‹</a></li>
        @endif

        @if($paginator->currentPage() > 2)
            <li class="page-item hidden-xs"><a class="page-link" href="{{ $paginator->url(1) }}">1</a></li>
        @endif
        @if($paginator->currentPage() > 3)
            <li class="page-item"><span class="page-link">...</span></li>
        @endif
        @foreach(range(1, $paginator->lastPage()) as $i)
            @if($i >= $paginator->currentPage() - 1 && $i <= $paginator->currentPage() + 1)
                @if ($i == $paginator->currentPage())
                    <li class="page-item active"><span class="page-link">{{ $i }}</span></li>
                @else
                    <li class="page-item"><a class="page-link" href="{{ $paginator->url($i) }}">{{ $i }}</a></li>
                @endif
            @endif
        @endforeach
        @if($paginator->currentPage() < $paginator->lastPage() - 2)
            <li class="page-item"><span class="page-link">...</span></li>
        @endif
        @if($paginator->currentPage() < $paginator->lastPage() - 1)
            <li class="page-item hidden-xs"><a class="page-link" href="{{ $paginator->url($paginator->lastPage()) }}">{{ $paginator->lastPage() }}</a></li>
        @endif

        {{-- Next Page Link --}}
        @if ($paginator->hasMorePages())
            <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">›</a></li>
        @else
            <li class="page-item disabled"><span class="page-link">›</span></li>
        @endif
    </ul>
@endif

and in product page:

{{ $products->links('components.mobile.mobile-pagination-template') }}
Activity icon

Started a new Conversation Fit Pagination On Mobile Devices

I can`t fit on mobile device the pagination. (laravel 6 and bootstrap 4)

I found this function for pagination ( onEachSide() )

 $products->onEachSide(1)->links()

The results are ok when the page loads (screenshot attached):

https://www.dropbox.com/s/k2aitr40ofastq3/pag_initial.png

But the problem is when click on 3 and so on.... (screenshot attached):

https://www.dropbox.com/s/2rjmsmxpuh8nclh/pag_after.png

Oct
01
3 months ago
Activity icon

Replied to Vue Component Not Displaying In Another Component

@punksolid sorry...It was declared but forgot to write it here when posting. I have updated the post....and is not working.

Activity icon

Started a new Conversation Vue Component Not Displaying In Another Component

I have a problem displaying a component in Vue. For backend I am using laravel.

In my home.blade.php

  <div id="app">
      <app></app>
  </div>

The App.vue

<template>
    <div>
        <navbar-side></navbar-side>
        <div class="main-content" id="panel">
            <navbar-top></navbar-top>
            <router-view></router-view>
        </div>
    </div>
</template>

<script>
    import NavbarSide from "./layout/NavbarSide";
    import NavbarTop from "./layout/NavbarTop";
    export default {
        name: "App",
        components: { NavbarTop, NavbarSide}
    }
</script>

In App.vue I have the router view. The / path is the dashboard component

<template>
    <p> Dashboard content </p>
</template>

<script>
    export default {
        name: "Dashboard",      
        mounted() {
            console.log('Dashboard mounted.')
        }
    }
</script>

When i load the app i get the msg: "Dashboard mounted." .... but if i add another component to the dashboard it will not display it :

<template>
    <div>
        <header></header>
        <p> Dashboard content </p>
    </div>   
</template>

<script>
    import Header from "../layout/Header"; 
    components: {Header}
    export default {
        name: "Dashboard",      
        mounted() {
            console.log('Dashboard mounted.')
        }
    }
</script>

And the Header.vue component is:

<template>        
        <p> Header content </p>   
</template>

<script>
    export default {
        name: "Header",
        mounted() {
            console.log('Header mounted.')
        }
    }
</script>

Why the header component is not showing in the dashboard component ???

Aug
24
5 months ago
Activity icon

Replied to (Swift_TransportException(code: 0): Connection To Tcp://server.example.com:465 Timed Out

it's working now.....I didn't do anything.

I thing the cache was the problem...after changing in the .env

Always is a pain in the ass when changing something in .env

Aug
23
5 months ago
Activity icon

Replied to Run Queue:work In Maintenance Mode ?

@tykus

because I was testing the new email settings on maintenance mode ... which I am using queue (database) to send emails in bkg and try to force to send email (from jobs table) using the mentioned command ..... it does not do anything.

The job is not dispatch from the jobs table.....ONLY if I get out of maintanance (php artisan up).

That`s why not work!

Activity icon

Started a new Conversation (Swift_TransportException(code: 0): Connection To Tcp://server.example.com:465 Timed Out

We have changed the email server from a provider to another. The where sending with the old email settings but not with the new ones. I am not sure if it`s laravel server or email server.

I will use here my domain as: example.com

I have changed the new email settings in .env:

MAIL_DRIVER=smtp
MAIL_HOST=server.example.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=ssl

and when we send emails we get this exception in laravel.log

production.ERROR: Connection to tcp://server.example.com:465 Timed Out {"exception":"[object] (Swift_TransportException(code: 0): Connection to tcp://server.example.com:465 Timed Out at /var/www/example.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:473, Swift_IoException(code: 0): Connection to tcp://server.example.com:465 Timed Out at /var/www/example.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:166)

I have tried also with tls instead of ssl but the same error.

I have configure that email [email protected] in thunderbird with the given settings from the provider and works.

Email settings: incomming: IMAP server.example.com 993 SSL/TLS Encrypted password outgoing: SMTP server.example.com 465 SSL/TLS Encrypted password

username (email address) and password.

I am missing something ????

Activity icon

Started a new Conversation Run Queue:work In Maintenance Mode ?

How to run php artisan queue:work in maintenance mode (php artisan down) ????

Is this possible?

Activity icon

Replied to Config:cache => Your Configuration Files Are Not Serializable.

The problem was in the Controller constructor when defining the $agent.

$agent = new Agent();
config(['agent' => $agent]);

It seems that in config should not be defined any function.

A temp fix:

1 Clear the config

php artisan config:clear

2 comment the code from Controller.php where i defined the $agent

3 Cache the config

php artisan config:cache

4 Uncomment the code from Controller

I was changing some value from .env and the changes was not reflected in the app, then i played with the cache and discover this error :)

Activity icon

Started a new Conversation Config:cache => Your Configuration Files Are Not Serializable.

I am having an error using the command in laravel 5.8

~$ php artisan config:cache
Your configuration files are not serializable.

I investigate where the problem come from.

Commented the line:

$this->files->delete($configPath);

from

vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php

to see exactly what`s the problem.

In bootstrap/cache/config.php on line 612 is the problem.

"Call to undefined method Jenssegers\Agent\Agent::__set_state()

The Agent is installed via composer ("jenssegers/agent": "^2.6")

Added in /config/app.php

on aliases

 'Agent' => Jenssegers\Agent\Facades\Agent::class,

and on providers

Jenssegers\Agent\AgentServiceProvider::class,

I need $agent in every controller and view and defined Agent in Controller.php in the constructor:

// detect device agent
        $agent = new Agent();
        config(['agent' => $agent]);
        

It`s not ok how i defined the agent in Controller???

Why it complains about:

 undefined method Jenssegers\Agent\Agent::__set_state()

?

Aug
20
5 months ago
Activity icon

Replied to How To Sync Attributes In A Specific Order ?

@sergiu17 on my machine don`t :))

 foreach ($attributes as $attr) {
            echo $attr.' ';
        }
        echo '<br>';

        $product->attributes()->detach();
        foreach($attributes as $attribute) {
            $product->attributes()->attach($attribute);
        }

        foreach ($product->attributes as $attr) {
            echo $attr->AttributeID.' ';
        }

outputs:

82 84 83 86 
82 83 84 86

it still save the attribute_id in asc order.

@ftiersch

The pivot table have two columns (attribute_id and product_id)

Why the order is important?

Because I want to display them in the order they were saved

Activity icon

Replied to How To Sync Attributes In A Specific Order ?

@sergiu17

tried this combination allready :)

$product->attributes()->detach();

foreach($attributes as $attribute) {
       $product->attributes()->attach($attribute);
}

but the same thing....does not save in the order that the elements are in attributes array

Activity icon

Started a new Conversation How To Sync Attributes In A Specific Order ?

I have pivot table that saves the attribute_id and product_id

When saving the product with attributes ($attributes) i get an array ex:

array:4 [
  0 => "82"
  1 => "84"
  2 => "83"
  3 => "86"
]

Those attribute I need to be in that order!!!!

That`s the problem

when saving:

 $product->attributes()->sync($attributes, true);

it saved in this order:

attribute_id    product_id
82                   31
83                   31
84                   31
86                   31

How can I save in the order that is on the array (82, 84, 83, 86) ???

Activity icon

Replied to Search In Multiple Fields Using Eloquent

@cronix

still not working ...

 $products = Product::where(array(['IsActive', '1']))
                ->where(function ($query) use ($search) {
                    $query->where('Name', 'like', '%'.$search.'%')->orWhere('Code', 'like', '%'.$search.'%');
                })
                ->orderBy('created_at', 'desc')
                ->paginate(12)
                ->appends($queries);

It works independently for code and for product name.

If the user type for ex:

1217 TRICOU EXTREME

where 1217 is the code for product name: "TRICOU EXTREME" it does not find anything.

@jlrdw i will test to see if it works.

Aug
19
5 months ago
Activity icon

Started a new Conversation Search In Multiple Fields Using Eloquent

I want to implemented a search for products in laravel 5.8 and in the search controller I have this:

$search = $request->input('ref');
$queries['ref'] = $search;
$products = Product::where(array(['IsActive', '1'], ['Name', 'like', '%' . $search . '%']))
                ->orWhere(array(['IsActive', '1'], ['Code', 'like', '%' . $search . '%']))
                ->orderBy('created_at', 'desc')
                ->paginate(12)
                ->appends($queries);

The search is working for product name and product code (but not combined). I you use a separate search for code OR for product name will work.

For example if i search for:

4512 Tennis ATP Balls Babolat

where 4512 is the product code and "Tennis ATP Balls Babolat" is the product name, the search will not found anything.

What I know about the % in the like:

'Name', 'like', '%4512 Tennis ATP Balls Babolat%'

should find any values that have "4512 Tennis ATP Balls Babolat" in any position

What I dis wrong?

Aug
08
5 months ago
Activity icon

Replied to Search For Day Created_at

@cronix

the result will be :

2019-08-07 00:00:00 had 2 orders.
2019-08-06 00:00:00 had 1 orders.
2019-08-05 00:00:00 had 1 orders.

for the other days if i don`t have orders it will not get.

How can i set for 2019-08-04, 2019-08-03 .... if there is not any order, the value 0 ?

There is no other way that I can get the entries for a specific day more easily (created_at) ???

something like this?

$orders = DB::table('orders')->whereNull('deleted_at')->whereDay('created_at', $day)->count();
Aug
07
5 months ago
Activity icon

Replied to Search For Day Created_at

@aurawindsurfing

i want for a specific date not between.

Ex: 2019.08.07 - 2 orders 2019.08.06 - 5 orders 2019.08.05 - 10 orders ...

the $orders will be the count orders for a specific day.

Activity icon

Started a new Conversation Search For Day Created_at

Hello,

I have this array:

$last7DaysOrders = array(
            'labels' => array(),
            'datasets' => array(
                array(
                    'label' => 'Orders',
                    'data' => array()
                )
            )
        );

and i want to get the number of orders for the last 7 days.

      for ($i = 6; $i >= 0; $i--) {
            $day = Carbon::today()->subDay($i);
            array_push($last7DaysOrders['labels'], $day->format('D'));
            $orders = DB::table('orders')->whereNull('deleted_at')->whereDay('created_at', $day)->count();
            array_push($last7DaysOrders['datasets'][0]['data'], $orders);
        }

but i get unexpected results for the number of orders.

I have also tried with:

$orders = DB::table('orders')->whereNull('deleted_at')->where('created_at', 'like',  $day->format('Y-m-d'))->count();

but i get 0 result.

Any ideas how can I do it?