rafaeladi

Member Since 1 Month Ago

Experience Points
1,750
Total
Experience

3,250 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
4
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 1
1,750 XP
Apr
16
1 day ago
Activity icon

Started a new Conversation Query To Display The Intended Results

So currently ive been working on a project and this is one of the problem that i had. I want to have this data in my application and want the data to be viewed as a progressbar in my view. I want the data to be like this

| CaseName  | Duration | VerdictPass  | VerdictFail | Total | Config |
| --------- | -------- | ------------ | ----------- | ----- | ------ |
|  Case1  |  3654  |  2  |  1  |  3  | BaseConfig_GEN1,ColorGrip_Absent,InkType_MO70 |
|  Case2  |  23325 |  1  |  0  |  1  | BaseConfig_GEN1,ColorGrip_Present|
|  Case3  |  23325 |  1  |  1  |  2  | BaseConfig_GEN2 |

Currently i only have this and the data is not even correct, especially the total

| CaseName  | Duration | Total  | Config |
| --------- | -------- | ------ | ------ | ----- |
|  Case1  |  3654  |  2  | BaseConfig_GEN1,ColorGrip_Absent,InkType_MO70 |
|  Case2  |  23325 |  1  | BaseConfig_GEN1,ColorGrip_Present|
|  Case3  |  23325 |  2  | BaseConfig_GEN2 |

As of now, i havent figured out how to generate the VerdictPass and Fail in the same query.

My current query now

    public function testSuiteDetails($suite_id)
    {
        return DB::table('test_executions as e')
        ->select('e.case_id','b.version','c.name as case',DB::raw('SUM(distinct e.duration) as time'),
            DB::raw('group_concat(distinct bs.config order by bs.config asc SEPARATOR ";") as config'))
        ->selectRaw('COUNT(distinct e.verdict) as verdict')
        ->rightJoin('test_cases as c','e.case_id','=','c.id')
        ->rightJoin('test_suites as s','c.suite_id','=','s.id')
        ->rightJoin('build_versions as b','e.build_id','=','b.id')
        ->rightJoin('configuration as f','f.id','=','e.finalconfig_id')
        ->rightJoin('baseconfig_configuration as bc','bc.config_id','=','f.id')
        ->rightJoin('base_config as bs','bs.id','=','bc.baseconfig_id')
        ->groupBy('e.case_id','b.version','c.name')
        ->where('c.suite_id',$suite_id)
        ->get();

    }

Is there anyway to get this right? PLease note that the configuration retrieved from other table and concatenate inside this query

Apr
15
2 days ago
Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: PATCH.

Thank you for your help! It works like i wanted now

Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: PATCH.

is there something i did wrong here? The value that are supposed to be updated is deleted now, leaving me with a null value inside my DB

Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: PATCH.

@neilstee I implement your suggestion. but now i encounter anouther error

Call to undefined method Illuminate\Session\Store::patch()

Is this common error with this problem?

I also tried to remove this code to test is first

@if(Session::has('comment_updated'))
    <div class="alert alert-success" role="alert">
        {{Session::patch('comment_updated')}}
    </div>
@endif

and it works but it still doesnt update the value to the database

Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: PATCH.

@neilstee still no luck. and i dont think it matter in my case since the updating occurs in the same page, not with dedicated edit page

Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: PATCH.

@corvs just did that but still no luck.

<form method="POST" class="row g-1 {{$value->name}}" action="{{ route('update.case_details', ['id' => $value->exec_id]) }}">
            @csrf
             @method('PATCH')
            <div class="input-group form col-auto {{$value->name}}">
                <select class="form-select form-select-sm col-4" id="inputGroupSelect {{$value->name}}" aria-label="Status Selection">
                    <option selected>Choose...</option>
                    <option value="1">Being Analyzed</option>
                    <option value="2">Other Option</option>
                    <option value="3">Another Option</option>
                </select>
                <a href="/update_comment/{{$value->exec_id}}" class="btn btn-primary btn-sm">Change Status</a>
            </div>
        </form>
Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: PATCH.

I already tried to specifiy the action like @abhijeet9920 @neilstee has mentioned, but when i click the button it still give me the same error.

