10 Best Reply Awards

  • Member Since 2 Years Ago
  • 855 Lessons Completed
  • 14 Favorites

23rd July, 2018

m7vm7v left a reply on How To Convert Date Fields To Timestamps And Substract Them? • 2 hours ago

@ziben69 Could you please click on the best-reply icon under the @Tomi 's avatar. He deserves the badge after his answer is the one that helped you.

m7vm7v left a reply on How To Sum The Columns And Display It In View File Laravel • 5 hours ago

In the controller you could do

        $salesDetails = Sales_details::orderBy('created_at','desc')->paginate(10);

        $salesDetailsCollection = collect($salesDetails->items());

        return view('Sales_details.view', [
            'salesDetails' => $salesDetails,
            'total' => $salesDetailsCollection->sum('total'),
            'no_of_litre' => $salesDetailsCollection->sum('no_of_litre')

in your view you would have all the data in {{ $salesDetails }}, {{ $total }}, {{ $no_of_litre }}

m7vm7v left a reply on How To Implement Similar To Fb Like Button Effect On Your Page • 5 hours ago

@Cronix I think we've miss understood @mikail10000000 .

What he is trying to accomplish is to do the other way around - people using his API to login in a third party page.

@mikail10000000 if that so then you need to create an API for that. Example scenario for that could be this and you can extend it as much as you'd like -

You have a standard laravel auth with user's avatars and so on. Then you need to create a development endpoint such as fb where if the user wants to use your API must confirm that. When thats confirmed you can create public and private keys and level of access for example for that user and store them into your database - that would be the creds for the user to connect to your API. Then you need to create API endpoints where the developers need to send a POST (preferably) request to your server with their creds and the user in your system they need to take information for(and a simple check if they have privileges to do so through the level of access). Then in that api route you could return json with the requested user's username/email/avatar. Thats the first step. Then you will need to implement the user's requests such as a login link. For example if a user from the third party system click on 'Login by a.com' then that will lead them to e api route on your server with the public cred from b.com. On that page there would be something like - Do you {{ $username }} give access to b.com to see your username/email/avatar. If they click yes then b.com is having privileges to that user and when the user is returned to b.com this system would have all the creds to create the user on their system and log it in.

I hope that makes as this is the simplest way to achieve this functionality and there are some more to be added but during this process you would see whats needed.

I would recommend you to have a look at this (read it all first then start implementing it as it will require a strong knowledge of the full process)- https://laravel.com/docs/5.6/passport

m7vm7v left a reply on Laravel 5.6 "Page Not Found" Problem • 5 hours ago

@Tshephy if @pmartin 's solution worked then hit the best-reply button under his avatar ;)

m7vm7v left a reply on Connect Laravel To Amazon S3 • 6 hours ago

@AbdallahSabri if you are using valet try to secure the link by simply run 'valet secure' in the project root directory. If not then try to install ssl manually.

m7vm7v left a reply on Get Value For Dropdown List And Input It Database • 6 hours ago

@armancs If that so then my first reply remains what you would need to do. Just in the I would use the the country->id for the value and the name after. So when you hit the controller for the country you would have the needed id with no need to query that information by the name. Hope that makes sense.

22nd July, 2018

m7vm7v left a reply on Vue Like Component In Posts View • 1 day ago

@andonovn is correct. You can create for example <post-reply :post='{{ $post }}'></post-reply> with all the logic for the post reply, register it and then you can use it everywhere as many times as you want. For example in a collection page with 20 posts

@foreach($posts as $post)
{{ $post->title }}
<post-reply :post='{{ $post }}'></post-reply>

In that case for each post you will have a new instance of the component.

m7vm7v left a reply on How To Implement Similar To Fb Like Button Effect On Your Page • 1 day ago

Which is the third party website you are talking about? There a many different ways to connect to the facebook API. You can find all the docs here https://developers.facebook.com/docs

I would assume that what you need is to be able to login by facebook functionality which would create a new user in your database from information given by facebook which is not really hard to be implemented. If so then follow this guide - https://laravel.com/docs/5.6/socialite

m7vm7v left a reply on How To Locally Test Cross Website App • 1 day ago

I would suggest that you could create a /widget-sample route that will return from the controller a 'blank'/the default layout page.

The test would look like -

//when I visit that page //I expect to see empty page/layout //when I add/inject the widget to the page - as that is what would the user do, it will inject the code into their page. //I expect to see the title of the widget, some body and some functionality that you know its been written for that widget

m7vm7v left a reply on Trying To Get Property 'id' Of Non-object When Showing Single Post In View • 1 day ago

When you do $post = Post::findOrFail($id); The $post will return a single instance of the object NOT a Collection. Therefore in the blade you do not need to use the @foreach($post as $post) as you have just one $post, just remove that line and the @endforeach.

m7vm7v left a reply on Queues - Delayed Dispatching? • 1 day ago

You could start investigating trough the database. Stop the job listener/worker queue:work then trigger the function that will create that job. When you connect to your database you will see that there will be a new record in the 'jobs' table. Look at the last two columns 'available_at' & 'created_at'. You should notice the 10 minutes delay/difference between them. Is that the case or they are with the same values?

m7vm7v left a reply on Get Value For Dropdown List And Input It Database • 1 day ago

Lets walk trough the requirements one more time - Is it the case you want that when a user visits a page there will be a list of countries and an input field for a city name. When the user clicks on a country and fill the city name then for example click on a button (or you could do it trough AJAX without a button) 'Create' then in the database you want to see that there is a new record in the cities table with name, country_id or name. Is that all correct or I've miss understood what you try to achieve. If not then could you explain briefly and provide pictures if you believe that would help. Thanks

m7vm7v left a reply on Connect Laravel To Amazon S3 • 1 day ago

Is that on locally still or its on hosting server @AbdallahSabri ? If its on the hosting server you can check do you have ssl correctly installed by a lot of tools, one of them can be found here https://www.sslshopper.com/ssl-checker.html

m7vm7v left a reply on Get Value For Dropdown List And Input It Database • 1 day ago

Hi @armancs It depends if you want to associate the Country with he City, which I believe you would want to. If so in the form you have to make the country list as a radio buttons or better - select from the list and have to give it a name attribute and the options with value="country_id".

Then wrap all that in a with a submit button and action that points to a controller method, in which you could simply do a

$city = City::create([
    'name' => request('city_name'),
    'country_id' => request('country_id')

21st July, 2018

m7vm7v left a reply on Creating A New Account With A Soft Deleted Email • 1 day ago

You have to think about it in couple of places.

The validation is not the only problem you will face.

In the users_table migration you have to remove the ->unique() $table->string('email')->unique();

For the validation rule I will suggest you could write your own. https://laravel.com/docs/5.6/validation#custom-validation-rules

m7vm7v left a reply on How Can Replace Page In Laravel • 1 day ago

You might consider using PJAX for that if I've understood the question correctly honestly...

https://laracasts.com/lessons/faster-page-loads-with-pjax https://laracasts.com/lessons/faster-page-loads-with-pjax-the-server-side

m7vm7v left a reply on Create/update Sql Records Without Form • 1 day ago

If you need simply to ignore the csrf field then you need this - https://laravel.com/docs/5.6/csrf#csrf-excluding-uris

I am not sure what are you exactly asking with the second question tbh. If you could give more information we might be able to help more.

m7vm7v left a reply on How To Run Scheduling Every 2 Sec • 2 days ago

@Snapey as you see the title says 'How to run scheduling every 2 sec'.

m7vm7v left a reply on Posting In Database Comes With Unwanted Quotation Marks • 2 days ago

Try -

Remove all the [] from the view Form::text('taskEmployee' .....

then in the controller -

Task::create([ 'task' => request('task'), 'taskEmployee' => request('taskEmployee'), 'taskStartDate' => request('taskStartDate'), 'taskDeadline' => request('taskDeadline'), ]);

m7vm7v left a reply on Display Data In Table Format From Database • 2 days ago

@scala Have you changed the controller and the loop in the view as I've mentioned. Make sure you have removed ->toArray() in your controller. Its not necessary but you do not need to cast it to array as you loose a lot of other functionality.

in your controller

public function index()
        return view('pages.booksin', [
        'ordered_books' => OrderedBook::all()

in the view

    @foreach($ordered_books as $book)
                <td>{{ $book->BookID }}</td>

m7vm7v left a reply on Any “famous” Sites Built With Laravel? • 2 days ago

https://laravel.com https://laracasts.com

Why would be interested in any other :P

m7vm7v left a reply on Error Attaching Datatables Library • 2 days ago

I would assume it because you call the dataTable.js on the last.

Try to reorder them the js - jquery on top then the dataTable then the app.js

m7vm7v left a reply on Display Data In Table Format From Database • 2 days ago

In your view why do you look the $data when you are sending $ordered_books from the controller.

For debugging you could use Xdebug but I would recommend you just dd();

in your [email protected]

$ordered_books = OrderedBook::all();


return view('pages.booksin', compact('ordered_books'));

in your blade {{ $row->BookID }}

m7vm7v left a reply on How To Pass AJAX Data To Laravel Controller • 2 days ago

I would assume the problem might be that the data is an object when the token should be send right away.

data:_token:$('#token').val(), fprinter:FPrint

m7vm7v left a reply on How To Pass AJAX Data To Laravel Controller • 2 days ago

If you use VueJS the token will be created and send automatically. If not then {{ csrf_field() }} or @crsf_field would create a hidden field. Then in the JS just take the value and send it with your object .

m7vm7v left a reply on How To Run Scheduling Every 2 Sec • 2 days ago

Instead of using the ->everyMinute(); try ->cron('* * * * *'); and specify the exact timing using purely cron syntax.

m7vm7v left a reply on How To Add Headers In Laravel Request • 2 days ago

Have you checked https://laravel.com/docs/5.6/responses#attaching-headers-to-responses

I would assume that for requesting json you might gonna need to exclude that response by if(request()->expectsJson()))

m7vm7v left a reply on Sum Values From Multidimensional Collection • 2 days ago

Before calling the ->toArray() I would assume that you have a collection. If not the collect it by $array = collect($yourArray['podvrste_amb'][0]['kolicine_amb']);

After you have a collection you can easily use the ->sum(); method https://laravel.com/docs/5.6/collections#method-sum

$nepov_proizv_kol_summed = $array->sum('nepov_proizv_kol'); $nepov_uvoz_kol_summed = $array->sum('nepov_uvoz_kol');

Then you can return a rebuild array with all the values you need.

For comparing you can still use the collection as there are a lot methods to use - on the same page I have given. Hope that helps.

m7vm7v left a reply on Eager Loading Doesn't Work • 2 days ago

Can you show us all the relationships for the product connected with this list.

20th July, 2018

m7vm7v left a reply on (1/1) MethodNotAllowedHttpException • 3 days ago

Hi @surabhi Can you paste the full stack of the error message you see?

m7vm7v left a reply on Redis Error Cause Explosiong Of Log File Size • 3 days ago

You are most likelly having a permissions problem on the server. You have to ssh into the server and give write access for Redis. This or you are out of disk space I would suggest.

m7vm7v left a reply on Laravel 5.6 "Page Not Found" Problem • 3 days ago

Do have blade for both the pages.welcome and pages.about?

m7vm7v left a reply on Selects With Dependencies Old () • 3 days ago

In the

<select name="municipio_code" class="form-control" id="municipio">
    <option value="1" {{  old('municipio_code') == 1 ? 'selected' : '' }}>Option 1</option>
    <option value="2" {{  old('municipio_code') == 2 ? 'selected' : '' }}>Option 1</option>

m7vm7v left a reply on (1/1) MethodNotAllowedHttpException • 3 days ago

Try switching to named routes Route::post('/check-token-view','[email protected]_tokens_data')->name(check-token-view);

Then in the form action {{ route('check-token-view') }}

m7vm7v left a reply on Store Array Data Using Serialize • 3 days ago

First of all you should never save the user's bank credentials into the database. You just need the creds to send them into the provider (such as Stripe) and confirm the payment then charge the user without even the creds hitting your server. In many countries thats even illegal. And thats why Stripe makes it very easy to use without hitting your server on that point.

Second - if you are receiving the creds into your server it could be as easy as call the

$serialisedData = serialize(request()->all());

and save that information into the database. After


Hope that makes sense but reconsider saving that data is in another hand you should never need it anyway no matter is it legal or not.

m7vm7v left a reply on Where Did I Go Wrong In Uploading File • 3 days ago

Do you see any errors when you submit the form?

I would suggest that in Project you have not updated the private $fillable= [] with all the fields you are saving. On another hand do not use action('TeamFinder\[email protected]') in the form action. Go to the web.php with all your Routes and create a route Route::post('/form/submit', 'TeamFinder\[email protected]'); and might give a ->name('form-submit'); then in the form itself in the blade you can use route('form-submit') or the full path 'form/submit'.

m7vm7v left a reply on How To Make Sure I Only Insert This JS Script Once? • 3 days ago

If you have a model for the Widget you can make a private property called 'dependencies' which would be an array with all the dependencies that have been already injected ['google-charts', 'google-recaptcha', 'bootstrap']. Then foreach widget that the user request check that list and make sure that you pluck only the unique values and then spit only them on the page. Or for each widget you can push the dependency into the same array only if does not exist. Hope that makes sense.

m7vm7v left a reply on Dynamic Rate Limiting Without User Model • 3 days ago

You might be better if you keep the User and implement roles-rules system. So an User can be tenant/team leader/organisation leader. If its not a big system just make another field for the User called 'role'. Then the throttle requests per tenant would be an easy implementation. Hope that makes sense.

19th July, 2018

m7vm7v left a reply on Database Problem • 3 days ago

You should go to the root of your project and find the .env file. If you do not have it then rename the .env.example to .env

find and change this lines to the one you are using


m7vm7v left a reply on Error While Trying To Update Multiple Has Many Relation! • 3 days ago

Try not using the ->update directly like that.

https://laravel.com/docs/5.6/collections#method-each You can try ->each( function($singleOrder) { $singleOrder->update() })

Is there a reason why using the DB rather than the Model itself?

m7vm7v left a reply on How Can I Create A Controller Constructor That Takes In Two Concrete Implementations Of The Same Interface? • 4 days ago

You can make a Redis decorator. In the controller inject only the Interface. Create the Redis decorator for the DBRepo and register them in the RepositoryServiceProvider with singleton.

m7vm7v left a reply on Process Jobs In Queue Strictly One After Another • 4 days ago

You could then make a simple check before executing the SeconJob ... if the there is no FirstJob in the queue then execute the SecondJob if not delay it.

m7vm7v left a reply on Facebook Share Giving Me An Error On "og:title" • 4 days ago

Hi, I am not sure have you recently changed anything but visiting the page you have provided returns an Exception and its normal that fb will return this result. In another hand this info is being cached by FB even if you fix the issue. You might gonna need to wait or visit https://developers.facebook.com/tools/debug/ to recache your page after you click on 'Scrape again' - but only after you fix the issue on your page.

m7vm7v left a reply on Allow Softdeleted Users To Login • 4 days ago

I would mostly agree with @jlrdw You better not softdelete the user but use a flag in the database like 'restricted' set by default to zero and rather than deleting then - update the flag to true if its a small system or create a role based integration for a bigger one like @jlrdw suggested.

m7vm7v left a reply on Process Jobs In Queue Strictly One After Another • 4 days ago

Have you tried the ->withChain option


FirstJob::withChain([ new SecondJob, new ThirdJob ])->dispatch();

m7vm7v left a reply on Laravel Create And Change Database In The Same Request • 4 days ago

Have you tried with raw queries - DB::connection($prefix)->raw('create companies...'); rather than the Schema approach?

18th July, 2018

m7vm7v left a reply on Laravel Notifications - Queue ONLY On ToMail Method? • 5 days ago

You could separate the logic in two notifications - one for the database and one for the mail. After that you do not need to use the Notification facade but fire an event that will trigger both the notifications. Hope that makes sense. After all then you can make the database notification to be NOT Queueable and then the mail notification can be Queueable.

15th July, 2018

m7vm7v left a reply on Union/Join/Merge Table To Get The Result • 1 week ago

Hi @ravipw1801 try placing ->get just before the ->paginate()

9th July, 2018

m7vm7v left a reply on Laravel Notifications • 2 weeks ago

Its pretty much the same logic mate -

use SerializesModels;

    public $business; //All the public properties will be available to be used in the Listener

    public $user;

     * Create a new event instance.
     * @return void
    public function __construct(Business $business, User $user)
        $this->business = $business;

    $this->user = $user;

//For this simple example you do not need the broadcastOn method btw

then in the controller send all the needed data -

$user->notify(new ArrangeCallRequested($business, $user));

So then in the SendNotificationForArrangedCall you will have access to both models -

public function handle(ArrangeCallRequested $event)
        return (new ArrangeCallRequested)->view(
            'emails.arranged-call', [
                'business' => $event->business,
                'user' => $event->user

Then in the email blade you can use the model Hi {{ $user->name }}, you have requested a call for {{ $business->name }}.

m7vm7v left a reply on Laravel Notifications • 2 weeks ago

Hi @ravipw1801 In your controller where you call $user->notify(new ArrangeCallRequested());

pass all data you need to like this

$user->notify(new ArrangeCallRequested($theBusinessModel, $theUserForExample));

then in SendNotificationForArrangedCall

public $theBusinessModel;

public $theUserForExample;

public function toMail($notifiable)
    return (new ArrangeCallRequested)->view(
        'emails.arranged-call', [
        'theBusinessModel' => $this->theBusinessModel,
        'theUserForExample' => $this->theUserForExample

Then in the email blade you can use the model {{ $theBusinessModel->name }}

Edit Your Profile

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