Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Persian language! #8

Merged
merged 12 commits into from
Nov 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

This package includes its own configuration file which you should publish by with the command ```php artisan vendor:publish``` and following the instuctions on screenafterwards. In the configuration file you have to adjust the namespace for you filters directory and your request filter prefix.

```
```php
return [
'filtersFQCN' => 'App\\Filters\\',
'requestFilterPrefix' => 'filter_'
Expand All @@ -36,7 +36,7 @@ return [
```path\to\laravel\app\Filters\User\HasId.php```
Your filter has to extend ModelSearch\Contracts\Filter.

```
```php
<?php

namespace App\Filters\User;
Expand Down Expand Up @@ -66,7 +66,7 @@ class HasId implements Filter
The request filter prefix in the configuration defines the prefix being used for filter names in the request parameters. This can be used to allow the user to apply filters trought POST and GET requests. This has to be done manually by calling the ```addRequestFilters``` method and providing a Request instance.

Always remember to apply filters in the appropiate order.
```
```php
$search = new ModelSearch( User::class );
$search->addRequestFilters( $request );
$result = $search->result();
Expand All @@ -78,7 +78,7 @@ You can change the filter prefix of the Search after by calling the ```setReques

The following example shows you how to use the Search in your Controller:

```
```php
namespace ModelSearch\ModelSearch;


Expand All @@ -99,4 +99,4 @@ public function someController( Request $request ) {

...
}
```
```
141 changes: 141 additions & 0 deletions Readme_fa-FA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<div dir="rtl" style="direction:rtl;text-align:right;">
<h1>جستجوی مدل لاراول</h1>
</div>

[![Build Status](https://travis-ci.org/bumbummen99/laravel-modelsearch.png?branch=master)](https://travis-ci.org/bumbummen99/laravel-modelsearch)
[![codecov](https://codecov.io/gh/bumbummen99/laravel-modelsearch/branch/master/graph/badge.svg)](https://codecov.io/gh/bumbummen99/laravel-modelsearch)
[![StyleCI](https://styleci.io/repos/159666547/shield?branch=master)](https://styleci.io/repos/159666547)
[![Total Downloads](https://poser.pugx.org/skyraptor/modelsearch/downloads.png)](https://packagist.org/packages/skyraptor/modelsearch)
[![Latest Stable Version](https://poser.pugx.org/skyraptor/modelsearch/v/stable)](https://packagist.org/packages/skyraptor/modelsearch)
[![Latest Unstable Version](https://poser.pugx.org/skyraptor/modelsearch/v/unstable)](https://packagist.org/packages/skyraptor/modelsearch)
[![License](https://poser.pugx.org/skyraptor/modelsearch/license)](https://packagist.org/packages/skyraptor/modelsearch)
[![Homepage](https://img.shields.io/badge/homepage-skyraptor.eu-informational.svg?style=flat&logo=appveyor)](https://skyraptor.eu)

<div dir="rtl" style="direction:rtl;text-align:right;">
<p>
Laravel Model Search یک پکیج سبک و با کاربرد آسان است تا بتوانید پرس و جوهای جستجوی پویا را برای مدلهای خاص با Laravel یا Illuminate 5.8 ایجاد کنید.
</p>
</div>

<div dir="rtl" style="direction:rtl;text-align:right;">
<h1>ابزار های وابسته</h1>

- لاراول 5.7+

</div>
<div dir="rtl" style="direction:rtl;text-align:right;">
<h1> نصب کردن</h1>
<h2> کامپوزر</h2>

<p>
دستور کامپوزر `composer require skyraptor/modelsearch` را برای نصب ساده اجرا کنید تا آخرین نسخه موجود نصب شود و سپس برای بروزرسانی دستور زیر را اجرا کنید.

`composer update`

این بسته با استفاده از ServiceProvider بسته Laravels ، ServiceProvider خود را ثبت می کند.
</p>
</div>
<div dir="rtl" style="direction:rtl;text-align:right;">
<h2>تنظیم و کانفیگ</h2>
<p>
این بسته شامل پرونده پیکربندی خود می باشد که شما باید با دستور `php artisan vendor:publish` و دنبال کردن نمونه های موجود در screenafterward. در فایل پیکربندی باید فضای نام را برای فهرست فیلترها و پیشوند فیلتر درخواست خود تنظیم کنید.
</p>
</div>

```
return [
'filtersFQCN' => 'App\\Filters\\',
'requestFilterPrefix' => 'filter_'
];
```

<div dir="rtl" style="direction:rtl;text-align:right;">
<h2>فیلتر ها</h2>
<p>
برای تعریف یک فیلتر ، باید پوشه ای را ایجاد کنید که به عنوان مدل خود در فهرست پوشه فیلترهای شما قرار گیرد. در این پوشه می توانید پوشه مخصوص مدل را ایجاد کنید. مثلا:

مثلا:


فیلتر شما باید مدل ModelSearch \ Contracts \ Filter را گسترش دهد.

</p>
</div>

`path\to\laravel\app\Filters\User\HasId.php`

```php
<?php

namespace App\Filters\User;

use ModelSearch\Contracts\Filter;
use Illuminate\Database\Eloquent\Builder;


class HasId implements Filter
{
/**
* Apply a given search value to the builder instance.
*
* @param Builder $builder
* @param integer $value
* @return Builder $builder
*/
public static function apply(Builder $builder, $value)
{
return $builder->where( 'id', $value );
}
}
```

<div dir="rtl" style="direction:rtl;text-align:right;">
<h2>درخواست فیلتر</h2>

<p>
درخواست پیشوند فیلتر در پیکربندی پیشوند مورد استفاده برای نام فیلترها را در پارامترهای درخواست تعریف می کند. این می تواند مورد استفاده قرار گیرد تا به کاربر اجازه دهد فیلترهای درخواست POST و GET را اعمال کند. این کار باید با فراخوانی روش 'addRequestFilters' و ارائه نمونه درخواست (Request) انجام شود.

همیشه به یاد داشته باشید که فیلترها را به ترتیب مناسب اعمال کنید.
</p>
</div>

```php
$search = new ModelSearch( User::class );
$search->addRequestFilters( $request );
$result = $search->result();
```

<div dir="rtl" style="direction:rtl;text-align:right;">
<p dir="rtl">
می توانید پیشوند فیلتر جستجو را با فراخوانی متد `setRequestFilterPrefix()`تغییر دهید و یک پیشوند جدید ارائه دهید.
</p>
<h2>مثال ها</h2>

<p dir="rtl">
مثال زیر نحوه استفاده از جستجو در Controller را به شما نشان می دهد:
</p>
</div>


```php
namespace ModelSearch\ModelSearch;


public function someController( Request $request ) {
...

$search = new ModelSearch( User::class );
$search->addFilters([
'HasId' => 1,
'HasLastName' => 'Doe'
]);
$search->addFilter('SomeFilter', 'value');
$result = $search->result();

// The search can be extended after processing results
$search->addFilter('AnotherFilter', 'value');
$result2 = $search->result();

...
}
```