tisuchi

Developer at EDV Standard

Hire Me

Experience

149,695

73 Best Reply Awards

  • Member Since 2 Years Ago
  • 1000 Lessons Completed
  • 12 Favorites

12th May, 2017

tisuchi left a reply on How To Add My Own Custom Class • 1 week ago

I normally prefer to use custom function instead of class. Again, of course, its your choose.

But what I can suggest that, just use function than you can call this function anytime in any place as easy as route() or some other buildin function in laravel.

How to use a custom function

Imagine that you have custom file called helpers.php where you stored all the custom functions.

function Foo()
{
    return "Bar";
    
}

Now anywhere in your project (controller/view/model), you can able to call this function like that-

Foo();

And this function will return "Bar".

tisuchi left a reply on How To Make Site Works Both On Www And Site.com • 1 week ago

You can control this issue by editing .htaccess for your site. Just google it.

Here is the example- http://www.inmotionhosting.com/support/website/htaccess/force-www-htaccess

tisuchi left a reply on $with N+1 Problem • 1 week ago

You know what, its not with n+1 (what can I understand).

If your code is like that, only that time you will get the n+1 issue.

$phones = App\Phone::all();

foreach ($phones as $phone) {
    echo $phone->user->phone;
}

Likely your code is following whereIn() that definitely not creating n+1. Explanation of your code is-

$Phones = App\Phone::with('user')->get();

foreach ($Phones as $phone) {
    echo $phone->user->user;
}

The query for above code is like so-

select * from Phones
select * from users where id in (1, 2, 3, 4, 5, ...)

Meaning, it just creates 2 query only to fetch as much as data you have.

Ref: https://laravel.com/docs/5.4/eloquent-relationships#eager-loading

tisuchi left a reply on Image • 1 week ago

Can you show your code?

9th May, 2017

tisuchi left a reply on How To Integrate Script • 1 week ago

Haha... Calm down... @ninahe No body contribute here for money. Its just helping each other.

May be some other experts can help you.... :)

tisuchi left a reply on Detecting Errors In Code In Laravel • 1 week ago

For that, you need to test your code.

Check it out this series.... https://laracasts.com/series/phpunit-testing-in-laravel

tisuchi left a reply on How To Integrate Script • 1 week ago

I never tried. But it has a link for other kinds of interaction. You may check there and follow the instruction- https://github.com/php-tmdb/api

tisuchi left a reply on How To Delete Thread In This Forum? • 1 week ago

So far, in this forum, there is no way to delete any thread. Its for knowledge sharing, I believe, so that you are not able to delete that. The maximum that you can do is edit only.

tisuchi left a reply on Iwant To Design Webpage With Uploading Multiple Images And Store In Database With Progressbar • 1 week ago

Than do it, what stoped you? (lol, just kidding)

There are thousand of tutorials in online. You can google it.

Although, can recommend you that, check this tutorial to get the concept. http://itsolutionstuff.com/post/php-file-upload-progress-bar-with-percentage-using-form-jquery-exampleexample.html

tisuchi left a reply on Route Controller Method Delete • 1 week ago

Better show your code.

tisuchi left a reply on Controller Method Not Found • 1 week ago

First of all, you need to define your every route like this way-

Route::post('/', [
    'uses' => [email protected]'
]);

Read More: https://laravel.com/docs/5.4/routing

tisuchi left a reply on How To Integrate Script • 1 week ago

They have a plugin for Laravel. You may be check here..

https://github.com/php-tmdb/laravel

7th May, 2017

tisuchi left a reply on Carbon Exception Error • 2 weeks ago

Case 1

Just simply dd() your create_at with Carbon instance in your method to make sure that its working. If it is not working there properly, than add following line in your model-

protected $dates = ['created_at', 'updated_at'];

This line will make your created_at and updated_at timestamp.

tisuchi left a reply on Search With Location Radius • 2 weeks ago

You can use DB::Select in this case.

For example-