Activity icon

Started a new Conversation The GET Method Is Not Supported For This Route. Supported Methods: PATCH.

Im having a problem here, I want to update my data and already use patch method within the form itself but still giving me this error.

Route

Route::patch('/update_comment/{id}', [ResultsController::class,'update'])->name('update.case_details');

Blade

@if(Session::has('comment_updated'))
    <div class="alert alert-success" role="alert">
        {{Session::patch('comment_updated')}}
    </div>
@endif
<table class="table table-hover">
    <thead>
        <tr>
        <th scope="col">Test Name</th>
        <th scope="col">Details</th>
        <th scope="col">Duration</th>
        <th scope="col">Host</th>
        <th scope="col">Status</th>
        <th scope="col">Message</th>
        <th scope="col">Action</th>
        </tr>
    </thead>

<tbody>
    {{-- Foreach to display each results --}}

    @foreach ($test_data['details'] as $value)
    <tr>
         
    <th scope="row" class='col-auto align-middle'>{{$value->name}}</td>
    <td scope="row" class='col-3 align-middle'>{{$value->description}}</td>
    <td scope="row" class='col-auto align-middle'>{{CarbonInterval::seconds($value->duration)->cascade()->forHumans()}}</td>
    <td scope="row" class='col-auto align-middle'>{{$value->host}}</td>
    {{-- Color depends on the status --}}
    @if ($value->verdict)
    <td class='text-success fw-bold col-auto align-middle'>{{"Passed"}}</td>
    @else
    <td class='text-danger fw-bold col-auto align-middle'>{{"Failed"}}</td>   
    @endif
    <td scope='row' class="col-auto align-middle">{{$value->comment}}</td>
    <td class='align-middle'>
        <form method="POST" class="row g-1 {{$value->name}}" action="{{$value->id}}">
             @method('PATCH')
            <div class="input-group form col-auto {{$value->name}}">
                <select class="form-select form-select-sm col-4" id="inputGroupSelect {{$value->name}}" aria-label="Status Selection">
                    <option selected>Choose...</option>
                    <option value="1">Being Analyzed</option>
                    <option value="2">Other Option</option>
                    <option value="3">Another Option</option>
                </select>
                <a href="/update_comment/{{$value->exec_id}}" class="btn btn-primary btn-sm">Change Status</a>
            </div>
        </form>
    </td>
</tr>
     @endforeach
</tbody>
</table>

Controller

    public function update(Request $request)
    {
        //
        DB::table('test_executions')
            ->where('id',$request->id)->update([
                'name'=>'name',
                'details'=>'details',
                'duration'=>'duration',
                'host'=>'host',
                'verdict'=>'verdict',
                'description'=>$request->description
            ]);
        return back()->with("comment_updated","Status has been updated successfully");
    }

Can somebody help me find what is wrong here? Do i need to use another than patch?

Apr
08
1 week ago
Activity icon

Started a new Conversation Custom Chartisan/Laravel Charts Hooks On Controller

Is there any way to have a custom hooks inside a controller since on their documentation its not quite clear on how to do so. The only thing that works for me now it to put the styling for the chart inside my view page and it gets very messy if i have multiple chart inside my view page.

<script>

    const chart = new Chartisan({
    el: '#chart',
    url: '@chart('sample_chart')',
    hooks: new ChartisanHooks()
      .colors(['#ECC94B', '#4299E1'])
      .legend({ bottom: 0 })
      .title({
        textAlign: 'center',
        left: '50%',
        text: 'This is a sample chart using chartisan!',
      })
      .tooltip({
        trigger:'axis',
      })
      .axis({
        yAxis:{
           type:'value',
           yAxisIndex:1,
           name:"Health",
           position:'left',
           axisLine: {
                show: true,
           },
            axisLabel:{
            formatter: "{value} %",
            min:0,
            max:100,
          },
        },
        yAxis:{
          type:'value',
          yAxisIndex:2,
          name:'Passed tests',
          position:'left',
          axisLine: {
                show: true,
           },
          axisLabel:{
            min:0,
            max:200,
          },
        }
      })
      
      .datasets([
        {
          type: 'line',
          smooth: false,
          lineStyle: { width: 2 },
          symbolSize: 7,
          animationEasing: 'cubicInOut',
          areaStyle: {
                opacity: 0.8,
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: 'rgba(128, 255, 165)'
                }, {
                    offset: 1,
                    color: 'rgba(1, 191, 236)'
                }])
            }
        },
        'bar',
      ]),
})

    </script>

