arctushar

arctushar

Member Since 3 Years Ago

Dhaka

Experience Points 2,745
Experience Level 1

2,255 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 2
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

25 May
3 weeks ago

arctushar started a new conversation WhereIn With Only One Value

WhereIn with only one value for all item

For Example

In a table there are id, cost and item_id field.

For same item_id there are multiple id.

Now I want that pick row where item_id are 2,6,9 and for all item_id it will pick only last id for the specific item_id

so result will be Cost of 2, cost of 6 and cost of 9 based on latest id.

How Can I do that

14 May
1 month ago

arctushar left a reply on OrwhereNotNull

Finally I made it

$earning=Earning::where('codelist_id',$request->code)->where(function ($query) {
        $query->orwhereNotNull('q4')
        ->orwhereNotNull('q3')
        ->orwhereNotNull('q2')
        ->orwhereNotNull('q1');
            })->orderBy('year','desc')->first();

arctushar started a new conversation OrwhereNotNull

|codelist_id|q1|q2|q3|q4|year| |----|----|----|----|----|----| |224|NULL|NULL|NULL|NULL|2019| |----|----|----|----|----|----| |224|NULL|NULL|10|NULL|2018| |----|----|----|----|----|----| |224|NULL|NULL|13.67|NULL|2017| |----|----|----|----|----|----| |224|NULL|NULL|NULL|NULL|2016|

I have some data like above in a table. I want to make query as above

  1. if any one value of q1 or q2 or q3 or q4 in 2019 is found not null, then pick 2019 other wise search for next year 2018, then so on 2017, 2016

For example as there is not value in any of q1,q2,q3,q4 in 2019 then it will get data of 2018 as there is q3 value. if there was no value in q3 of 2018, then picked 2017.

is it possible ??????

07 Dec
6 months ago

arctushar left a reply on GroupBY And Extra Parameter How

I have used below code

return $userInfo = DB::table('portfolios')->select('quantity', DB::raw('sum(quantity*buy) as buytotal'), DB::raw("sum((SELECT ltp FROM dsedatas where dsedatas.codelist_id=codelist_id ORDER BY id DESC LIMIT 1)) as selltotal"),'codelist_id')->groupBy('codelist_id')->get(); 

but it is giving wrong data from dsedatas ltp

arctushar started a new conversation GroupBY And Extra Parameter How

Hi I am trying to get result as below

return $userInfo = DB::table('portfolios')->select('quantity', DB::raw('sum(quantity*buy) as buytotal'), DB::raw('sum(quantity*(Dsedata::where('codelist_id',codelist_id))) as selltotal'),'codelist_id')->groupBy('codelist_id') ->get();

this is giving error but when I m using below query, its works fine

return $userInfo = DB::table('portfolios')->select('quantity', DB::raw('sum(quantity*buy) as buytotal'), DB::raw('sum(quantity*codelist_id) as selltotal'),'codelist_id')->groupBy('codelist_id') ->get();

How can I make query as first code given above?

plz help

08 Sep
9 months ago

arctushar started a new conversation Array Iteration In Blade Not Working

My code in controller is as below

$obj = [];
foreach($sectors as $sector){
    foreach($sector->codelists as $objindex=>$codelist){            
        $dsedatas=Dsedata::where('codelist_id',$codelist->id)->where('date',$date1)->get(); 
        foreach($dsedatas as $i=>$dsedata){
            $obj[$objindex][$i]=$dsedata;
        }
    }
}
return view('minalysistest')->with('obj',json_encode($obj));

and my code in blade is as below

{{$obj}}
@foreach($obj as $sector)
{{$sector}}
<hr/>
@endforeach

here only $obj is showing but foreach not working.

my {{$obj}} is as below

