Aronaman

Aronaman

Member Since 1 Year Ago

Experience Points
5,400
Total
Experience

4,600 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
5
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.

Level 2
5,400 XP
Apr
01
2 days ago
Activity icon

Started a new Conversation Load Chart

Controller

 $apiDay = url('admin/ajax-day-statics');        
        $apiMonth = url('admin/ajax-month-statics');
        $apiYear = url('admin/ajax-year-statics');

 $toDayStatics = new GoogleAnalytics;
         if(route('ajax.day.statics')){
             $toDayStatics->labels(['Today'])->load($apiDay);
         }elseif(route('ajax.month.statics')){
             $toDayStatics->labels(['This Month'])->load($apiMonth);
         }elseif(route('ajax.year.statics')){
            $toDayStatics->labels(['This Year'])->load($apiYear);
         }

// google Analytics Daily
    public function ajaxDayStatics(Request $request)
    {
        $day = Analytics::performQuery(Period::days(1),
        'ga:',
        [
            'metrics' => 'ga:users,ga:newUsers,ga:sessions,ga:sessionsPerUser,ga:pageviews,ga:pageviewsPerSession,ga:avgSessionDuration,ga:bounceRate',

        ]);

        $todayUsersVisits=$day->totalsForAllResults['ga:users'];
        $todaySessisons=$day->totalsForAllResults['ga:sessions'];

    // dd($thisMonth->totalsForAllResults['ga:bounceRate']);
   

         $toDayStatics = new GoogleAnalytics;
         // $toDayStatics->labels(['Today']);
         $toDayStatics->dataset('Visits', 'bar',[$todayUsersVisits])->color('#7cbd1e')->backgroundcolor("#7cbd1e");


          return $toDayStatics->apiDay();

    }

Html

 <div class="btn-group btn-group-toggle float-right mr-3" data-toggle="buttons">
     <label class="btn btn-outline-secondary active">
       <input id="day" type="radio" name="options" autocomplete="off" checked=""> Day
    </label>
    <label class="btn btn-outline-secondary ">
       <input id="month" type="radio" name="options" autocomplete="off" > Month
    </label>
    <label class="btn btn-outline-secondary">
      <input id="year" type="radio" name="options" autocomplete="off"> Year
    </label>
     </div>

<div class="c-chart-wrapper" style="height:300px;margin-top:40px;">

    {!! $toDayStatics->container() !!}
 </div>

Ajax

@if($toDayStatics)
       {!! $toDayStatics->script() !!}
 @endif


     <script type="text/javascript">
        
        $("#day").change(function(){
          var original_apiDay_url = {{ $toDayStatics->id }}_api_url;
            
            {{ $toDayStatics->id }}_refresh(original_apiDay_url );
        });

        $("#month").change(function(){
          var original_apiMonth_url = {{ route('ajax.month.statics') }};
            
            {{ $toDayStatics->id }}_refresh(original_apiMonth_url );
        });
        $("#year").change(function(){
          var original_apiYear_url = {{ route('ajax.year.statics') }};
            
            {{ $toDayStatics->id }}_refresh(original_apiYear_url);
        });
    </script>

i am using ConsoleTvs Charts package i am try to load chart based on month, year and day. how can i do this??

i am new to this i dont know how to load ajax in console tvs chart pakage

any help thanks

Mar
30
4 days ago
Activity icon

Replied to Special Character In Query Builder

i try 3 slash \ \ \working @tykus thanks

Activity icon

Replied to Special Character In Query Builder

@tykus it is not working, same result

Activity icon

Started a new Conversation Special Character In Query Builder

in my database i have 10 bookings row from 10 i have 8 Bookable_type="App\Room", but i get zero, i think this is b/c the special character "/" . how can i solve this problem

         DB::raw("SUM(CASE WHEN bookings.bookable_type ='App\Room' THEN 1 ELSE 0 END) AS countBookedRoomMontly"),

i also try count , but give all not what i nedd

            DB::raw("COUNT(CASE WHEN bookings.bookable_type ='App\Room' THEN 1 ELSE 0 END) AS countBookedRoomMontly"),

Any Help

Mar
25
1 week ago
Activity icon

Started a new Conversation Invoice No Increment

