jeudi 10 janvier 2019

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