afoysal

afoysal

Member Since 3 Years Ago

Experience Points 10,690
Experience
Level
Lessons Completed 17
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

01 Oct
1 month ago

afoysal started a new conversation Version Upgrade

How to Upgrade Laravel 5.3 to Laravel 5.7 ?

19 Sep
1 month ago

afoysal started a new conversation Missing Public Folder In Laravel

I received a project from my client. I tried to install it in my local machine using php artisan serve command and I found below error

enter image description here

After searching in Google I found this question. Then I found that there is no public folder in my project directory.

enter image description here

Is there any specific reason to delete this public folder ? or it is left accidentally ?

I changed

chdir($this->laravel->publicPath());

in vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php To :

chdir('/');

as per this question. After that I am getting a blank white page while I am running my project using php artisan serve.

What is the solution ?

08 Aug
3 months ago

afoysal started a new conversation PhpMyAdmin Issue

I am getting below error in phpMyAdmin.

enter image description here

05 Aug
3 months ago

afoysal started a new conversation Passing Optional Parametere

I am developing an API. In this regard I have below route in my api.php file.

Route::post('/upload/{address}', '[email protected]');

Here often I would like to pass address often not. How can I write this route ?

19 Jul
3 months ago

afoysal left a reply on Catching Parameter From URL In Vue.js

Thanks @topvillas . If I use your solution I got error like below.

[Vue warn]: Invalid prop: type check failed for prop "id". Expected String, got Number.

Thanks.

afoysal left a reply on Catching Parameter From URL In Vue.js

Thanks @topvillas . How can I remove this error ?

afoysal started a new conversation Catching Parameter From URL In Vue.js

I am trying to collect id value from URL.

In my index.js of router file I have below code:


    {   path: '/word/:id',
        name: 'word',   
        component: Word,
        props: true,
    }, 

In my component I have below code:


    <script>
        export default {
            props: {
                 id: Number,
            },
            created() {
                 this.routeChanged();
            },
            watch: {
                'id': 'routeChanged',
            },
            methods: {
                routeChanged () {
                    console.log(this.id);
                },
            },
        };
    </script>

I am getting below error:

[Vue warn]: Invalid prop: type check failed for prop "id". Expected Number, got String.
17 Jul
3 months ago

afoysal left a reply on Using HasMany()

Thanks @christianyeah for your reply. Can I get result like below from your solution ?

Product1 --Model 1 --Variant1 --Model2 --Variant1 --Variant2 --Variant3

Product2 --Model1 --Variant1 --Variant2

Thanks.

14 Jul
4 months ago

afoysal left a reply on Relationship In Laravel-5.6

Thanks @Swaz . If I use your solution I am getting all the translations which sentence_id is matched with idof sentences table, but post_id is not matching with the current post id of post table.

13 Jul
4 months ago

afoysal left a reply on Relationship In Laravel-5.6

Thanks @staudenmeir . I am trying with different options. I made post before in SO, then I tried again and made post here. Thanks.

afoysal started a new conversation Relationship In Laravel-5.6

I have three tables like below.

    posts
        id   - integer
        name - string
    
    sentences
        id      - integer
        post_id - integer
        name    - string
    
    translations (word by word)
        id          - integer
        post_id     - integer
        sentence_id - integer
        word_id     - integer
        name        - string

In PostController.php I am trying to fetch data like below

return Post::with(['sentences', 'sentences.translations'])->limit(2)->get();

I have function in post.php model is like below

    protected $primaryKey = '_id';

    public function sentences()
    {
        return $this->hasMany('App\Model\sentence', 'post_id','id');
    }

I have function in sentences.php model is like below

    protected $primaryKey = '_id';
    
    public function translations()
    {
        return $this->morphMany('App\Model\translation', 'sentence_id','id');
    }

I would like to fetch posts along with sentences and translations.

I can fetch post and sentences but I am facing issue while I am trying to fetch translations.