{"4":{"25":{"id":1611215,"codelist_id":33,"ltp":"11.0","trade":95,"value":"8.487","volume":774080,"date":"2018-08-30","time":"13:54:05","created_at":"2018-08-30 13:54:05","updated_at":"2018-08-30 13:54:05"},"29":{"id":1612445,"codelist_id":33,"ltp":"10.9","trade":128,"value":"12.178","volume":1112495,"date":"2018-08-30","time":"14:08:05","created_at":"2018-08-30 14:08:05","updated_at":"2018-08-30 14:08:05"}},"18":{"51":{"id":1614691,"codelist_id":219,"ltp":"16.9","trade":293,"value":"27.150","volume":1591319,"date":"2018-08-30","time":"14:28:06","created_at":"2018-08-30 14:28:06","updated_at":"2018-08-30 14:28:06"}},"21":{"44":{"id":1609459,"codelist_id":252,"ltp":"25.4","trade":334,"value":"15.521","volume":608059,"date":"2018-08-30","time":"13:30:05","created_at":"2018-08-30 13:30:05","updated_at":"2018-08-30 13:30:05"}},"31":{"63":{"id":1614239,"codelist_id":251,"ltp":"61.4","trade":408,"value":"41.515","volume":675358,"date":"2018-08-30","time":"14:24:06","created_at":"2018-08-30 14:24:06","updated_at":"2018-08-30 14:24:06"}}}

what is the problem ?? what is the solution ?

04 Sep
9 months ago

arctushar started a new conversation Max Memory Failed

$datas=Sector::with(['codelists'=>function($query)use($date1,$logicarray){
    $query->select('id','sector_id','code')->with(['dsedata'=>function($query)use($date1){
    $query->select('trade','id','ltp','codelist_id','date','value','volume','time')->where('dsedatas.date',$date1);
}]);
}])->get(); 

I have above code. There are total 9 sectors, 352 codelists, 882595 dsedata .

is there any way to reform the above code so that it works fine and light ?

26 Jun
11 months ago

arctushar started a new conversation Error In @section

if I use code in blade 5.6 as below

@section('ogtype',{{$node->type}})

It show error as below

syntax error, unexpected '<' (View: E:\xampp\htdocs\resources\views\node\detail.blade.php)

and

<?php $__env->startSection('ogtype',<?php echo e($node->type); ?>); ?>

But If I use code as below

@section('ogtype')
{{$node->type}}
@endsection

Its working, why one line not working ?

arctushar left a reply on Many To Many Showing Only Few Rows

Node model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Node extends Model
{
    public function users(){
        return $this->belongsToMany('App\User');
    }
    public function tags(){
        return $this->belongsToMany('App\Tag');
    }
    public function statistics(){
        return $this->belongsToMany('App\Statistic');
    }   
    public function nodedescription(){
        return $this->hasOne('App\Nodedescription');
    }   
}

Tag model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Tag extends Model
{
    public function nodes(){
        return $this->belongsToMany('App\Node');
    }
}

arctushar left a reply on Many To Many Showing Only Few Rows

@Artak For your cod error is

syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'

Your last code need [ ] for with , I changed it to with

    $node = Node::with(['tags' => function($query){
                $query->withTrashed();
        }])->find(1723);

In this case error is

Method Illuminate\Database\Query\Builder::withTrashed does not exist.

arctushar left a reply on Many To Many Showing Only Few Rows

@bobbybouwmann I tried, same result, only two tags rows

arctushar started a new conversation Many To Many Showing Only Few Rows

I have Two models with three table. Models are Node & Tag. And have Three tables named- nodes, tags, node_tag. My Node Model code is as below

    public function tags(){
        return $this->belongsToMany('App\Tag');
    }

My Tag model code is as below

    public function nodes(){
        return $this->belongsToMany('App\Node');
    }

When I call in controller as below

return $node=Node::find(1723)->tags;

this is showing only two rows. But when I call in controller as below

return $user = DB::table('node_tag')->where('node_id', 1723)->get();

It shows four rows. What is the problem ?

25 Jun
11 months ago

arctushar started a new conversation WhereHas Showing Error Why?

I have Three Model- Sector, Codelist and Dsedata. Basis of this I have eloquent as below which works

$datas=Sector::with(['codelists.dsedata'=>function($query)use($date1){
    $query->select('id','codelist_id','date','volume')->where('dsedatas.date',$date1)->where('volume','>',600);
}])->get();

