jeudi 31 janvier 2019

How can i get 3 table data in index in laravel?

I have 3 tables schools, school_Details,ratings

** Schools**

  • id

  • name

  • phone

  • school

  • email

  • status

School details:

-id

  • school_id

  • image

  • status

ratings:

-id

  • school_id
  • rating_value
  • status

both rating &school details have only one row for one school_id.

Now how can i get all details from all 3 tables in index from schoolController



via Chebli Mohamed

Error whille running composer install on PHP 7.2 Ubuntu

I kept getting this error at the end of my composer install on PHP 7.2 - Laravel 5.1

> php artisan clear-compiled
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/forge/bheng/app/Exceptions/Handler.php:29
Stack trace:
#0 /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
  thrown in /home/forge/bheng/app/Exceptions/Handler.php on line 29
[2019-01-31 10:29:34] production.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/forge/bheng/app/Exceptions/Handler.php:29
Stack trace:
#0 /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
  thrown in /home/forge/bheng/app/Exceptions/Handler.php:29
Stack trace:
#0 {main}  



  [Symfony\Component\Debug\Exception\FatalErrorException]                                                                                                                                                                                                                                                                       
  Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/forge/bheng/app/Exceptions/Handler.php:29  
  Stack trace:                                                                                                                                                                                                                                                                                                                  
  #0 /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error))                                                                                                                                                                     
  #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))                                                                                                                                                                                                                      
  #2 {main}                                                                                                                                                                                                                                                                                                                     
    thrown                                                                                                                                                                                                                                                                                                                      


Script php artisan clear-compiled handling the post-update-cmd event returned with error code 255
┌──[root@bheng]──[/home/forge/bheng] 
└──  

How can I prevent that ?



via Chebli Mohamed

How can i store data?

This is view file in this include...css,html and ajax

@extends('layouts.app')

@section('content')
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script> 
<form enctype="multipart/form-data" method="post" action="" >
                @csrf
<div class="form-group col-md-8">
  <button type="button" class="form-control" data-toggle="modal" data-target="#myModal">
Category  </button>

  <!-- The Modal -->
  <div class="modal" id="myModal">
<div class="modal-dialog modal-lg" >
      <div class="modal-content">
      
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title">Category</h4>
          <button type="button" class="close" data-dismiss="modal">&times;</button>
        </div>

        <div class="modal-body">
  <div class="row">
        <div class="col-md-4" >
          
              @foreach($categories as $category)
              <option  class="categoryList" value=""></option>
              @endforeach
           
        </div>
        <div class="col-md-4 ">
          <a href="#" name="subcategory" id="subcategory" >
          </a>
        </div>
  </div>
</div>
      </div>
    </div>
  </div>

</div>
 <div class="form-group col-md-8">
                    <button type="submit" class="btn btn-primary" value="submit">Submit</button>
                </div>
</form>

<script type="text/javascript">

    $(function(){
        $('.categoryList').on('click', function(){
          //alert('hi');
          var cat_id = $(this).attr('value');
          console.log(cat_id);
          var url = "/api/getSubcategory/"+cat_id;
          $.ajax({
              type: "GET",
              url: url,
              dataType: "JSON",
              success: function(res)
              {
                // amusing res = {"3":"home","4":"home duplex"}; 
                var html = "";
                $.each(res, function (key, value) {
                     html += "<option value="+key+">"+value+"</option>";
                });
                $("#subcategory").html(html);
              }
          });
        });

    });

</script>

@endsection
This is my controller
    public function create(){
        $categories = Category::all();
      $subcategories = Subcategory::all();

        return view('post.create', compact('categories', 'subcategories'));
    }
     public function getSubcategory(Request $request){
        $id = $request->id;
         $subcategories = Subcategory::where('category_id',$id)->select
('subcategory','id')->pluck('subcategory', 'id');
return json_encode($subcategories);
    }

This is web.php

Route::get('/post/create', 'PostController@create')->name('post.create');
    Route::get('api/getSubcategory/{id}', 'PostController@getSubcategory' );

This is my output

problem is i am select still not show in box which subcategory i selected and not store in database I want to do how can i show in box which category and subcategory i selected and how to store in database My english is not good so sorry but i am stuck in problem..How can i do perfectly?



via Chebli Mohamed