Is there any way to put all of this and still able to render the chart with just calling some function?

Apr
06
1 week ago
Activity icon

Replied to Laravel Charts With Query Builder

@fylzero So i just figured out how to view the error

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

And i think this comes from this code

 $total_test=DB::table('test_executions as e')

                    ->where('e.case_id','1')

                    ->toArray();

i made that mistake and now replaced the 'toArray()' with 'get()' but the intended data is still not visible

Activity icon

Replied to Laravel Charts With Query Builder

@fylzero if i did the whole thing with static data, it gives me the results that i want. I think part of the problem here is how the data is being structured when passed to the laravel charts.

I dont have a stack trace since the view can be rendered but only the charts doesnt, so the error message that i had only from the error that are displayed on the chart container

Apr
02
2 weeks ago
Activity icon

Replied to Laravel Charts With Query Builder

@fylzero I tried to gather the data from my db but everytime i genereate the chart it always show error

UNEXPECTED TOKEN < IN JSON AT POSITION 0

And this is the code that i had for now,

public function handler(Request $request): Chartisan
    {  
	$label = DB::table('test_suite')->pluck('name');
    $data=DB::table('test_execution')->pluck('duration');	

       return Chartisan::build()
        ->labels($label->toArray())
        ->dataset('Number of tests', [1, 2, 8,3,6,1, 2, 8,3,6])
        ->dataset('Errors made', $data->toArray());
        
    }
Apr
01
2 weeks ago
Activity icon

Replied to Multiple Function For The Same Route

@martinbean i knew about this but i had different data to passed on. So what am i trying to do here basically is to 'fetch' the data that is on the next page when you click the test case as im already shown on the picture to the page before it. Currently i cant find a way to do it since on that page, the parameter is the case id and on the page that has the progress bar the parameter is suite id on the URI. Im going to try to make another controller for now to see if its possible to do so.

Mar
31
2 weeks ago
Activity icon

Replied to Multiple Function For The Same Route

the reason on why it needs to be in the same URI is due to how its being presented. The Progressbar will appear on a table that can be viewed like this

https://imgur.com/xE7gMUD

And the progress bar should present the right data that is corresponding to it. So for each test case it would have a different amount of data on its progress bar. Maybe the other way to do it is by making another controller? As it for now, it shows the same amount of number due to the conditions i put in on my function which takes a suite id as a parameter. I hope this explains the problem

Activity icon

Replied to Multiple Function For The Same Route

So currently i have this setup in place as my controller for now. The problem is i want to pass the information but it has a different parameter to pass on in order to retrieve the correct results

  public function showSuiteDetails($suite_id)
    {
        $data=
        [
            'case'=>$this->Results->testSuiteDetails($suite_id),
            'pass'=>$this->Results->countPassed($suite_id)->count(),
            'fail'=>$this->Results->countFailed($suite_id)->count(),
            'total'=>$this->Results->countTotal($suite_id)->count(),
        ];
        dump($data);
  
        return view ('suite_details',['test_data'=>$data]);
    }
    public function showProgress($case_id)
    {
        $progress=
        [          
            'pass'=>$this->Results->countPassed($case_id)->count(),
            'fail'=>$this->Results->countFailed($case_id)->count(),
            'total'=>$this->Results->countTotal($case_id)->count(),
        ];
        dump($progress);
  
        return view ('suite_details',['test_progress'=>$progress]);
    }

How do i create the branching, do i create a new one?

Activity icon

Replied to Multiple Function For The Same Route

is there any alternative for this problem?

Activity icon

Started a new Conversation Multiple Function For The Same Route

Is it possible to have a multiple function for a single route? The function also contains a different parameter in it.

Route::get('/suite_details/{suite_id}', [ResultsController::class,'showProgress'])->name('suite_details');