But when I add whereHas as below command. it show error

$datas=Sector::whereHas(['codelists.dsedata'=>function($query)use($date1){
    $query->select('id','codelist_id','date','volume')->where('dsedatas.date',$date1)->where('volume','>',600)->get();
}])->with(['codelists.dsedata'=>function($query)use($date1){
    $query->select('id','codelist_id','date','volume')->where('dsedatas.date',$date1)->where('volume','>',600);
}])->get();

The error is : Method name must be a string

and the error location is

    protected function getRelationWithoutConstraints($relation)
    {
        return Relation::noConstraints(function () use ($relation) {
            return $this->getModel()->{$relation}();
        });
    }
 
24 Jun
11 months ago

arctushar left a reply on Has Not Working In Relationship Query

@Artak , not working

I got one solution as below

        $codelists=Codelist::select('id','code','category')
            ->whereHas('dsedatalast',function($query)use($date,$alertvalue){
            $query->select('id','codelist_id','value','date','volume','ltp')->where('date',$date)->where('value','>',$alertvalue/10);
        })
        ->with(['dsedatalast'=>function($query)use($date,$alertvalue){
            $query->select('id','codelist_id','value','date','volume','ltp')->where('date',$date)->where('value','>',$alertvalue/10);
        }])->with(['dse2datalast'=>function($query)use($date,$alertvalue){
            $query->select('id','codelist_id','volume','cp')->where('dse2datas.date','<',$date);
        }])->get();

arctushar left a reply on Route Showing Strange

Solve, There is a folder named 'chart' in public folder

23 Jun
11 months ago

arctushar started a new conversation Route Showing Strange

My web. php in route have only below route

Route::get('/chart', function(){ return 'bangladehs'; });

It is going to loging page. But when I renamed chart to chart1 it is working fine.

My php artisan route:list showing as below

+--------+----------+----------+------+---------+--------------+
| Domain | Method   | URI      | Name | Action  | Middleware   |
+--------+----------+----------+------+---------+--------------+
|        | GET|HEAD | api/user |      | Closure | api,auth:api |
|        | GET|HEAD | chart    |      | Closure | web          |
+--------+----------+----------+------+---------+--------------+

Even I tried route:clear but still not solved.

NB: I have installed chartjs module.

arctushar left a reply on Has Not Working In Relationship Query

no, but due to arguement , dsedatalast is null.

arctushar left a reply on Has Not Working In Relationship Query

@mballaag

my new code is as below

return $codelists=Codelist::select('id','code','category')->with(['dsedatalast'=>function($query)use($date,$alertvalue){
            $query->select('id','codelist_id','value','date','volume','ltp')->where('date',$date)->where('value','>',$alertvalue/10);
        }])->whereNotNull('dsedatalast')->get(); 

It showing below error

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dsedatalast' in 'where clause' (SQL: select `id`, `code`, `category` from `codelists` where `dsedatalast` is not null) "
22 Jun
11 months ago

arctushar started a new conversation Has Not Working

My eloquent is as below

return $codelists=Codelist::select('id','code','category')->with(['dsedatalast'=>function($query)use($date,$alertvalue){
            $query->select('id','codelist_id','value','date','volume','ltp')->where('date',$date)->where('value','>',$alertvalue/10);
        }])->has('dsedatalast')->get(); 

Here some dsedatalast is null and some has value. I wanted to ignore where dsedatalast is null and need where dsedatalast has value

My correct output of above code as as below