I am getting below error

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'translations.sentence_id_id' in 'where clause' (SQL: select * from `translations` where `translations`.`sentence_id_id` in (1, 2

12 Jul
4 months ago

afoysal started a new conversation Deploy API

I developed an API using Laravel. How can I deploy it in a Shared Hosting ? Which steps should I take ?

11 Jul
4 months ago

afoysal left a reply on Using HasMany()

public function color()
{
        return $this->hasMany('App\Model\color', 'model_id', 'model_id','varient_id','varient_id');  // Is it possible to use more column name here like this? 
}

afoysal left a reply on Using HasMany()

Thanks @christianyeah . I have another table related to this tables named color. color table has variant_id and model_id. I am using query like you.

How can I make relation with them ?

10 Jul
4 months ago

afoysal left a reply on Catch URL Parameter

Thanks @bobbybouwmann. Actually I am new in Vue.js. I am trying to catch value from URL. I don't know how to do that perfectly. Thanks.

afoysal started a new conversation Using HasMany()

I have three table Product, Model and Variant. Product has many Model. Model has many Variant. There is product_id in Model table. There are product_id and model_id in Variant table.

How can I use hasMany() in Model model class to fetch Products along with Model and Variant in Product controller?

afoysal left a reply on Route Model Binding In Laravel 5.6

Thanks @bobbybouwmann. What should I do if I would like to fetch only 5 Post ?

afoysal left a reply on Route Model Binding In Laravel 5.6

Thanks @newbie360 . I am developing an API. Should I write like this ?

return $post->load('comments')->image;

afoysal left a reply on Route Model Binding In Laravel 5.6

Thanks @bobbybouwmann . One comment has one images.

I have relationship comment model is like below

public function image() { return $this->hasOne('App\Model\image', 'id', 'image_id'); }

How can I attach image with this Query ?

afoysal left a reply on Route Model Binding In Laravel 5.6

Thanks @toby . My parent model post is not loading. Thanks.

afoysal started a new conversation Route Model Binding In Laravel 5.6

I am using Laravel resource controller with route model binding in my API development project. I have below code

public function show(Post $post)
{
    return $post->comments()->get();

}

I am using below URL

http://127.0.0.1:8000/api/posts/1

I would like to retrieve both post values with comments value.

But I am getting only comments values.

09 Jul
4 months ago

afoysal left a reply on Catch URL Parameter

@bobbybouwmann and @m7vm7v I updated the post. Thanks.

afoysal left a reply on Catch URL Parameter

Thanks @bobbybouwmann . watch is working from second time not from first time. Thanks.

afoysal started a new conversation Catch URL Parameter

How can I catch URL parameter when URL changes inside Vue.js Component ?

08 Jul
4 months ago

afoysal left a reply on Get Join Query Result In Different JSON Object Key

Thanks @Tray2 . I know raw SQL but I am looking for Eloquent solution. Thanks.

afoysal left a reply on Navigation In Vue.js

Thanks @Erik. It is not working without path. Thanks.

afoysal started a new conversation Navigation In Vue.js

I have below code in my HTML Code.

    <router-link :to="{ path: '/word/',name: 'word', params: { id: word._id }}"></router-link>

My route settings in index.js like below

    export default new Router({
        mode: 'history',
        routes: [
            {
                path: '/',
                name: 'mainbody',
                component: MainBody
            },
            {
                path: '/word/:id',
                name: 'word',
                component: Word
            }
        ]
    });

But it is not working.

afoysal started a new conversation Get Join Query Result In Different JSON Object Key

I have a Query like below in my Laravel controller which one I am using for API development.

    return $post
                ->comments()
                ->join('translationCHN', function ($join) {
                    $join->on('comment.word_id', '=', 'translationCHN.word_id');
                    $join->on('comment.sentence_id', '=', 'translationCHN.sentence_id');
                })
                ->get();

I am getting output in JSON format. From this query I would like to get result in different JSON Object Key translationCHN.

How can do that ?

07 Jul
4 months ago

afoysal started a new conversation Props Issue

Is there any issue in below code.

<script>
    import axios from 'axios';
    export default {
        data () {
            return {
                sentence:'',
            }
        },
        props: ['sentenceID',sentenceName'],
        methods: {
            get_sentence (sentenceName,sentenceID) {
                axios.get('/'sentenceName+'/'+sentenceID)
                .then(response => {
                    this.sentence = response.data;
                    console.log(response.data);
                }).catch();
            }
        },
        created: function() {
            this.get_sentence(this.sentenceName,this.sentenceID);
        },
    }
</script>
05 Jul
4 months ago

afoysal started a new conversation Condition Based Iteration Using For Loop In JavaScript

I am trying to play audio file using for loop in vue.js. My code is like below

    for(var i = this.start; i < this.end; i++) {
        var audio = new Audio('some value');
        audio.play();
        if(audio.ended == true) {
            //go for another iteration
        }
    }

I would like to go for another iteration after the condition is true. Actually I would like to play audio file one after another. How can I do that ?

afoysal started a new conversation Use For Loop Inside Vue.js Method

How to use for loop inside vue.js method ?

createSelectedContacts: function(contacts){
      for(i = 0; i <= contacts.length; i++){
            this.selectedContacts.push(contacts[i].id);
      }
},
03 Jul
4 months ago

afoysal left a reply on Table Name In Output Of Join() Query

Thanks @staudenmeir . I am working with an API. Thanks.

02 Jul
4 months ago

afoysal left a reply on Fetch Certain Amount Of Character From Database

Thanks @crnkovic . Your solution is working but your solution is a part of a query. That's why I need solution in later one also.

afoysal left a reply on Table Name In Output Of Join() Query

Thanks @staudenmeir . I have join query like below

->join('employee', function ($join) {
                $join->on('company.surah_id', '=', 'employee.surah_id');
                $join->on('company.verse_id', '=', 'employee.ayah_id');
            }) 

I have a field text in employee table. I would like to fetch certain amount of character. More over I would like to fetch like below

"employee": {
     "text": "Jamal"
} 

afoysal left a reply on Fetch Certain Amount Of Character From Database

Thanks @staudenmeir . Can I use below query ?

->get(['*', 'tafsir_ahbayan.tafsir as tafsir_ahbayan', 'tafseer_zakariya.tafsir as tafseer_zakariya' => function ($query) {
                $query->select('id', 'surah_id', 'ayah_id')->selectRaw('LEFT(`tafsir`, 500) as `tafsir`');
            }]);
01 Jul
4 months ago

afoysal left a reply on Table Name In Output Of Join() Query

Thanks @staudenmeir . No, I need below output

"contacts": {
     "id": 1,
     "employee_id": 1,
     "text": "good",
     "employee": "Jamal"
}

afoysal left a reply on Fetch Certain Amount Of Character From Database

Thanks @crnkovic . I am working in API Development.

afoysal started a new conversation Fetch Certain Amount Of Character From Database

How to fetch certain amount of character from database using Laravel query ?

I have query like below

return $company->employee()->with('motorCycle', 'children')->get();

There is a column named motorCycle.text . I would like to fetch 500 character from that field.

How can I do that ?

afoysal started a new conversation Table Name In Output Of Join() Query

I have a Query like below. I am outputting json response.

$users = DB::table('users')
            ->join('contacts', 'users.id', '=', 'contacts.user_id')   // need table name as object key here
            ->select('users.*', 'contacts.phone', 'orders.price')
            ->get();

afoysal left a reply on Multiple Condition Laravel Join()

Thanks @AlexDemin . Can I use like below ?

Post::has('comments.votes')
    ->join('tafsir_ahbayan', 'tafsir_ahbayan.surah_id', '=', 'quran.surah_id','tafsir_ahbayan.my_id', '=', 'quran.my_id')
    ->where(...another conditions...)
    ->get();

afoysal started a new conversation Multiple Condition Laravel Join()

How to add multiple condition in Laravel join() ? like

Post::has('comments.votes')->->join('tafsir_ahbayan', 'tafsir_ahbayan.surah_id', '=', 'quran.surah_id'  // I would like to add more conditions here)->get();
29 Jun
4 months ago

afoysal started a new conversation One To Many To One Relationship

How to do One to Many to One relationship in Laravel. I have three tables company, employee and motorcycle. One company has many employee. One employee has one motorcycle.

How can I do that Eloquent relationship in controller ?

28 Jun
4 months ago

afoysal started a new conversation Sending Argument To Resource Controller

I am using resource controller. My route is Route::apiResource('suras', 'SuraController');.

I have controller like below

<?php

namespace App\Http\Controllers;

use App\Model\Sura;
use Illuminate\Http\Request;

class SuraController extends Controller
{
    public function show(Sura $sura)
    {
        return $sura->ayahs()->offset(0)->limit(20)->get();
    }
}

Now I have to send parameter to offset($offset) and limit($limit).

I have to load first 20 records when I send first request. Then next 20 records when I send second request and so on.

How can I do that ?

27 Jun
4 months ago

afoysal started a new conversation One To Many Relationship In API Development

I am trying to develop an API. In this regard my route in api.php file is like below

Route::apiResource('suras', 'SuraController');

My Model is like below

Sura.php

<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Sura extends Model
{
    protected $table      = 'surah_name';
    protected $primaryKey = '_id';
    public function ayahs()
    {
        return $this->hasMany('App\Model\Quran', 'surah_id', '_id');
    }   
}

My Controller is like below

SuraController.php

<?php

namespace App\Http\Controllers;

use App\Model\Sura;
use Illuminate\Http\Request;

class SuraController extends Controller
{
    public function show(Sura $sura)
    {
        // I would like to fetch specific number of ayahs here. I tried different code here
    // but could not get correct result.
    }
}

I am browsing this URL http://127.0.0.1:8000/api/suras/78.

22 Jun
4 months ago

afoysal left a reply on Using Resource

Thanks @Dhaval_patel . I read your link. What will happen if I not use resource in Laravel ? Thanks.

afoysal started a new conversation Using Resource

What are the benefit of using resource? What will happen if I not use resource in Laravel ? Thanks.

20 Jun
4 months ago

afoysal left a reply on Console Message Of Vue.js

Thanks @NickVahalik . I tried in several ways but none is working. Thanks.

afoysal left a reply on Hot Reload Is Not Working In Vue-Cli Fresh Installation

Thanks @NickVahalik . My Hot Reload of vue-cli is not working. Thanks.

afoysal left a reply on Console Message Of Vue.js

Thanks @NickVahalik for your reply. How to enable Hot reload in vue-cli ?

How to know my Hot reload is working properly ?

afoysal left a reply on Proper Way Of Adding CSS File In Vue.js Application

Thanks @rin4ik for your reply. Is there any folder in Vue.js named resources and public ?