DB::select('SELECT * FROM
                    (SELECT id, name, address, phone, latitude, longitude, (' . $circle_radius . ' * acos(cos(radians(' . $lat . ')) * cos(radians(latitude)) *
                    cos(radians(longitude) - radians(' . $lng . ')) +
                    sin(radians(' . $lat . ')) * sin(radians(latitude))))
                    AS distance
                    FROM users) AS distances
                WHERE distance < ' . $max_distance . '
                ORDER BY distance
                OFFSET 0
                LIMIT 20;
            ');

tisuchi left a reply on Carbon Exception Error • 2 weeks ago

You know why you are getting this result wrongly when fetching? It because of you are storing a invalid monthly in database. That is why Carbon cannot detect the valid month name whatever you are strong.

tisuchi left a reply on Delete Row With Corresponding Rows From Database On Click • 2 weeks ago

Its basically simple.

Assuming here that the post's id is 1

$post = App\Post::find(1);
$post->delete();

If the foreign key's onDelete clause is defined, (which in your case it is), the post and ALL rows in other tables defined as you comments in your example.

Your create_comments_table foreign key should look like something like this:

$table->integer('post_id')->unsigned();
$table->foreign('post_id')->references('id')->on('post')->onDelete('cascade');

You may get the more intuitive tutorial here- https://laracasts.com/series/laravel-from-scratch-2017

tisuchi left a reply on Delete Row With Corresponding Rows From Database On Click • 2 weeks ago

If I can understand you properly, its called casecade delete.

In this case, you need to change your database table settings a bit.

For example, you have a users table and every user has a profile data in profiles table. Now in you profiles table

Schema::create('profiles', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            ...

In this table, every profile has a foreign key user_id. So, if you delete any record from users table, the corresponding record of this user from profiles table will be deleted.

Ref: https://laravel.com/docs/5.4/eloquent#model-events

tisuchi left a reply on Carbon Exception Error • 2 weeks ago

There are few ways to solve this issue, may be.

  1. Check month name in front env (jQuer / vueJS) whether it is valid or not. If invalid, show error in front page.

  2. In your store method, check month name by PHP whether it is valid or not. Return error, if it is invalid.

4th May, 2017

tisuchi left a reply on Whatsapp Api • 2 weeks ago

Never used, but one of the popular API package for whatsapp is https://github.com/mgp25/Chat-API

3rd May, 2017

tisuchi left a reply on Selected Option Dropdown • 2 weeks ago

You just follow the Github markdown process.

Laracasts is also following the same.

For example, use wrap your code by ``` to make it nicer way.

Just check the following link to get all the instruction- https://help.github.com/categories/writing-on-github/

tisuchi left a reply on Selected Option Dropdown • 2 weeks ago

Sure, go ahead.

tisuchi left a reply on Localhost Server Inaccessible - Help • 2 weeks ago

If you access your local mamp file by localhost:8888, you need to access your laravel also http://localhost:8888 instead of 8887, isn't that?

tisuchi left a reply on Selected Option Dropdown • 2 weeks ago

I can suggest you simply use vuejs to reduce your panic.

https://vuejs.org/v2/guide/forms.html#Select

tisuchi left a reply on Finding Class Methods Within API Docs • 2 weeks ago

Have you watched this api series? I hope can solve your issue- https://laracasts.com/series/incremental-api-development

tisuchi left a reply on Can We Create Multiple Role For User • 2 weeks ago

Either you can write roles, or you can use packages.

for creating roles.

userroles table

- id 
- rolename
- accessitems 

users table Add one more column named, userrole. In this column, you need to store id as a foreign key from userroles table.

Package

https://github.com/Zizaco/entrust https://github.com/spatie/laravel-permission https://github.com/romanbican/roles

tisuchi started a new conversation CDN For Vue-moment • 2 weeks ago

Does anybody knows the CND for vue-moment? I am trying to use vue-moment (https://github.com/brockpetrie/vue-moment) with CDN.

28th April, 2017

tisuchi left a reply on How To Recover Manually Deleted Migration Files In Laravel 5 • 3 weeks ago

May be you can try with composer update to get all the update of your framework. It might be bring back your core files.

Ref: http://developed.be/2014/08/29/composer-dump-autoload-laravel/

22nd April, 2017

tisuchi left a reply on Class Config Does Not Exist In Laravel 5.4 • 1 month ago

No worries. If it is working perfectly, than make it answer, so that others can be beneficiary from this question.

21st April, 2017

tisuchi left a reply on How To Move Laravel 5.4 Application To Shared Hosting? • 1 month ago

Ok, there are few ways to go.

I prefer just change your application public folder a bit. Check this tutorial- https://www.youtube.com/watch?v=pBTvXKGvrAA

tisuchi left a reply on Class Config Does Not Exist In Laravel 5.4 • 1 month ago

I don't feel that it will be any problem. Just give a try.

tisuchi left a reply on Can Anyone Guide Me How To Display The Table With This Format In Laravel • 1 month ago

Yes, just follow the @samalapsy option. Beside that, update a bit there-

Put your loop inside <tbody> tag.

<tbody>
    @foreach($projects as $project)
        <tr>
            <td> {{ $project->dateColumn }} </td>
            <td> {{ $project->myWalletColumn }} </td>
            <td> {{ $project->codeColumn }} </td>
            <td> {{ $project->devSupportColumn }} </td>
            <td> {{ $project->numberColumn }} </td>
            <td> {{ $project->numberAgainColumn }} </td>
        </tr>
    @endforeach
    
  </tbody>

tisuchi left a reply on Class Config Does Not Exist In Laravel 5.4 • 1 month ago

You can try by downloading stable php unit version. PHPUnit 6.0 may be problem for you.

Download PHPUnit 5 and try.

20th April, 2017

tisuchi left a reply on Multiple MorphToMany ? • 1 month ago

Here is the concept of Polymorphic Relations.

Imagine that, the Post and Video models will both have a tags method that calls the morphToMany method on the base Eloquent class.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    /**
     * Get all of the tags for the post.
     */
    public function tags()
    {
        return $this->morphToMany('App\Tag', 'taggable');
    }
}

Next, on the Tag model, you should define a method for each of its related models. So, for this example, we will define a posts method and a videos method:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Tag extends Model
{
    /**
     * Get all of the posts that are assigned this tag.
     */
    public function posts()
    {
        return $this->morphedByMany('App\Post', 'taggable');
    }

    /**
     * Get all of the videos that are assigned this tag.
     */
    public function videos()
    {
        return $this->morphedByMany('App\Video', 'taggable');
    }
}

Ref: https://laravel.com/docs/5.4/eloquent-relationships#many-to-many-polymorphic-relations

tisuchi left a reply on How To Create Dynamic <li> In Jstree • 1 month ago

Can you show you tables structure?

tisuchi left a reply on Token Mismatch Mobile Device • 1 month ago

Since you added your domain in session domain, that last solution that I can suggest you to use laravel caffeine. https://github.com/GeneaLabs/laravel-caffeine

But before that, make sure that, your mobile browser didn't disabled the cookies.

tisuchi left a reply on Laravel Relation For Different User Types • 1 month ago

To make it simpler, I support @ohffs comments. Just make it if else, may be-

The easier way to do it might be to check and return a different relation :

public function orders() { if ($this->is_shop) { return $this->hasMany(Order::class, 'created_by'); } return $this->hasMany(Order::class, 'fulfilled_by'); }

tisuchi left a reply on Laravel Relation For Different User Types • 1 month ago

May be you can try with Polymorphic relationships. Imagine that, each order has been placed by either shop or Supplier.

Check More: https://laravel.com/docs/5.4/eloquent-relationships#polymorphic-relations

tisuchi left a reply on Compare The Records In Two Table For A Mactch • 1 month ago

If you need to check by laravel, you may be try with join-

$users = DB::table('cache_user')
            ->join('main_users', 'cache_users.id', '!=', 'main_users.user_id')
            ->select('main_users.*')
            ->get();

Now, in $users variable, you will get all the mismached record from main_users table.

Now you may write query to insert into cache_users from $users.

tisuchi left a reply on How To Get More Info On TokenMismatchException Log Entries? • 1 month ago

May be you can play with Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php file.

tisuchi left a reply on Move Existing Row To Another Table • 1 month ago

If it is simply moving row from one table to another (without any existing data), just go to database, add a new row in Old_searchterms and delete from Searchterms.

Don't forget to update your respective migration file.

tisuchi left a reply on Disable Verify Csrf Token By Middleware • 1 month ago

There are few way to solve this issue, may be. But I suggest to go- App\Http\Kernel.php

And comment this line from protected $middleware array.

                'App\Http\Middleware\VerifyCsrf',

Of course, there are few more way to go.

tisuchi left a reply on Throwing Error Undefine Namecategory • 1 month ago

Isn't that because of the space?

Try (Just remove the empty space in front of namecategory)

$result[ $u->namecategory ] 

Instead of

$result[ $u-> namecategory ] 

tisuchi left a reply on Laravel 5.1.46 Middleware Weird Behaviour • 1 month ago

I am not sure, may be instead of clear session, you may disable session for a particular route.

You may check the following discussion that might be very close to your issue- https://laracasts.com/discuss/channels/laravel/laravel-51-disable-session-and-cookies-for-some-routes

tisuchi left a reply on Get Id Of Inserted Row And Use For The Next Query? • 1 month ago

You can just simply call-

$booking->id;

This will give you last inserted ID of $booking.

19th April, 2017

tisuchi left a reply on Join Query And Sub Join Query • 1 month ago

It seems that, its fine. May be you try with leftJoin() instead of simply join().

Ref: https://laravel.com/docs/master/queries#joins

tisuchi left a reply on Join Query And Sub Join Query • 1 month ago

In controller, may be you need to add groupBy()-

$users = DB::table('mastercategory')
          ->join('subcategory', 'mastercategory.idcategory', '=', 'subcategory.idcategory_mastercategory')
          ->join('subling', 'subcategory.idsubcategory', '=', 'subling.idsubcategory_subcategory')
          ->select('mastercategory.*', 'subcategory.*','subling.*')
          ->groupBy('mastercategory.namecategory')
          ->get();
Edit Your Profile
Update

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