Route::get('/suite_details/{suite_id}', [ResultsController::class,'showSuiteDetails'])->name('suite_details');
Mar
30
2 weeks ago
Activity icon

Replied to Seconds To Humantime

@tippin yes i just got some help with this issue on my other post and it is solved now

Activity icon

Replied to Using Carbon To Convert Second To Time

@michaloravec I already add it on my config file like this

        'Carbon' => Illuminate\Support\Carbon::class,
        'CarbonInterval' => Illuminate\Support\CarbonInterval::class,

But it still give me an error

Class "Illuminate\Support\CarbonInterval" not found
Activity icon

Replied to Using Carbon To Convert Second To Time

i tried the first one but it always said that the CarbonInterval is not found. I already put it on my controller but idk how to declare it on blade.

Activity icon

Started a new Conversation Using Carbon To Convert Second To Time

So i want to convert my duration data from database to be viewed on my view page. I tried made some function on my controller that should convert it.

    public function humanTime()
    {
        $seconds = DB::table('test_executions as e')
                        ->select('e.duration');
        $time = CarbonInterval::seconds($seconds)->cascade()->forHumans();
        dd($time);
	}

And on my view page i want to show it and currently i have this.

    @foreach ($test_data['details'] as $value)
    <tr>      
    <th scope="row" class='col-auto align-middle'>{{$value->name}}</td>
    <td scope="row" class='col-3 align-middle'>{{$value->description}}</td>
    <td scope="row" class='col-auto align-middle'>{{humanTime($value->duration)}}</td>
	</tr>
	@endforeach

But currently i only get an error that state:

'Call to undefined function humanTime()' and when i tried to test the function also shows that the collection cannot be converted to int.

Mar
29
2 weeks ago
Activity icon

Started a new Conversation Laravel Charts With Query Builder

Is there any documentation on how to use laravel charts with data from DB but the one with query builder not eloquent? I cant seem to find it anywhere and how the data being passed is kind of different so i need some help in this

Mar
24
3 weeks ago
Activity icon

Started a new Conversation Adding Data To Charts Using Query Builder

So i want to make a chart using laravel charts and i want to use my own data from database. As far as i can tell there is no example on how to do it with query builder, only eloquent.

So i want to pass this information, the labels is going to be get from 'test_suites' table and from 'name' column. the data is going to be retrieved from 'test_cases' table in which already connected with id. and i want to count how many cases each suite has. I executed this and i get an error where it says it cannot count a string where it supposed to be a collection. Do i need to use join to get the information on the values or what?

        $total_test = DB::table('test_suites')->get();
        $labels = [];
        $count = [];
        
        
        $values = DB::table('test_cases')->get();
        foreach ($values as $item) {
                array_push($count,$item->name->count());
            }
        return Chartisan::build()
            ->labels($labels)
            ->dataset('Sample', $count); 
Mar
22
3 weeks ago
Activity icon

Replied to Easy To Use Chart

already tried but the chart wouldnt render, there is no error on my developer view also

Activity icon

Replied to Easy To Use Chart

@neilstee i tried using it but it never show me the chart, even with the sample charts

Activity icon

Replied to Easy To Use Chart

is that the same as chartisan?

Activity icon

Started a new Conversation Easy To Use Chart

What chart library to use with laravel, i just need some basic chart like bar,pie and line chart. I see from chartJs, chartisan and highchart. Is there any perceivable difference between these libraries?

Mar
19
4 weeks ago
Activity icon

Started a new Conversation Showing The Correct Data From The Selected Id

Hi, so currently iam unable to view the correct data on my page especially on the accordion.

This is what it looks like now Image of current situation

https://imgur.com/a/SvWnAwS

And this is my intention Image of prefered

https://imgur.com/a/37WNkTK

This is how i put my view page now