mercredi 30 janvier 2019

assertJson and assertSee show call to a null member error

I trying to develop a test for my APIs,

This is my code:

public function testFirstAPI()
    {
        $user = \User::find(1);
        $r = $this
            ->actingAs($user)
            ->json('put', route('updateUser'),['lock' => 'true']);
        $r->assertResponseStatus(200)->seeJson(['success' => true]);
    }

this test will work and when I use $r->dump() I can found the success in the response.

but I don't know why seeJson show this error:

Symfony\Component\Debug\Exception\FatalErrorException]
  Call to a member function assertJson() on null



via Chebli Mohamed

lundi 28 janvier 2019

How to Display All Categories in Laravel

Am trying to display all the category in the database on single post blade, however, am also display five out the category in the database as my navigation menu. I am not sure maybe its the loop I am using as I keep getting five categories instead of all categories.

public function index()
{
    return view('index')->with('title', Setting::first()->site_name)
        ->with('categories', Category::take(5)->get())
        ->with('first_post', Post::orderBy('created_at', 'desc')->first())
        ->with('second_post', Post::orderBy('created_at', 'desc')->skip(1)->take(1)->get()->first())
        ->with('third_post', Post::orderBy('created_at', 'desc')->skip(2)->take(1)->get()->first())
        ->with('wordpress', Category::find(4))
        ->with('laravel', Category::find(3))
        ->with('settings', Setting::first());
}

Here is the code for my single post controller

public function singlePost($slug)
{
    $post = Post::where('slug', $slug)->first();
    $next_id = Post::where('id', '>', $post->id)->min('id');
    $prev_id = Post::where('id', '<', $post->id)->max('id');

    return view('single')->with('post', $post)
        ->with('title', $post->title)
        ->with('settings', Setting::first())
        ->with('categories', Category::all())
        ->with('next', Post::find($next_id))
        ->with('prev', Post::find($prev_id))
        ->with('tags', Tag::all())
        ->with('first_post', Post::orderBy('created_at', 'desc')->first())
        ->with('second_post', Post::orderBy('created_at', 'desc')->skip(1)->take(1)->get()->first())
        ->with('third_post', Post::orderBy('created_at', 'desc')->skip(2)->take(1)->get()->first());
}

This is how I passed the value in the single.blade.php

@foreach($categories as $category)
    <div class="post-category-wrap">
        <div class="category-post-item">
            <!-- <span class="post-count">168</span> -->
            <a href="{‌{route('category.single', ['id' => $category->slug])}}" class="category-title">{‌{$category->name}}
                <i class="seoicon-right-arrow"></i>
            </a>
        </div>
    </div>
@endforeach 



via Chebli Mohamed

dimanche 27 janvier 2019

Api have decode data but not work in form

This is my create.blade.php file which include ajax function API and HTML tag code..

@extends('layouts.app')

@section('content')
       <link rel="stylesheet" href="http://www.codermen.com/css/bootstrap.min.css">    
    <script src="http://www.codermen.com/js/jquery.js"></script>
<form enctype="multipart/form-data" method="post" action="" >
                @csrf

<div class="form-group col-md-8">
                    Category<select name="category" id="category" class="form-control">
                                    <option>select</option>
                        @foreach($categories as $category)
                <option value=""></option>
                @endforeach
                            </select>
                </div>
                <div class="form-group col-md-8">
                    Category<select name="subcategory" id="subcategory" class="form-control">
                                    <option>select</option>
                        @foreach($subcategories as $subcategory)
                <option value=""></option>
                @endforeach
                            </select>
                </div>
</form>