[{"id":1,"code":"1JANATAMF","category":"A","dsedatalast":null},{"id":2,"code":"1STPRIMFMF","category":"A","dsedatalast":{"id":691653,"codelist_id":2,"value":"1.472","date":"2018-06-07","volume":116385,"ltp":"12.6"}},{"id":3,"code":"AAMRATECH","category":"A","dsedatalast":{"id":691655,"codelist_id":3,"value":"1.440","date":"2018-06-07","volume":51177,"ltp":"28.0"}},{"id":4,"code":"ABB1STMF","category":"A","dsedatalast":null},{"id":5,"code":"ABBANK","category":"Z","dsedatalast":{"id":691426,"codelist_id":5,"value":"5.079","date":"2018-06-07","volume":408603,"ltp":"12.5"}},{"id":6,"code":"ACI","category":"A","dsedatalast":{"id":691656,"codelist_id":6,"value":"13.540","date":"2018-06-07","volume":39686,"ltp":"341.4"}},{"id":7,"code":"ACIFORMULA","category":"A","dsedatalast":{"id":691657,"codelist_id":7,"value":"4.334","date":"2018-06-07","volume":26471,"ltp":"164.7"}]

I even used whereHas instead of, result is same. NB: I want only those codelists whre dsedatalast is not null.

04 Jun
1 year ago

arctushar left a reply on Localhost Works But Server Show Error

@Cronix thnx, but I tried, it did not clear the config file. So I needed to manually delete it.

arctushar left a reply on Localhost Works But Server Show Error

Finally solved, Just deleted config.php from bootstrap/cache

Thanks all for helping me

arctushar left a reply on Localhost Works But Server Show Error

finally got the line

  'session' => 
  array (
    'driver' => 'file',
    'lifetime' => '120',
    'expire_on_close' => false,
    'encrypt' => false,
    'files' => 'E:\xampp\htdocs\storage\framework/sessions',

what will be the correction? plz suggests

arctushar left a reply on Localhost Works But Server Show Error

I have copied all ifles in newfolder, then searched and found this

H:\Desktop\New folder\public\css\htdocs - Shortcut.lnk (1 hit)

H:\Desktop\New folder\storage\logs\laravel.log (113 hits)
03 Jun
1 year ago

arctushar left a reply on Localhost Works But Server Show Error

what is OP's code? Should I reinstall my laravel again?

arctushar left a reply on Localhost Works But Server Show Error

Checked all files, did not find solutions

arctushar started a new conversation Localhost Works But Server Show Error

error is

file_put_contents(E:\xampp\htdocs\storage\framework/sessions/HhDScpMuJWXrB9GgSyMCFBe5ySYOvdRDyfQmFaxD): failed to open stream: No such file or directory

/home/tsrnd4cpnl/public_html/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php

What I did to solv problem

Comoser install composer update dump autoload cache clear write permission to storage write permission to storage\session write permission to bootstrap\cache

but not solved. My script works very well in localhost. But When I uploaded to shared server, it is not working.

23 May
1 year ago

arctushar left a reply on Where Function In BelongsToMany Problem

@Vilfago thnx, your last one of last comment solved my problem. But why first one of last comment is getting all nodes with other tags? My another site i did below . Where constraints not working?

arctushar left a reply on Where Function In BelongsToMany Problem

@Snapey Thnx, I have deleted id and make (node_id,tag_id) unique. Now I can edit manually.

arctushar left a reply on Where Function In BelongsToMany Problem

@snapey thnx for ur reply

  1. $nodes=Node::with(['tags'])->get(); is returning all nodes with related all tags
  2. I have renamed method node to nodes. But still giving error as mentioned earlier as 'constraint violation: 1052'
  3. in pivot table I m using id so that in future I can edit manuay by phpmyadmin.

still waiting to resolve this problem.

arctushar left a reply on Where Function In BelongsToMany Problem

@jonjie I need constraints on tag. I want specic nodes where relationship with id 4 . So

arctushar left a reply on Where Function In BelongsToMany Problem

@Mahmoudy , I tried, but failed error is as below

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous (SQL: select `tags`.*, `node_tag`.`node_id` as `pivot_node_id`, `node_tag`.`tag_id` as `pivot_tag_id` from `tags` inner join `node_tag` on `tags`.`id` = `node_tag`.`tag_id` where `node_tag`.`node_id` in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) and `id` = 4)

arctushar started a new conversation Where Function In BelongsToMany Problem

Wanted to select nodes that have tag id 4 in NodeController I am using below function

$nodes=Node::with(['tags'=>function($query)use ($id){
            $query->where('tags.id','4');
        }])->paginate(12);

I have also tried to use 4 instead of '4' and also tried in NodeController as below

$nodes=Node::with(['tags'=>function($query)use ($id){
            $query->where('tag_id','4');
        }])->paginate(12);

and I have below models Node model is as below

    public function tags(){
        return $this->belongsToMany('App\Tag');
    }

Tag table has below field ['id','name'] and tag models is as below

class Tag extends Model
{
    public function node(){
        return $this->belongsToMany('App\Node');
    }
    public $timestamps = false;
}

all above cases not showing error but result is all nodes id 1-12, whether tag_id is 4 or not What is the problem and what is the solution ?

03 May
1 year ago

arctushar started a new conversation Why Auto Truncated In Blade Template

Hi in my database I have inserted "11Sep17: A+ & ST-2 (NCR), " when I want to try this in controller "return $codelist->crdrating;" is working fine but when trying {!!$codelist->crdrating!!} not showint, only showing "11Sep17:" why ??

28 Apr
1 year ago

arctushar left a reply on Cant Understand What Will Be The Eloquent

$users=User::select('id','name')->with(['cashpayment'=>function($query){ $query->select('id','user_id','cashpayment','date')->where('cashdatas.date','2018-04-26')->latest()->first(); }])->get();

All cashpayment is blank, But only one cashpayment is showing.

27 Apr
1 year ago

arctushar left a reply on Cant Understand What Will Be The Eloquent

I have read eloquent and query. But for this query, I tried to find, but can't get how can I do that. Totally out of my understanding :(

arctushar started a new conversation Cant Understand What Will Be The Eloquent

Hi I have table 'cashdatas' with Model 'Cashdata' with column id,user_id,cashpayment,date

in specific day A user can pay cash many times. and cash payment is the total cash pay in a specific date.

I have script so it will calculate total cashpayment in the specific date and create new entry with total cash pay (cashpayment will increase in every entry).

Now I want to make a query which will get Last 10 Highest cashpayment userlist in a specific date. What will be the eloquent.

Is it possible ???

25 Apr
1 year ago

arctushar started a new conversation Error In 'or Condition' In Blade Template

@if($data->id!=9 || $data->id!=1) 
@endif 

I have used above but not working. But If i use only one condition, it works fine. What is the solution ?

27 Mar
1 year ago

arctushar started a new conversation Variable Error

$date=Dsedata::select('date')->where('codelist_id',2)->orderBy('created_at', 'desc')->first()->date;
        return $coderesults=Codelist::with(['otherdata','dsedata'=>function($dquery){
            $dquery->where('date',$date);
        },'sector','meeting','comments' => function($query)
        {
            $query->with('user')->where('published', 'yes');

        }])->find(2);

above is my code in controller

and error is as below

ErrorException (E_NOTICE)
Undefined variable: date

and its showing in line "$dquery->where('date',$date);"

what is the solution

20 Mar
1 year ago

arctushar started a new conversation Relationship In Relationsip In Relationship With Limit

Hi I have a table name and column name given below

  1. sectors = 'id' , 'name'
  2. codelists = 'id' , 'name' , 'sector_id'
  3. datas = 'id', 'codelist_id' , 'trade', 'volume'

In Codelist Model I have 'datas' method

    public function datas()
    {
        return $this->hasMany('App\Data');
    }

in Sector Model I have method

    public function codelists()
    {
        return $this->hasMany('App\Codelist');
    }

Now I want to make a query which will give me

  1. Last 03 Sector name
  2. Correspondence Every sector last 04 codelist
  3. then corresondence every codelist last 05 datas

Is it possible ?? I tried by below

        return $sectors=Sector::select('id','name')->with(array('codelists'=>function($query){
                $query->with(array('datas'=>function($query1){
                    $query1->take(5)->get();
                })
                )->take(4)->get();
            }))->take(3)->get();

Here I found that only for first codelist of first first sector, 05 datas is showing. All other is null array for datas.

can anybody give me solution ?

18 Mar
1 year ago

arctushar started a new conversation Take By Group And Item Both

Hi I have an database with below info. I have 50 users with country. Now each users have several posts say some users have 15 post, some users have 2 posts and some users have no posts.

Now I want an eloquent which will select last 03 users with where country=x and also want upto 05 posts for each 03 users

Is it possible? How can I do it with easy way ?

07 Mar
1 year ago

arctushar started a new conversation Datadisplay Error

my query result by axios is as below

{ "id": 1, "code": "1JANATAMF", "sector_id": 1, "category": "A", "yearend": null, "paidup": null, "reserve": null, "crdrating": null, "cashdividend": "0.00", "stockdividend": "0.00", "created_at": null, "updated_at": null, "otherdata": { "id": 1, "codelist_id": 1, "freefloat": "9.99", "created_at": "2018-03-07 00:00:00", "updated_at": null }, "dsedata": { "id": 330, "codelist_id": 1, "ltp": "6.2", "trade": 15, "volume": 34420, "date": "2018-03-07", "time": "13:28:46", "created_at": "2018-03-07 13:28:46", "updated_at": "2018-03-07 13:28:46" }, "sector": { "id": 1, "name": "Mutual", "created_at": null, "updated_at": null } }

it is showing as whole, no error. But when I use @{{coderesults.otherdata}} and also showing otherdata values but problem is when I use @{{coderesults.otherdata.freefloat}} vuejs not working. and not showing data.

NB: @{{coderesults.dsedata.ltp}} is working.

arctushar left a reply on Controller Function Not Working

Route::resource('/dsedata', 'DsedataController');

Route::resource('/sector', 'SectorController');

First one not working, but second one working

arctushar started a new conversation Controller Function Not Working

Hi, I have Controller as below Code

    public function edit(Dsedata $dsedata)
    {
        return $dsedata;
    }

but showing nothing but if I use as below

    public function edit(Dsedata $dsedata)
    {
        return Dsedata::find(1);
    }

showing result, Noted that my url is http://localhost/dsedata/1/edit So what is the problem?

My migration was as below

    public function up()
    {
        Schema::create('dsedatas', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('codelist_id'); 
            $table->decimal('ltp',12,1);
            $table->integer('trade');
            $table->integer('volume');
            $table->date('date');
            $table->time('time');
            $table->unique(['codelist_id','volume','date']);
            $table->timestamps();
        });
    }