@foreach ($test_suite['suite'] as $value)
<div class="col">
<div class="card overflow-auto">
<h5 class="card-header bg-danger text-white">{{$value->name}}</h5>                    
<div class="card-body">
<h5 class="card-title">Failed Tests</h5>
{{-- Test Case Show --}}
@foreach ($case_data['case'] as $data)       
<div class="accordion accordion-flush" id="accordionFlush{{$data->case}}">
<div class="accordion-item">
<h2 class="accordion-header" id="flush-heading_card{{$data->case}}">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapse{{$data->case}}" aria-expanded="false" aria-controls="flush-collapse{{$data->case}}">
{{$data->case}}
</button>
</h2>    
<div id="flush-collapse{{$data->case}}" class="accordion-collapse collapse" aria-labelledby="flush-heading{{$data->case}}" data-bs-parent="#accordionFlush{{$data->case}}">
<div class="accordion-body">
{{-- test Execution show --}}
@foreach ($case_data['case'] as $execution)
<div class="list-group list-group-flush">
<a href="{{ route('case_details', ['case_id' => $execution->case_id]) }}" class="list-group-item list-group-item-action">{{$execution->name}}</a>
</div>                         
@endforeach                        
</div>
</div>
</div>                        
</div>      

@endforeach

And this is how i configured the data that passed to the view (Controller)

    public function suite()
    {
        $data=[
             'suite'=>$this->Results->suiteDataOnly(),
         ];
         dump($data);
        $cases_data=[
             'case'=>$this->Results->testDetails(),
         ];
         dump($cases_data);

        return view ('index',['test_suite'=>$data],['case_data'=>$cases_data]);

    }

And the data that shown