my problem #1expNum +1 remove all zero and make 2 instade of 0002

	   $now=Carbon::now();
            $firstDateYear=$now->startOfYear();

            $record = Invoice::latest()->first();
            if(!is_null($record)){
                $expNum = explode('-', $record->recp_no);
                    //check first day in a year
                if ($firstDateYear->isToday() ){
                    $nextInvoiceNumber = date('Y').'-0001';
                } else {
                    //increase 1 with last invoice number
                    $nextInvoiceNumber = $expNum[0].'-'. $expNum[1]+1;

//error  dd($nextInvoiceNumber)  "A non well formed numeric value encountered"
                }

            }else{
            $nextInvoiceNumber =date('Y').'-0000';
            }

any one please better way to do this !!!

Mar
22
1 week ago
Activity icon

Replied to Eloquent

any help please!

Activity icon

Started a new Conversation Eloquent

this working in db query building I want work in eloquent

DB::table('bookings')
->select([
 DB::raw('(select pay AS payment)- (select commision_i_get AS commission) as net'),
])

Eloquent

Booking::where('organization_id',$orgId)
		->whereRaw('pay -commision_i_get ')// I don't know how to subtract the value and assign to net variable 

Mar
18
2 weeks ago
Activity icon

Started a new Conversation DB Query Relationship

query

Activity icon

Replied to Count And Sum Db Query

@rodrigo.pedra one more thing we select db builder org_id , how can I access the relationship and get org name from org tables

booking and org has 1 to many relationship