<script type="text/javascript">
      $(document).ready(function() {
       
                        $('#category').change(function(){
                var categoryID = $(this).val();
                if(categoryID){
                    $.ajax({
                        type:"GET",
                        url:"/"+categoryID,

                        success:function(res){

                            if(res){
                                $("#subcategory").empty();
                                $("#subcategory").append('<option>Select</option>');
                                $.each(res,function(key,value){
                                    $("#market").append("<option value='"+key+"'>"+value+"</option>");
                                });

                            }else{
                                $("#subcategory").empty();
                            }
                        }
                    });
                }else{
                    $("#subcategory").empty();
                }
            });
</script>
@endsection

This is my controller code which include create function and getSubcategory function

public function create(){
    $categories = Category::all();
  $subcategories = Subcategory::all();
    return view('post.create', compact('categories', 'subcategories'));
}


 public function getSubcategory(Request $request){

    $id = $request->id;
    $subcategories = Subcategory::where('category_id',$id)->select
    ('Subcategory','id')->get();

      
      // return view('post.create')->with('subcategories', json_decode($subcategories, true));

}

This is my web.php

Route::get('/post/create', 'PostController@create')->name('post.create');
Route::get('api/getSubcategory/{id}', 'PostController@getSubcategory' );

Now my problem is API have data and give me API output

but when i open this page and select category still not show related subcategory Error show this image



via Chebli Mohamed

jeudi 24 janvier 2019

Format decimal value in database in where clause

I want to get data from database but the format of values that are compared do not tally.

The numbers in database are saved in weird format - sometimes are rounded and some of those are decimals (10, 14, 15, 12.44, 16.10, etc.)

In array I have values rounded on 2 decimals though.

I want to get data from database like so:

$foundPayments = $this>paymentsRepo>newQuery()>whereRaw("CONVERT(DECIMAL(10,2),payments.amount) = :payments", ['payments' => $payments]);

Althought, I end up with an error like this: Syntax error: 7 ERROR: syntax error at or near ","

I am not sure if the code works in laravel 5.1 with sending params like I do but thats not really what I do care for in that - the same error apperars even when I do not use variable.



via Chebli Mohamed

mercredi 23 janvier 2019

Controller is not getting file submitted

i am submitting the form which is having file but when i try to get the file in controller it always return failure.

i have tried possible thing.

Save

public function storeLogo(request $request){

if($request->hasFile('logo')){

         $image=$request->file($yes);
         $fileName= time().'.'.$image->getClientOriginalExtension();
         $location=public_path('merchantGlobal/'.$fileName);
         Image::make($image)->save($location);
         return "success";

  }

        return "failure";


}

I want get success message of controller



via Chebli Mohamed

How to redirect one category to sub category?

This is FrontController

public function index(){
    $categories = DB::table('categories')
        ->select('category')
        ->groupBy('category')
        ->get();
    return view('front', compact('categories'));
}

This is blade layout

@foreach($categories as $category)
<a href=""><h2 class="card-title"></br></h2></a>
@endforeach

Categories-table structure and data

This is my front page

My question is when i click any category redirect to related to subcategory...How can i do that??



via Chebli Mohamed

Laravel pivot table relational data not retrieve

I have four table.

country
----------
id,name

service
----------
id,name

country_service
----------
id,country_id,service_id

country_service_rate
----------
id,country_service_id,rate

Now I want to get value of country_service_rate table row.

country_service model

public function rate(){
    return $this->belongsTo('App\CountryServiceRate');
}

Service Model

public function country(){
    return $this->belongsToMany(Country::class)->withPivot('id','is_base');
}

When I am trying to get data of pivot table related

$country->pivot->rate

getting null. But $country->pivot showing country_service table row data.



via Chebli Mohamed

lundi 21 janvier 2019

first made all panel of admin, then made designing part and when trying to merge file in my laravel file getting issue

first I made admin panel, then made designing part and when trying to merge file into my laravel file getting issue.

First Paste my folder of design code in htdocs->blogging(my project name) and then I move app file of design in public folder(in php artisan software). then I copied all data of home page and paste in welcome.blade.php and when running my blog.post, its showing nothing. Anyone can suggest that please. thank you.

this is my home page code that is running successfully in html i have pasted in welcome.blade.php

                    <div class="post__content-info">

                        <h2 class="post__title entry-title ">
                            <a href="15_blog_details.html">The Important & Standard Post Format</a>
                        </h2>

                        <div class="post-additional-info">

                                    <span class="post__date">

                                        <i class="seoicon-clock"></i>


                                        </time>



via Chebli Mohamed

vendredi 18 janvier 2019

How can i update two table admission & payments when payment is successful in laravel paytm?

I am saving name, class ,subject, user_id in admission table except payment_status and then after clicking on pay now button payments data such as payment_id , user_id , transaction_id, payment_status etc is captured in Payments table now how can i update payment_status field in admission when payment is successful in paytm.

 public function paynow(Request $request, $slug)
    {

     

      $payment_gateway = $request->gateway;

          if($payment_gateway=='paytm'){

               
         $order_id = strtolower(str_random(25));


        $token = $this->preserveBeforeSave($item,$order_id, $type,  $payment_gateway, $other_details);

        $data_for_request = $this->handlePaytmRequest( $order_id, $amount );


        $paytm_txn_url = 'https://securegw.paytm.in/theia/processTransaction';
        $paramList = $data_for_request['paramList'];
        $checkSum = $data_for_request['checkSum'];



        return view('payments.paytm',compact('paytm_txn_url','token', 'paramList', 'checkSum' ));


      }

      dd('please wait...');
    }
    
    
    public function handlePaytmRequest( $order_id, $amount ) {
        // Load all functions of encdec_paytm.php and config-paytm.php
        $this->getAllEncdecFunc();
        $this->getConfigPaytmSettings();

        $checkSum = "";
        $paramList = array();

        // Create an array having all required parameters for creating checksum.
        $paramList["MID"] = 'ytrytrytrytrty';
        $paramList["ORDER_ID"] = $order_id;
        $paramList["CUST_ID"] = $order_id;
        $paramList["INDUSTRY_TYPE_ID"] = 'Rta109';
        $paramList["CHANNEL_ID"] = 'WEB';
        $paramList["TXN_AMOUNT"] = '299';
        $paramList["WEBSITE"] = 'WEBPROD';
        $paramList["CALLBACK_URL"] = url( 'https://www.ravi.com/payments/paytm/paytmCallback' );
        $paytm_merchant_key = 'ytgduzyMHCahghghg9LlXnHlZ';

        //Here checksum string will return by getChecksumFromArray() function.
        $checkSum = getChecksumFromArray( $paramList, $paytm_merchant_key );

        return array(
            'checkSum' => $checkSum,
            'paramList' => $paramList
        );
    }
    
    
    public function paytmCallback( Request $request ) {
      
   
        $order_id = $request['ORDERID'];
               $user = Auth::user();


        if ( 'TXN_SUCCESS' === $request['STATUS'] ) {
            $transaction_id = $request['TXNID'];
            $status = $request['STATUS'];
           
            if($this->paymentSuccess($request))
        {


       
        }
        else {
       
        }

      //REDIRECT THE USER BY LOADING A VIEW

                return \Redirect()->route('account')->with('danger', 'Your payment was successfull, now you can give exam within 15 days');

        } else if( 'TXN_FAILURE' === $request['STATUS'] ){
                return \Redirect()->route('account')->with('danger', 'Your payment was failed, kindly try again');
        }
    }
    
     public function preserveBeforeSave($item, $order_id, $package_type,$payment_method)
    {

  
      $payment          = new Payment();
      $payment->item_id     = $item->id;
      $payment->item_name     = $item->title;
      $payment->plan_type     = $package_type;
      $payment->payment_gateway = $payment_method;
      $payment->slug      = $order_id;
      $payment->cost      = $item->cost;
      $payment->user_id     = $user->id;
      $payment->payment_status  = PAYMENT_STATUS_PENDING;
    
      $payment->save();
      return $payment->slug;
    }


via Chebli Mohamed

jeudi 17 janvier 2019

I am new in laravel and I want to announcement on homepage

Actually I want to display admin announcement or any notification on home page so when ever any user will be login with credentials detail so he or she can see announcement or notification..

please help me step by step , if possible with code logic, please do for me thank you very much



via Chebli Mohamed

mercredi 16 janvier 2019

How can i give perfect relationship each other table?

i am confuse about database relationship...I am creating website like classified ads..without registartion how user can post?? Registration users and without registration users form are same...but how to store data without registartion user

This is form

This is database



via Chebli Mohamed

mardi 15 janvier 2019

How can i avoid image required in edit form if image exist in laravel?

I am adding and editing a user with same function (Store), when ever i add a user it asks me image is required but whenever i edit a user which have image it also ask me image is required and i want if a image is already present it wont ask me

                                 
  I am saving like this
                                 
 public function store(Request $request)
        {
           $rule=array(
                    'name' => 'required',

               'image' => 'required',
                                 );
                                 
              if(!empty($inputs['id'])){
                            $user = User::findOrFail($inputs['id']);
                        }else{
                            $user = new User;
                        }
   
        $user_image = $request->file('image');

       if($user_image){
       
            $tmpFilePath = 'uploads/candidates/';

            $hardPath =  str_slug($inputs['name'], '-').'-'.md5(time());
            $img = Image::make($user_image);
            $img->fit(300, 300)->save($tmpFilePath.$hardPath.'-b.jpg');
            $user->image = $tmpFilePath.$hardPath.'-b.jpg';

        }
                      $user->name = $inputs['name'];
                      $user->save();

        }


via Chebli Mohamed

dimanche 13 janvier 2019

How to fetch all data from 3 tables with condition in laravel?

I have 3 tables school ,schooldetails & admission, and i want to get all data in index page how can i do that , i am getting data of school and admission table due to relationship but not of school details kindly check it and help

school

id
name
name
mobile
city


schooldetails
id
school_id(foreign key of school id)
contact_person

admission

id
school_id(foreign key of school_deatils id)
admission_classes
start_date
end_date

My function
public function schoolslist($class='', $city='')
        {
        $schools = Admission::where('admission_classes', 'like', "%{$class}%")->where('status', '1')->orderBy('id','desc')->whereHas('school', function($query) use($city) {
    $query->where('city', 'like', $city);
})->paginate(10);
          return view('frontend.index',compact('schools'));

        }
        my Admission model
        public function School()
    {
        return $this->belongsTo('App\School');
    }
    public function SchoolDetails()
    {
        return $this->belongsTo('App\SchoolDetails');
    }
        
        My view
         @foreach($schools as $i => $school)
          from user table Ravi
        //from school_Details table  No result 
          //from admission table  date 11/22/2018
         @enforeach


via Chebli Mohamed

Laravel load more on pagination not working as expected

I am trying to do load more using jquery

  $response=Event::when(isset($request->id),function ($query)use ($request){
            $query->where('id','>',$request->id);
        })->where(function ($query){
            $query->whereDate('event_start_date','>=',Carbon::now());
            $query->orWhereDate('event_end_date','>=',Carbon::now());

        })->orderBy('event_start_date', 'ASC')
            ->paginate(12) ;

I have 10 posts where id=4 ,5,6 post event will come end because of event_start_date is 30th jan

every time when i click load more i was sending last event id so post 4,5,6 is not appearing because i have condition $query->where('id','>',$request->id);

Sample db data

id |event_start_date | event_end_date
1 |2019-01-15 20:00:00|2019-01-15 20:00:00
2 |2019-01-15 20:00:00|2019-01-15 20:00:00
3 |2019-01-15 20:00:00|2019-01-15 20:00:00
4 |2019-01-27 20:00:00|2019-01-30 20:00:00
5 |2019-01-28 20:00:00|2019-01-31 20:00:00
6 |2019-01-29 20:00:00|2019-01-31 20:00:00
7 |2019-01-15 20:00:00|2019-01-15 20:00:00
8 |2019-01-15 20:00:00|2019-01-15 20:00:00
9 |2019-01-15 20:00:00|2019-01-15 20:00:00
10 |2019-01-15 20:00:00|2019-01-15 20:00:00

can any one help me how i can fix this issue ?



via Chebli Mohamed

vendredi 11 janvier 2019

TokenMismatch when sending out contact mail - Laravel 5

I have a contact feature on my Laravel app.

I kept getting

enter image description here

When I submit my contact

enter image description here

I configured it correct with my password

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mail.yahoo.com
MAIL_PORT=465
MAIL_USERNAME=dev.bunglongheng@yahoo.com
MAIL_PASSWORD=*******

Any hints for me ?



via Chebli Mohamed

How can i decode json data if i saved in array laravel?

I have 2 two table one is admission and other is class table and i am saving class id in admission class field of admission table by jsonencode method.

My controller
public function store(Request $request)
{
$admission = new Admission;
$admission->school_id = Auth::User()->id;
$admission->admission_classes=json_encode($inputs['admission_classes']);
$admission->save();   

}

My index function
 public function index(Request $request) {

 $school_id= Auth::user()->id;

 $admissions= Admission::where('school_id',$school_id)->orderBy('id','desc')->paginate(10);
          return view('frontend.index',compact('admissions','active_class'));
          
        }
        My view
        
       
  @foreach($admissions as $i => $admission)
  
  
  
  @endforeach
  
 I am getting data in this way:-
 
 ["1","2","4","5","6","7","8","9"]      
 
 But i want to get in this format:
 Nursery,Class 1, Class2, Class3 etc

        


via Chebli Mohamed

jeudi 10 janvier 2019

How can i search fetch all data from 3 tables and show it in my view in laravel?

I have 3 tables School,School details, and admission , and i am saving school id of school in school details & admission table with other information. Now i want to get all schools list that i am saving in all 3 tables. I am able to find data of two table school and admission not of school details table.

public function schoolslist($class='', $city='') {

    $schools = Admission::whereHas('school', function($query) use($city) { 
      $query->where('city', 'like', $city);})->where('admission_classes', $class)->where('status', '1')->orderBy('id','desc')->paginate(10);

      return view('frontend.schoollist',compact('schools'));

    }



via Chebli Mohamed

when i use postman for run API In laravel 5.1 API post method not working

Controller code: public function xyz(){echo 'hello';}

Route::group(['prefix' => 'api'], function(){Route::post('apiregstration','APIcontroller@xyz');});

I use laravel 5.1 and want to create API with post method but it not work , GET method work fine



via Chebli Mohamed

mercredi 9 janvier 2019

Ifill form but not show data in database

enter image description here

I try all the way but not show user_id and image_id in the table

This is model view of post

 protected $fillable = ['title','category','description','name','phone','city'];

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

public function user(){
    return $this->belongsTo('App\User');
}



via Chebli Mohamed

mardi 8 janvier 2019

Please Help Me Locate From Where I Can Buy This Type Of Site

This is my first question here. I am looking to buy a script/theme/etc same as gamingarena .app (just remove the space before .app).

Can you guys help me locate from where I can find the same framework the above site is using.

There is also another site playerzon.com which is also using the same technology. Both the above examples are identical but are owned by different people. So I think there is some kind of scrtip that I can buy online. But where I don't know.

Please check out the sites and help me. If you register on these sites you will see tournaments that they are organizing and than you can join a tournament by paying a small amount. Please test the sites and let me know if you guys can help.

TIA



via Chebli Mohamed

How to view cities name if I saved it as ID in laravel?

I have three table: users,interviews & cities.

I am saving city ID's in user table city field. I am trying to fetch users city field in interview's section and i am getting all users data such as name, age, mobile etc. but I'm getting only city ID not city name.

My interview model relationship:

public function User()
    {
        return $this->belongsTo('App\User','user_id');
    }

My controller

public function index()
    {
        $user_id= Auth::user()->id;
        $items= Interviews::where('user_id',$user_id)->where('status','>=',1)->orderBy('id', 'desc')->paginate(10);
        return view('frontend.index',compact('items'));
    }

My view

@foreach($items as $i => $item)
        <!-- Item #1 -->
            <tr>
                    <td><b> </td>
                    <td><b></td> 
                    <td><b> </td>
                    <td><b> </td>

            </tr>                            
@endforeach



via Chebli Mohamed

lundi 7 janvier 2019

How to get rows in Eloquent ordered by having most specific relationships?

I have a project in Laravel 5.1 with three tables: articles, tags and a pivot table to save many-to-many relationships: article_tag table.
I need to get all articles related by tags to a specific article, assigning a major number or relevance to those articles that have major number of coincidences by tag. So, first ones would be those which are "more related". For example, if I require all articles with tag_id #1 and #2, and if article A have both tags but article B have only one coincidence, I want get both articles ordered in sequence: A, B.

I think I can do it with a mysql statement:

SELECT articles.*, count(*) as tags_count 
FROM article_tag, articles 
WHERE tag_id in (1,2) 
AND articles.id = article_tag.article_id 
GROUP BY article_id 
ORDER BY tags_count DESC

But I want to use Eloquent. How can I approach it?



via Chebli Mohamed

How can i search for a single id if i save it in array in one field in laravel?

See the image please

I am saving admission classes fields data in array/json encode format,but i want to search all data where id is 7 from admission classes. how can i do it in larave.please guide and see the image above



via Chebli Mohamed