array:1 [▼
  "case" => Illuminate\Support\Collection {#297 ▼
    #items: array:5 [▼
      0 => {#299 ▼
        +"host": "PC_1"
        +"id": 4
        +"name": "TC_SCOOLSCEUFAN16_TACHO"
        +"verdict": 1
        +"description": null
        +"comment": null
        +"duration": 3654
        +"finalconfig_id": 2
        +"case_id": 5
        +"build_id": 4
        +"host_id": 1
        +"updated_at": "2021-03-19 09:11:54"
        +"create_at": "2021-03-19 09:11:54"
        +"version": "0.1.48.16"
        +"branch": "Nightly"
        +"hash": "34"
        +"case": "PhfFans"
        +"suite_id": 3
      }
      1 => {#289 ▶}
      2 => {#307 ▶}
      3 => {#311 ▶}
      4 => {#308 ▶}
    ]
  }
]

So the end goal is to make each accordion item(test case) show the right card header(test suite). Can i just filter it by using the id or something? Thanks

Activity icon

Replied to Showing Each Test Suite Details Based On The Id

thank you, it is so what i was intended for

Mar
18
4 weeks ago
Activity icon

Replied to Showing Each Test Suite Details Based On The Id

@a4ashraf this is the output if i type the caseid manually in the url

array:1 [▼
  "case" => Illuminate\Support\Collection {#291 ▼
    #items: array:1 [▼
      0 => {#300 ▼
        +"host": "PC_3"
        +"id": 3
        +"name": "capUnitHappyFlow_UpSwitch"
        +"verdict": 0
        +"comment": null
        +"duration": 3654
        +"finalconfig_id": 2
        +"case_id": 4
        +"build_id": 3
        +"host_id": 3
        +"updated_at": "2021-03-18 16:05:42"
        +"create_at": "2021-03-18 16:04:51"
        +"version": "0.1.48.2"
        +"branch": "Release"
        +"hash": "35"
        +"case": "PfConditioning2"
      }
    ]
  }
]

It already showed the right data, now its just how i am connecting this together. I tried to refer to the correct id on the button but still showing me empty collection. and weirdly the url changed automatically to this

http://127.0.0.1:8000/overview_details/%7Bid%7D

eventhough i put it like this on my code

<div class="d-grid gap-2">
                <a href="/overview_details/{id}" class="btn btn-primary mt-2 ">Test Details</a>
                </div>

do you know whats wrong here?

Activity icon

Replied to Showing Each Test Suite Details Based On The Id

@a4ashraf ok i will try but if the data showed up, how do i specify which one to view? can it be done just using this or do i need other things? tbh im still learning eloquent but i am more comfortable using query builder just for now

Activity icon

Replied to Showing Each Test Suite Details Based On The Id

the data i gather should look like this if i dont apply the where condition

array:1 [▼
  "case" => Illuminate\Support\Collection {#291 ▼
    #items: array:1 [▼
      0 => {#300 ▼
        +"host": "PC_2"
        +"id": 4
        +"name": "capUnitHappyFlow_Up"
        +"verdict": 1
        +"comment": null
        +"duration": 6510
        +"finalconfig_id": 1
        +"case_id": 3
        +"build_id": 4
        +"host_id": 2
        +"updated_at": "2021-03-18 12:28:26"
        +"create_at": "2021-03-18 12:28:26"
        +"version": "0.1.48.16"
        +"branch": "Nightly"
        +"hash": "34"
        +"case": "PfConditioning"
      }
    ]
  }
]
Activity icon

Replied to Showing Each Test Suite Details Based On The Id

that's the thing, i tried to use without joining tables and it works fine, when i join the table but show all the information with no filtering on a specific id, it also works fine. it is when i join tables and try to get the details from it where it gets confusing because it return and empty collection

Activity icon

Started a new Conversation Showing Each Test Suite Details Based On The Id

Hi, i have been working for this project for a couple of weeks now but i cant seem to find the solution for it. So basically i want to view the details of each 'test_suite' data that i have in my DB but it always return a blank collection.

So basically this is my model

    public function testDetails($case_id)
    {
        return DB::table('test_executions as e')
                    ->select('h.name as host','e.*','b.*','c.name as case')
                    ->rightJoin('test_cases as c','e.case_id','=','c.id')
                    ->rightJoin('build_versions as b','e.build_id','=','b.id')
                    ->rightJoin('test_hosts as h','e.host_id','=','h.id')
                    ->where('c.case_id',$case_id)
                    ->get();
    }

This is my controller for it

    public function details($case_id)
    {
        $data=[
            'case'=>$this->Results->testDetails($case_id),
        ];
        dump($data);

        return view ('overview_details',['test_data'=>$data]);
    }

The route to point out to the correct id

Route::get('/overview_details/{case_id}', [ResultsController::class,'details']);

And finally this is my view page

@foreach ($test_data['case'] as $value)
<tr>
<th scope="row" class='col-3'><a href="/details">{{$value->case}}</a></th>
<td class='col-4'>{{$value->branch}}</td>
<td class='col-2'>{{$value->version}}</td>
<tr>
@endforeach

And the current results is an empty collection like this

array:1 [▼
  "case" => Illuminate\Support\Collection {#291 ▼
    #items: []
  }
]

Any help is appreciated. Thanks!

Mar
17
1 month ago
Activity icon

Replied to Property [case] Does Not Exist On This Collection Instance.

thank you it works a charm! np i will rename it later

Activity icon

Started a new Conversation Property [case] Does Not Exist On This Collection Instance.

Hi, i am facing some problems when trying to parse the data from database to my view. within the debugging i noticed something weird, now my data is combined again in an array and i dont know how to parse the data to my view page.

This is the debugging data

array:1 [▼
  "suite" => Illuminate\Support\Collection {#289 ▼
    #items: array:15 [▼
      0 => {#295 ▼
        +"suite": "Maintenance"
        +"case": "PfMaintenance"
      }
      1 => {#294 ▶}
      2 => {#297 ▶}
      3 => {#296 ▶}
      4 => {#292 ▶}
      5 => {#298 ▶}
      6 => {#291 ▶}
      7 => {#299 ▶}
      8 => {#300 ▶}
      9 => {#301 ▶}
      10 => {#302 ▶}
      11 => {#303 ▶}
      12 => {#304 ▶}
      13 => {#305 ▶}
      14 => {#306 ▶}
    ]
  }
]

This is my model

    public function suiteData()
    {
        return DB::table('test_executions as e')
                    ->select('s.name as suite','c.name as case')
                    ->rightJoin('test_cases as c','e.case_id','=','c.id')
                    ->rightJoin('test_suites as s','c.suite_id','=','s.id')
                    ->get();
    }

and this is the controller

         $data=[
             'suite'=>$this->Results->suiteData(),
         ];
         //dd($data);

        return view ('results',['test_data'=>$data]);

and this is the view

                @foreach ($test_data as $value)
                   <div class="col">
                  <div class="card overflow-auto">
                    <h5 class="card-header bg-danger text-white">{{$value->suite}}</h5>                    
                    <div class="card-body">
				@endforeach

As you can see, i want to retrieve the 'suite' from my data as a replacement of value, but it keeps getting the error. Any help is useful, thank you

Mar
16
1 month ago
Activity icon

Replied to Seconds To Humantime

i think im going to give it a parameter, but it still hasnt solve the first problem, about the collection, do you have any suggestion for it? or maybe how you would tackle this problem. Thanks!

Activity icon

Replied to Seconds To Humantime

do you have some recommendation on how to do it or some documentation that i can look up to?

Activity icon

Replied to Seconds To Humantime

So i make a function inside my controller

    public function humanTime()
    {
        $durations=DB::table("test_executions")->pluck('duration');
        $time = CarbonInterval::seconds($durations)->cascade()->forHumans();
    }

And i want to grab that data to be viewed on my loop since it is a collection and this is inside my view

    @foreach ($test_data as $value)
    <tr>           
        <th scope="row" class='col-4'>{{$value->name}}</td>
        <td scope="row" class='col-3'>{{humanTime($time)}}</td>
	<tr>
@endforeach
Activity icon

Replied to Seconds To Humantime

i already tried it but it gives me this error

Object of class Illuminate\Support\Collection could not be converted to int

I know the problem is but i dont know how to overcome this.

Activity icon

Replied to Seconds To Humantime

Do i make a separate controller for this or is it ok just to have another function on my controller that refers to the function?

Activity icon

Started a new Conversation Seconds To Humantime

Are there any already existing function to convert seconds to human time? For example, i have a data which store a results of 6700 seconds, but on my view page i want to view it as 1 Hour, 51 Minutes and 39 Seconds.

Mar
15
1 month ago
Activity icon

Replied to Retrieving Data From Several Tables

so for example i have a test execution and configuration, it has many to many relationships am i correct if i configure it like this?

This one is one testexecution model

public function config(): BelongsToMany
     {
         return $this->belongsToMany(configuration::class);
     }

and this one is on configuration model

public function executions(): BelongsToMany
    {
        return $this->belongsToMany(testExecution::class);
    }

But where do i stated the protected table then? becuase i cant have 2 protected tables

Activity icon

Replied to Retrieving Data From Several Tables

but what if i dont use the migration aswell? thats why i have to state protected tables on each models

Activity icon

Replied to Retrieving Data From Several Tables

Is by having a separate model for the intersection table affect the way to retrieve the data? Becuase i dont follow the laravel naming conventions so i figure out to have a different model for it and on that model i have 2 HasMany connections. this is different then the one on the video where he used BelongsToMany on both original table

Mar
12
1 month ago
Activity icon

Started a new Conversation Retrieving Data From Several Tables

I have a problem where i want to retrieve the data from other tables, usually i only use SQL and in there i can done it without any problem using a JOIN function, but in laravel, how do i do that using a model? do i need to make a separate model for every table and somehow call them in one function? Is there any documentation to help me through this?

Thank you

Mar
11
1 month ago
Activity icon

Replied to Table Relationship Migrations

Schema::create('test_cases', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('suite_id')
                    ->references('id')
                    ->on('test_suites')->onDelete('cascade');
			$table->index('suite_id');
            $table->string('name');

            
        });

So it should look like that? I already saw the docs but im still confused with this

Activity icon

Replied to Table Relationship Migrations

ok it works but what if i want to make the suite_id also an index? becuase right now i still need to manually assign that column as an index inside the database

Activity icon

Replied to Table Relationship Migrations

i did it this way`

This is my test case table

Schema::create('test_cases', function (Blueprint $table) {
            $table->id();
            $table->integer('suite_id')
                    ->references('id')
                    ->on('test_suites')->onDelete('cascade');
            $table->string('name');

            
        });

and this is my test suite table

Schema::create('test_suites', function (Blueprint $table) {
            $table->id();
            $table->string('name');
        });

I know the suite_id on the test case table is not the same type but i cant have 2 id at the same table right?