->select([ 'org.org_name', 
...

it is possible or is there any method ??

Mar
17
2 weeks ago
Activity icon

Replied to Count And Sum Db Query

@rodrigo.pedra thanks very much !! the total commission add localbook and selfbook every date ?

any recommendation for reading Db query tutorial pdf or site

Activity icon

Replied to Count And Sum Db Query

@rodrigo.pedra

Do you still want to group it? No sir

i want

-org_id, 
-date,
- nobooking by localbook,
- total commision by localbooking,
- noboking by selfBook,
- total commison by selfbook and 
*totalBook(sum both total).

yes i love if you did for me !

Activity icon

Replied to Count And Sum Db Query

@rodrigo.pedra

thanks very much it works, i want to not repeat org_id

instade of this

0 => {#789 ▼
    +"org_id": 1
    +"payment_gateway": "LocalBook"
    +"day": "2020-03-16"
    +"bookings_per_day": 5
    +"comission_per_day": 560.0
  }
  1 => {#794 ▼
    +"org_id": 1
    +"payment_gateway": "selfBook"
    +"day": "2020-03-16"
    +"bookings_per_day": 1
    +"comission_per_day": 120.0
  }

i want this

0 => {#789 ▼
    +"org_id": 1
    +"payment_gateway": "LocalBook"
    +"day": "2020-03-16"
    +"bookings_localBook_per_day": 5
    +"comission_localbook_per_day": 560.0

    +"payment_gateway": "selfBook"
    +"bookings_selfbook_per_day": 1
    +"comission_selfbook_per_day": 120.0
  }
Activity icon

Started a new Conversation Count And Sum Db Query

Booking Table

id |org_id | local_id| check_in| Checkout| commision| Pay| Payment_gateway|book_status_id| create_at| update_at|

controller

        $bookedStatus_id=BookStatus::where('name','Booked')->first()->id;
    	$booking=DB::table('bookings')->where('book_status_id',$bookedStatus_id)
			->where('pay','>',0)
								  
			// ->selectRaw("*,SUM(commison) as sum")
			->get()
			->groupBy(['org_id','payment_gateway',function($q){
			return Carbon::parse($q->created_at)->format('d-M-yy');
			}])				  
			->toArray();

my question #1 how to count each each day booking #2 sum each day commison Column

Activity icon

Replied to DB Query Grouping Sum Each

@bobbybouwmann

I am new to db builder ,,,what i am wanting is grouping bookings table by the" org_id", "payment_gateway" and "update_at". and on each date count all array and sum commissions column value for every date.

i hope now is clear. can you give me any code example?

Activity icon

Replied to DB Query Grouping Sum Each

@bobbybouwmann did you understood my problem ??? no, i dont have raw query untile now

Activity icon

Started a new Conversation DB Query Grouping Sum Each

i want to achieve

*OrgName #1
        - PayPal
            - 2020-01-01 
                    [ 
                    array_booking
                    ]
                - Count Total (LBP)
                - Total Sum(LBC) commison
            - 2020-01-02
                    [ 
                    array_booking
                    ]
                - Count Total (LBP)
                - Total Sum(LBC) commison
            - 2020-01-04
                .
                .

        - credit Card
            - 2020-01-02
                    [ 
                    array_booking
                    ]
                - Count Total (SBP)
                - Total Sum(SBC) commison


    *OrgName #2

bookings table

id |org_id | local_id| check_in| Checkout| commision| Pay| Payment_gateway| create_at| update_at|

my query i just try

$bookedStatus_id=BookStatus::where('name','Booked')->first()->id;
 $booking=Booking::with('bookable')->where('book_status_id',$bookedStatus_id)
    				->where('pay','>',0)
    				->selectRaw("DATE_FORMAT(Update_date, '%Y %m %e') date")
    				->get()
    				->groupBy(['organization_id','payment_gateway','date'])
    				->toArray();

// db query also try 
$booking=DB::table('bookings')->where('book_status_id',$bookedStatus_id)
    			->where('pay','>',0)
    			 ->selectRaw("DATE_FORMAT(check_in, '%Y %m %e') date")
    			->selectRaw("*,SUM(commison) as sum")					  
    			->get()
    			 ->groupBy(['organization_id','payment_gateway','date'])
    									  
    			 ->toArray();

not working for me any help, please

Mar
15
2 weeks ago
Activity icon

Replied to Update Not Working

@sinnbeck yea ..i miss that .tnx

Mar
14
2 weeks ago
Activity icon

Started a new Conversation Update Not Working

Hello guys

  public function localUpdateSearch(Request $request)
     { 

     	if($request->ajax())
	     {
     		$booking=Booking::where('id',$id)->get();

	     		// $request['quantity_no']=[];
	     		// $request['quantity']=0;	
	     		$test=[
	     			'quantity_no'=>[],
	     			'quantity'=>0
	     		];


	     	$bookingUpdate=$booking->update($test);

            $booking->individualRooms()->sync($request->input('quantity_no', []));
…

Method Illuminate\Database\Eloquent\Collection::update does not exist. This is b/c the controller is not a resources controller?? Until know it was working fine, I use it many times in different controllers. What is the reason

Mar
10
3 weeks ago
Activity icon

Replied to Check Box Pass Value

if i checked and unchecked ... please edit the html suitable for ajax .

my html working for php code ..not for ajax i should pass id or class.

itry this ,but not working

var test= $('#send_text').val()

the problem is always the value is 1. i want to change the value based on the checked (1) or not checked (0)

Activity icon

Started a new Conversation Check Box Pass Value

html

<strong>Send Text:</strong>

       <input name="send_text" type="hidden" value="0">
       <input value="1"  type="checkbox" id="send_text" name="send_text" checked>

ajax

var sendText = $('input[name="send_text"]').prop('checked');

the probelem pass false always

Mar
09
3 weeks ago
Activity icon

Started a new Conversation Ajax Call Response All Response Has Been Called

blade table


@foreach ($expireds as $key => $expired){

    <tr>
      <td>{{ ++$i }}</td>
      <td>
      <a  class="expired-class" data-toggle="modal" data-target="#eachExpired" data-id="{{$expired->id}}" data-url="{{ route('local.expired.each', $expired->id) }}">
        {{$expired->localreservation->full_name}}
      </a>
     </td>


      <td>{{$expired->updated_at}}</td>

      <td>{{$expired->localreservation->email}}</td>
      <td>{{$expired->no_room}}</td>
      <td>{{$expired->no_conference}}</td>
      <td>{{$expired->localreservation->phone_no}}</td>
      <td>{{$expired->localreservation->localUserBankAccount}}</td>
      <td>{{$expired->group_pay}}</td>
      <td>{{$expired->group_unpay}}</td>
      
      <td>{{$expired->group_fund}}</td>
      

    </tr>
     @endforeach

modal inside the blade

 

modal
-------------------

<div class="modal fade" id="eachExpired" tabindex="-1" role="dialog" aria-labelledby="roomLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="roomLabel">Each Booking</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">

<table id="each_bookind" class="display table-bordered" style="width:100%">
  
  <thead>

   <tr>

     <th>No</th>

     <th>Type</th>

      <th>Name</th>

     <th>quantity</th>

     <th>start Date</th>

     <th>end Date</th>

      <th>Payed</th>

     <th>unpayed</th>

     <th>fund</th>


   </tr>
</thead>

  <tbody id="tBody"></tbody>
</table>

ajax

  $(document).ready(function () {
    
    $('.expired-class').click(function () {
      var me=$(this);
      var url = me.attr('data-url');
      var id = me.attr('data-id');
      if ( me.data('requestRunning') ) {
              return;
          }
       me.data('requestRunning', true); 

      $.ajax({
         type:"GET",

         url:url,
         dataType:'json',
         data:{
          id:id
         },
        
         success:function(res){ 
          console.log(res);
          if($.isEmptyObject(res.error)){
          // data_global = res; 
          var rowCount=$("#each_bookind tbody tr").length+1;
          var bodyData = '';
          // var i=1;
          $.each(res,function(index,row){ 
              
             console.log(row); 

                  bodyData+='<tr id="row_'+rowCount+'" >'
          bodyData+='<td >'+ rowCount +"</td><td>"+row.bookable_type+"</td><td>"+row.bookable.slug+"</td><td>"+row.quantity_no+"</td><td>"+row.check_in+"</td><td>"+row.check_out+"</td><td>"+row.pay+"</td><td>"+row.unpay+"</td><td>"+row.fund+"</td>";
              
              bodyData+="</tr>";
              
          
          });

          $("#tBody").append(bodyData);

              $("#msg").show();
              $("#msg").html("Success Add");
              $("#msg").fadeOut(4000);

      } 

       

      },// end of res
      complete: function() {
          me.data('requestRunning', false);
      }
  });// end of ajax 
         
  });
});

response 1st

{id: 49, bookable_type: "App\Room", bookable_id: 1, local_reservation_id: 131, name: null, …}

2nd

{id: 50, bookable_type: "App\Room", bookable_id: 2, local_reservation_id: 131, name: null, …}

on the second response show both the first and second

the problem is my first click response alright when I click again the response contains the first response and adds another response on the first response. any help, please.

Mar
06
4 weeks ago
Activity icon

Replied to Json Column

@sinnbeck

trough this error .sir "Call to undefined method App\GroupBooking::reject()".

i use this method, but array start from 1

$bookingIds=$findGroup->booking_id;

if (($key = array_search($id, $bookingIds)) !== false) {
    unset($bookingIds[$key]);
}

Activity icon

Replied to Json Column

@sinnbeck i really appricate

when i try it through error $removeId not define. then

 $test=$findGroup->reject(function($item) use($removeId) {
          return collect($item->booking_id)->contains($removeId);
      })->pluck('booking_id');

through other error "could not be converted to int"..

Activity icon

Replied to Json Column

[63, 64, 65]

Activity icon

Replied to Json Column

@sinnbeck

 $target=Booking::findOrFail($id);
       
      $findGroup=GroupBooking::whereJsonContains('booking_id', $target->id)->get();
      $removeId=collect($id);
      $test=$findGroup->whereNotIn('booking_id', $removeId)->pluck('booking_id');// this not working b/c booking_id is json column 
Activity icon

Started a new Conversation Json Column

hello guys

i have JSON column and value like ["1","2","3"] and what i want is using query remove "1" then expected new value is look like this ["2","3"]. how can i do this?

any help, thanks

Feb
21
1 month ago
Activity icon

Replied to Collection Pass Blade

@talinon yea..but pluck and sum and implode method is not working in blade. I try to use it in view composer, but it's for static page url....

Feb
20
1 month ago
Activity icon

Replied to Collection Pass Blade

   return view('Local.checkBalance.index', compact('groups','payed','funded'))
                         ->with('i');

i pass it my question is how can do query in blade.

it is possible in blade like this

@foreach ($groups as $key => $group)

$BookingIds=$group->pluck('id');
$first=$group->first();

b/c pluck and where are collection on controller not in blade ?/ there is any way??

Activity icon

Started a new Conversation Collection Pass Blade

Hyy guys Any trick or tip This my code

      $lists=Booking::with('localreservation')->where('approve_date',null)
                                       ->where('booked_by',$auth )
                                       ->whereDate('updated_at',$toDay)
                                       
                                       ->get();
      $groups=$lists->groupBy('validation_code')->toArray();
 dd($groups

output

array:3 [▼
  "vN9-2020-02-20" => array:1 [▼
    0 => array:31 [▼
      "id" => 7
      "bookable_type" => "App\Room"
      "bookable_id" => 2
      "local_reservation_id" => 46
      "name" => null
      "email" => null
      "booked_by" => "37"
      "user_id" => null
      "no_date" => 1
      "quantity" => 0
      "check_in" => "2020-02-27 00:00:00"
      "check_out" => "2020-02-28 00:00:00"
      "discount" => "0.05"
      …..
    ]
  ]
  "azZ-2020-02-20" => array:1 [▶]
  "KrB-2020-02-20" => array:3 [▶]

What I am try to do is for each blade

<table id="check_balance" class="display nowrap" style="width:100%">
  
  <thead>

   <tr>

     <th>No</th>

     <th>Date</th>

     <th>Name</th>
   
     <th>Phone No</th>

     <th>Types</th>

     <th>Booked By</th>

     <th>User Account</th>

      <th>Payed Amount</th>

      <th>Refund Amount</th>

     <th>Net</th>

    <th width="280px">Action</th>

    <!--  <th width="280px">Action</th> -->

   </tr>
</thead>

  
 <tbody>
 @foreach ($groups as $key => $group)

$BookingIds=$group->pluck('id');
$first=$group->first();
$types=$group->pluck('bookable');
<!-- ->flatten()->pluck('slug') -->
$implodeTypes=$types->implode('slug', ', ');

$payedAmount=$group->pluck('pay')->sum();
$refundAmount=$group->pluck('fund')->sum();
    <tr>
      <td>{{ ++$i }}</td>
      <td>{{$first->updated_at}}</td>


      <td>{{$first->localreservation->full_name}}</td>

      <td>{{$first->localreservation->phone_no}}</td>

      <td>{{$implodeTypes}}</td>
      <td>{{$first->booked_by}}</td>
      <td>{{$first->localreservation->localUserBankAccount}}</td>
      <td>{{$payedAmount}}</td>
      <td>{{$refundAmount}}</td>
      
      <td>{{$payedAmount-$refundAmount}}</td>

      <td>

         <a class="btn btn-primary" href="{{ route('local.approve',$BookingIds) }}">Approve</a>

      </td>
      
    </tr>
     @endforeach
  </tbody>

The problem is eloquent and collects query not used in blade, any suggestion, please!!

Activity icon

Replied to Pass Data In Json

@sergiu17, thanks for a fast reply !! is there is any simple method

in this method working fine, but i need to pass quantity and use

data:form_data,

but is change the json to string

 data:{
 quantity:quantity,
    form_data 
}
Activity icon

Started a new Conversation Pass Data In Json

how to change string to json /object

data:{
    quantity:quantity,
    form_data                                     
  }, // out put ---> form_data:"name=&type_of_organization=&city_id=&type=Room&start_price=300+ETB

to

// output --->   name: null, type_of_organization: null, city_id: "68", type: "Room", 
Feb
18
1 month ago
Activity icon

Started a new Conversation Ajax Callback

<div class="col-xs-12 col-sm-12 col-md-12 text-center ">
      <button  id="finish" class="btn btn-primary">finish</button>
 </div>

//script

 $('#addNew').click(function(cb){

    $.ajax({
 type:GET;
 url:'Get/local/'
 dataType:'json',
 data:form_data,
success:function(res){ 

cb(res); 
}
});

//and now I want to pass res I get to other function, and I try this, but not working

$('#finish').click(function(res){
console.log(res);

});

any help, please. res..give me data of an object. my problem is I am new to ajax and I don't know how to a callback res to other function

Feb
15
1 month ago
Activity icon

Replied to Tablular Format

console.log(res)

{id: 37, bookable_type: "App\Room", bookable_id: 2,....

res.id, res.no_date.... is working , but render many row ....

i try for loop

$.each(res, function (key, value) {
  for (key = 0; key < res.value.length; key++){
'<td id="row_'+rowCount+'" >' +rowCount+ '</td>'+
 '<td>' + res.value[key].id + '</td>'+
'<td>' + res.value[key].bookable_type + '</td>'+
....

not working say 'length' of undefined

Activity icon

Replied to Tablular Format

 var trHTML = '';
     $.each(res, function (i, item) {
      console.log(item.id);

console.log(item.id); i try this undefine , but in my crome response

{"id":13,"bookable_type":"App\Room",...

i also try console.log(item[0].id), but not working

Activity icon

Started a new Conversation Tablular Format

hello guys some issue in tablular format

<table id="org_table" class="display nowrap" style="width:100%">
  
                          <thead>

                           <tr>

                             <th>No</th>

                             <th>Org Name</th>
                           
                             <th>Type</th>.......
                        </tr>
                        </thead>
                        <tbody id="tBody"></tbody>
</table>

ajax blade code

 $('#addNew').click(function(){
                $.ajaxSetup({
                    headers: {
                      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                   }
                   });// ajaxsetup
var rowCount=$("#org_table tbody tr").length+1; 
// ?organization="+orgID+'&name='+form_data,
                   $.ajax({
                          type:"POST",
                         url:"{{route('localBook.store')}}?user_type="+userType,
                                dataType:'json',
                                data:form_data,
                                success:function(res){ 


           var trHTML = '';
               $.each(res, function (i, item) {
                  trHTML += 
                   '<tr>'+
                      '<td id="row_'+rowCount+'" >' +rowCount+ '</td>'+
                       '<td>' + res.item.bookable.slug + '</td>'+
                       '<td>' + res.item.bookable_type + '</td>'+
                       '<td>' + res.item.bookable.slug + '</td>'+
                      '<td>' + res.item.no_date + '</td>'+
                      '<td>' + res.item.quantity + '</td>'+
                       '<td>' + res.item.bookable.room_price + '</td>'+
                       '<td>' + res.item.sub_total + '</td>'+
                       '<td>' + res.item.discount_amount + '</td>'+
                       '<td>' + res.item.discount_price_on_web + '</td>'+
                      '<th id="delete_'+rowCount+'" scope="row" class="delete_row" >'+remove+'</th>'+
                   '</tr>';
                       });
                $('#org_table tbody').append(trHTML);
                    }// function success 
                 });

        });// #add new

response on console crome

{"id":13,"bookable_type":"App\Room","bookable_id":2,"local_reservation_id":20,"booked_by":"37","name":null,"email":null,"user_id":null,"no_date":2,"quantity":1,"check_in":"2020-02-27 00:00:00",.....
}

my table is not showing up this is b/c post request???? or did i make mistake, thanks in adavance

Feb
13
1 month ago
Activity icon

Started a new Conversation Ajax Search

inside form tag i have a search field.

<div class="form-row ">

                     <div class="col-sm-6 col-md-2 col-lg-2 mb-4">
                        <div class="select-wrap">
                        
                          <input type="text" name="name" id="name" class="form-control" placeholder="Search By Name">
                         
                       </div>

                      </div>
  <div class="col-sm-6 col-md-2 col-lg-2 mb-4">
                        
                       <button id="search" class="btn btn-primary">Search</button>
                      </div> <!-- end of serach warap  -->
</div>

Ajax

function search(){
                          var form_data = {
                            search_name:$('#name').val(),
                            org_type:$('#type_of_organization').val(),
                            city:$('#city_id').val(),
                            type:$('#type').val(),
                            start_price:$('#amount_start').val(),
                            end_price:$('#amount_end').val(),
                            check_in:$('#check_in').val(),
                            check_out:$('#check_out').val(),
                          } //end of var

                        if(form_data){
                             $.ajax({
                                type:"GET",
                                url:"{{route('local.search')}}?search="+form_data,
                                dataType:'json',
                                data:form_data,
                                success:function(res){
console.log(res);
}

 function registorEvents(){
                    $(document).on('click','#search',search);
                }
                  registorEvents();

the problem is render blank page and change my url from ../book/create to../book

APIController

 public function localSearch(Request $request)
     { 
        

        if($request->ajax())
         {
             

                    $name=$request->get('name');
                    $org_type=$request->get('org_type');
                    $city=$request->get('city');
                    $type=$request->get('type');
                    $start_price=$request->get('start_price');
                    $end_price=$request->get('end_price');
                    $check_in=$request->get('check_in');
                    $check_out=$request->get('check_out');
.....

Route::get('api/local-search','[email protected]')->name('local.search');

Feb
08
1 month ago
Activity icon

Replied to Inside Where

@tisuchi it is not working error "mb_strpos() aspects parameter 1 to be string object given "

Activity icon

Started a new Conversation Inside Where

organization and individualRooms hasManyThrough Relationship. App/Organization::with('individualRooms')->get(); working fine.

      $orgAvailable = Organization::with('individualRooms')->where(function ($query) use ($individualRoomReserveId) {
    $query->whereNotIn('individualRooms.id', $individualRoomReserveId);
})->first();

my question is how can i use individualRooms column?? it shows me some error "individualRoom.id is not found in organization column."

any help, thanks

Feb
06
1 month ago
Activity icon

Started a new Conversation Relationship

$organization->room //conference ->booking // 1 to many polymorphic relationship room.php/model

 public function bookings()
    {
        return $this->morphMany('App\Booking', 'bookable');
    }
 public function organization()
    {
        return $this->belongsTo(Organization::class, 'organization_id');
    }

conference.php also similar with the room.php

the organization has 1 to many relationships with the room and conference.

my question is how can i get $organization->booking;

$organization->booking;

//i try hasManyThrough, but it only works either room or conference.

  public function booking()
     {
       return $this->hasManyThrough(Booking::class, Room::class, 'organization_id','bookable_id','id','id');
   } 

any help please, thanks

Feb
05
1 month ago
Activity icon

Replied to Array

@sinnbeck and @sti3bas thanks very much !!

Activity icon

Started a new Conversation Array

relationship booking.php //model

public function individualRooms()

    {
      return $this->belongsToMany(individualRoom::class,'booking__individualroom');
    }
 App\Booking::with('individualRooms')->get()

what i want is all the individual roooms and itry this

})->with('individualRooms')->get()->pluck('individualRooms','id')->toArray();

output

array:3 [▼
  2 => array:1 [▼
    0 => array:8 [▼
      "id" => 3
      "room_id" => 1
      "room_no" => 202
      "room_floor" => null
      "created_at" => "2020-01-26 16:02:39"
      "updated_at" => "2020-01-26 16:02:39"
      "deleted_at" => null
      "pivot" => array:2 [▶]
    ]
  ]
  3 => array:2 [▼
    0 => array:8 [▶]
    1 => array:8 [▶]
  ]
  4 => array:2 [▼
    0 => array:8 [▶]
    1 => array:8 [▶]
  ]
]

but what i need is

0 => array:8 [▼
    "id" => 8
    "room_id" => 1
    "room_no" => 401
    "room_floor" => null
    "created_at" => "2020-02-03 19:31:44"
    "updated_at" => "2020-02-03 19:31:44"
    "deleted_at" => null
    "pivot" => array:2 [▶]
  ]
  1 => array:8 [▼
    "id" => 3
    "room_id" => 1
    "room_no" => 202
    "room_floor" => null
    "created_at" => "2020-01-26 16:02:39"
    "updated_at" => "2020-01-26 16:02:39"
    "deleted_at" => null
    "pivot" => array:2 [▶]
  ]
2 => array:8 [▼
    "id" => 3
    "room_id" => 1
    "room_no" => 202
    "room_floor" => null
    "created_at" => "2020-01-26 16:02:39"
    "updated_at" => "2020-01-26 16:02:39"
    "deleted_at" => null
    "pivot" => array:2 [▶]
  ]

any help, please??

Feb
04
1 month ago
Activity icon

Replied to Query Filter

 })->with('individualRooms')->get()->pluck('individualRooms')->toArray();

out put

array:2 [▼
  0 => array:1 [▼
    0 => array:8 [▶]
  ]
  1 => array:2 [▼
    0 => array:8 [▶]
    1 => array:8 [▶]
  ]
]

using first

 })->with('individualRooms')->get()->pluck('individualRooms')->first()->toArray();

result

 0 => array:8 [▼
    "id" => 3
    "room_id" => 1
    "room_no" => 202
    "room_floor" => null
    "created_at" => "2020-01-26 16:02:39"
    "updated_at" => "2020-01-26 16:02:39"
    "deleted_at" => null
    "pivot" => array:2 [▶]
  ]
]

working fine, but only the "first array" show up to access room_no.

my question is how can i get all array and access "room_no" get list like pluck('id','room_no');

Feb
03
2 months ago
Activity icon

Started a new Conversation Query Filter

d/m/y . ... and 02/01/20 -03/01/20 room 101 booked.

14/01/20-21/01/20 101 and 201 booked.

my question is on 03/01/20 - 14/01/20 both 101 and 201 available, but in my query getting 101, 101, 201, is there is other way ???

$roomNotReserve =$room->bookings()
                  ->whereNotIn('book_status_id',$statusCollect)
                  ->where(function($q2) use ($check_in, $check_out) {

                        $q2->where('check_in','>=',$check_out) 
                           ->orWhere('check_out','<=',$check_in);
                    })->with('individualRooms')->get()->pluck('individualRooms')->toArray();
 $q2->where('check_in','>=',$check_out) 
                           ->orWhere('check_out','<=',$check_in);

not consider the repetition!! same room booked on the different dates are all show up.

Activity icon

Replied to Sync Many To Many

@ahmeddabak thanks for the reply

can you give some example? modelKeys()??

$booking->individualRooms()->sync($room->individualRoom->modelKeys()));

and one more how to count multiple selected fields. 1selected, 2 or 3 based multiple

 {!! Form::select('quantity', $result,[], array('class' => 'form-control','multiple')) !!}
Feb
02
2 months ago
Activity icon

Replied to Query

@ahmeddabak my problem is using merge method [0=>101,1=>102] and [1=>202,3=>402]. the merge result is like this[0=>101,1=>202,3=>402], but what i need is [0=>101,1=>102,2=>202,=>3=>402]. so merge method is not working for me.

i try use array_merge($array1,$array2 and put it inside collect[] and pluck('id',room_no). same result of the merge in the collection. my question using two collections and merge them together, why dont i create 1 collection using query builder, but i make somewhere mistake

for example

->where(function ($query,$status_id){ // show me some error 1 paramete expected error...extra  

the first two collective and merge work fine expect the out put i need with pluck('id','room_no'),


edit the second query to get the first result without using merge
Activity icon

Started a new Conversation Query

$status_id = BookStatus::where('name', 'Booked')->firstOrFail()->id;
        $check_in =$check['check_in'];
        $check_out=$check['check_out'];

$booking_id=$room->bookings()->with('individualRooms')->get();
      $booking_list=$booking_id->pluck('individual_rooms');

  $roomNeverBooking =$room->individualRooms()->whereNotIn('id',$booking_list)->get()->pluck('id','room_no');

         $roomNotReserve = $room->bookings()->with('individualRooms')->whereNotIn('bookings.book_status_id',[$status_id])

                         ->when(request(['check_in','check_out']), function($q){

                        return $q->where('bookings.check_out','=<', request('check_in'))
                              ->orWhere('bookings.check_in','>=',request('check_out'));
                               
               })->with('individualRooms')->get()->pluck('id','room_no');
            
       $result=$roomNeverBooking->merge($roomNotReserve); 

change this one line query how??????????

$roomNotReserve =$room->individualRooms()->whereNotIn('id',$booking_list)
                ->where(function ($query,$status_id){
                  $query->with('individualRooms')->whereNotIn('bookings.book_status_id',[$status_id])
                        ->when(request(['check_in','check_out']), function($q){

                          return $q->where('bookings.check_out','=<', request('check_in'))
                               ->orWhere('bookings.check_in','>=',request('check_out'));
                             });

                    })->get()->pluck('id','room_no');

        dd($roomNotReserve);// error 

edit the second query to give me the 1st output. :)

Activity icon

Started a new Conversation Query

sorry

Activity icon

Started a new Conversation Query

sorry

Feb
01
2 months ago
Activity icon

Started a new Conversation Sync Many To Many

hello guys

room parent has 5 room child. quantity count the room child show in front end. my question is if the customer choice quantity b/n 1 to 5 . let say the customer choice 3 and book the room. the first 3 room children save in pavot table of booking_Individual. how can i do this??

room(parent)->individualRoom(child) 1 to many relationship

$result=$room()->individiual_rooms_count()->get();

<div class="form-group">
            <strong>Quantity:</strong>
    

              <select  name="quantity" >   
                  @for($i=1; $i<=$result; $i++)  
                  <option  >{{$i}}</option>
                  @endfor
              </select>

    
        </div>

booking.php //model


    public function individualRooms()

    {
      return $this->belongsToMany(individualRoom::class,'booking__individualroom');
    }

storeBooking

$booking =$room->bookings()->create($booking);
 $booking->individualRooms()->sync([???]));

if the user select 2 quantity the store the first 2 individual room, if 3 quantity selected same the first 3 from the individualroom .....

Jan
31
2 months ago
Activity icon

Started a new Conversation WithCount

hey guys

organization->room->individualRoom

organization.php //model