15 Oct
1 year ago

arctushar started a new conversation Sort Result As Group

Hi I have an eloquent like

Record::where('codelist_id','=',array(1,2))->get()

result is showing ok. NB there r multiple row which have codelist_id=1 and also multiple row which have 2.

they r not serialise, I can serialize by using ORDER BY. But I need other.

in the view I want to make two html table. On will be based on codelist_id=1 and other will be codelist_id=2. Remember query may be array(1,2,4,5,50.....)

Plz help if its possible. I tried but failed.

17 Jul
1 year ago

arctushar left a reply on Many To Many Working Oneway Only

@PovilasKorop , thnx, My User.php file code is as below

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
public function companies()
    {
        return $this->belongsToMany('App\Company');
    }
}

arctushar left a reply on Many To Many Working Oneway Only

for code as below

return Company::find(2)->users; 

giving result as below

[{"id":1,"name":"Ashraful Haque","email":"[email protected]","created_at":"2017-07-10 16:39:42","updated_at":"2017-07-10 16:39:42","pivot":{"company_id":1,"user_id":1}}]

arctushar left a reply on Many To Many Working Oneway Only

@SteamDiesel Showing blank, no error message

@jlrdw after adding ()->get(); giving below error

Call to undefined method Illuminate\Database\Query\Builder::companies()

Both u remember, one is working and inverse not working

thnx

16 Jul
1 year ago

arctushar started a new conversation Many To Many Working Oneway Only

return Company::find(2)->users; 

working good but

return User::find(1)->companies;

giving error, what is the problem ?

I have Authentication through make:auth command

This is extension part of https://laracasts.com/discuss/channels/eloquent/many-to-many-not-working-for-a-query

15 Jul
1 year ago

arctushar left a reply on Many To Many Not Working For A Query

return Company::find(2)->users; working good but return User::find(1)->companies; giving error, what is the problem ?